diff --git a/CMakeLists.txt b/CMakeLists.txt
index be98723f2..a74159242 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,7 @@ else ()
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/examples/order_plugin_example.so ${CMAKE_BINARY_DIR}/server/plugins/
+ COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/examples/excel_plugin_example.so ${CMAKE_BINARY_DIR}/server/plugins/
COMMENT "Creating server runtime layout"
DEPENDS sparkd data_files_dir)
diff --git a/src/client/spark_excel/algogen/Generate.cs b/src/client/spark_excel/algogen/Generate.cs
index f8fd81f55..8ff80a33a 100644
--- a/src/client/spark_excel/algogen/Generate.cs
+++ b/src/client/spark_excel/algogen/Generate.cs
@@ -56,7 +56,7 @@ namespace bts.excel
using (StreamReader reader = new StreamReader(stream))
{
string cpp = reader.ReadToEnd();
- cpp = cpp.Replace("#define __AlgoName__", "//#define __#AlgoName__");
+ //cpp = cpp.Replace("#define __AlgoName__", "//#define __#AlgoName__");
cpp = cpp.Replace("#define __FunctionDefs__", "//#define __#FunctionDefs__");
cpp = cpp.Replace("#define __FunctionCalls__", "//#define __#FunctionCalls__");
cpp = cpp.Replace("#define __FunctionImpls__", "//#define __#FunctionImpls__");
@@ -68,6 +68,7 @@ namespace bts.excel
cpp = cpp.Replace("#define __ParameterLaunches__", "//#define __#ParameterLaunches__");
cpp = cpp.Replace("#define __ParameterUpdates__", "//#define __#ParameterUpdates__");
cpp = cpp.Replace("#define __ParameterSetups__", "//#define __#ParameterSetups__");
+ cpp = cpp.Replace("__Remove__", string.Empty);
cpp = cpp.Replace("__AlgoName__", algoname);
diff --git a/src/client/spark_excel/algogen/functions/bts/SparkAlgoFunctions.cs b/src/client/spark_excel/algogen/functions/bts/SparkAlgoFunctions.cs
index 4ab66a07a..dfd229440 100644
--- a/src/client/spark_excel/algogen/functions/bts/SparkAlgoFunctions.cs
+++ b/src/client/spark_excel/algogen/functions/bts/SparkAlgoFunctions.cs
@@ -109,14 +109,6 @@ namespace bts.excel
[ExcelFunction(Category = "BTS", Description = "Resolve a security id from contract details")]
[SparkAlgoCode(
- dual_definition = "SecurityKey spark_resolve_security_id();",
- dual_impl = @"
- SecurityKey __AlgoName__::sparkalgo_resolve_security_id()
- {
- auto sk = SecurityKey(algo_services().security().id())
- return sk;
- }
- ",
replacement_call = "sparkalgo_resolve_security_id()"
)]
public async static void sparkalgo_resolve_security_id(
diff --git a/src/client/spark_excel/spark_excel.csproj b/src/client/spark_excel/spark_excel.csproj
index 735bf960d..243208136 100644
--- a/src/client/spark_excel/spark_excel.csproj
+++ b/src/client/spark_excel/spark_excel.csproj
@@ -90,11 +90,10 @@
PreserveNewest
- PreserveNewest
-
+
diff --git a/src/sdk/CMakeLists.txt b/src/sdk/CMakeLists.txt
index e4a38178e..f8afc37eb 100644
--- a/src/sdk/CMakeLists.txt
+++ b/src/sdk/CMakeLists.txt
@@ -12,6 +12,8 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/sdk
${CMAKE_CURRENT_SOURCE_DIR}/examples/build_examples.sh
${CMAKE_CURRENT_SOURCE_DIR}/examples/md_publisher_example.cpp
${CMAKE_CURRENT_SOURCE_DIR}/examples/order_plugin_example.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/examples/excel_plugin_example.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/examples/ExcelAlgoTemplate.cpp
server_layout)
add_custom_target(sdk_dir ALL DEPENDS ${CMAKE_BINARY_DIR}/sdk)
diff --git a/src/client/spark_excel/ExcelAlgoTemplate.cpp b/src/sdk/examples/ExcelAlgoTemplate.cpp
similarity index 87%
rename from src/client/spark_excel/ExcelAlgoTemplate.cpp
rename to src/sdk/examples/ExcelAlgoTemplate.cpp
index 43cd8d901..eb3e775a9 100644
--- a/src/client/spark_excel/ExcelAlgoTemplate.cpp
+++ b/src/sdk/examples/ExcelAlgoTemplate.cpp
@@ -13,7 +13,10 @@
using namespace bts::api::orderman;
using namespace bts::orderman;
-#define __AlgoName__ "_";
+// This file serves as a template for the excel algogen process the following defines are replaced by the algogen
+// I thought it useful to put this file in the build to make sure the template compiles in it's own right
+
+//#define __AlgoName__ __
#define __FunctionDefs__
#define __FunctionImpls__
#define __FunctionCalls__
@@ -42,9 +45,9 @@ struct ExcelBookAccessor
ExcelBookAccessor(Book& book) : book(book) { }
const double& operator()(int row, int col) const
{
- return this->operator(row, col);
+ return this->operator()(row, col);
}
- double& operator()(int row, int col)
+ double operator()(int row, int col)
{
if(col == 0)
{
@@ -79,6 +82,8 @@ struct ExcelBookAccessor
return os::nan();
}
};
+
+template struct Range;
template
struct range_iterator : public std::iterator
@@ -107,7 +112,7 @@ public:
bool operator!=(const range_iterator& rhs) const {return p.row != rhs.row || p.col != rhs.col;}
T& operator*() {return p(row, col);}
const T& operator*() const {return p(row, col);}
-}
+};
template
struct Range
@@ -147,11 +152,11 @@ struct Range
return 0;
}
- range_iterator begin()
+ range_iterator begin()
{
return range_iterator(*this, 0, 0);
}
- range_iterator end()
+ range_iterator end()
{
return range_iterator(*this, nrows, ncols);
}
@@ -181,15 +186,24 @@ class __AlgoName__ : public IAlgoOrder
void do_functions();
+
+ SecurityKey sparkalgo_resolve_security_id(const std::string& contract = "", const std::string& symbol = "",
+ const std::string& security_type = "", const std::string& exchange = "");
template
- Range sparkalgo_take_snapshot(const Range&, const std::string& name);
+ Range sparkalgo_take_snapshot(const Range&, const std::string& name);
__DualDefs__;
};
+SecurityKey __AlgoName__::sparkalgo_resolve_security_id(const std::string& contract, const std::string& symbol,
+ const std::string& security_type, const std::string& exchange)
+{
+ auto sk = SecurityKey(algo_services().security().id());
+ return sk;
+}
template
-Range __AlgoName__::sparkalgo_take_snapshot(const Range& rng, const std::string& name)
+Range __AlgoName__::sparkalgo_take_snapshot(const Range& rng, const std::string& name)
{
static std::map > cache;
auto it = cache.find(name);
@@ -281,7 +295,7 @@ void __AlgoName__::do_launch(IAlgoServices& services)
// Subscribe to market data
if(__NeedsBook__)
- services.subscribe_book( spark_resolve_security_id() );
+ services.subscribe_book( sparkalgo_resolve_security_id() );
}
// Called in the latency sensitive path, once, when the algo is first
@@ -304,7 +318,7 @@ void __AlgoName__::do_launch_attached(IAlgoServices& services, OrderKey attached
// Subscribe to market data
if(__NeedsBook__)
- services.subscribe_book( spark_resolve_security_id() );
+ services.subscribe_book( sparkalgo_resolve_security_id() );
// Simulate a child change so we can update our own state to
// reflect that of the child order we attached to. From this point
@@ -411,7 +425,7 @@ void __AlgoName__::on_child_change(OrderKey, const ChildState& st)
// This is called by the spark daemon at startup. In this call we
// describe our algo's parameters and register a factory function to
// create an instance of the algo.
-extern "C" void init_spark_plugin(bts::SparkServices& serv)
+extern "C" void __Remove__init_spark_plugin(bts::SparkServices& serv)
{
using namespace bts;
diff --git a/src/sdk/examples/build_examples.sh b/src/sdk/examples/build_examples.sh
index 3625e12d8..c2fcaa0c7 100755
--- a/src/sdk/examples/build_examples.sh
+++ b/src/sdk/examples/build_examples.sh
@@ -24,3 +24,17 @@ g++ -isystem ../externals/include \
-Wl,-rpath,.. \
-L ../lib \
-l spark
+
+g++ -isystem ../externals/include \
+ -I ../include \
+ -I ../include/spark \
+ -std=c++1z \
+ -fPIC \
+ -g \
+ -shared \
+ -o excel_plugin_example.so \
+ ExcelAlgoTemplate.cpp \
+ excel_plugin_example.cpp \
+ -Wl,-rpath,.. \
+ -L ../lib \
+ -l spark
diff --git a/src/sdk/examples/excel_plugin_example.cpp b/src/sdk/examples/excel_plugin_example.cpp
new file mode 100644
index 000000000..7a8c59705
--- /dev/null
+++ b/src/sdk/examples/excel_plugin_example.cpp
@@ -0,0 +1,6 @@
+#include "spark/lib/plugin/SparkServices.h"
+
+extern "C" void init_spark_plugin(bts::SparkServices& serv)
+{
+ //this file will be overriten by the excel algogen process, this function is here to dummy up
+}
\ No newline at end of file