diff --git a/src/sdk/example/example.cpp b/src/sdk/example/example.cpp index 631354da4..4b502b839 100644 --- a/src/sdk/example/example.cpp +++ b/src/sdk/example/example.cpp @@ -1,15 +1,86 @@ #include "spark/lib/logging/logging.h" #include "spark/lib/utils/init_spark_lib.h" #include "spark/lib/utils/bts_chrono.h" +#include "spark/lib/md/MDProducer.h" +#include "spark/lib/utils/PBUtils.h" +using namespace bts; + +void produce() +{ + md::MDProducer producer(co2::PLATFORM_SIM); + + auto s = utils::pb::from_string ( + "id: 16\n" + "symbol: \"ZF\"\n" + "exchange: VENUE_GLBX\n" + "contract_spec {\n" + "low_tick: 0.0078125\n" + "high_tick: 0.0078125\n" + "cash_per_point: 0.012799999999999999\n" + "price_multiplier: 1\n" + "}\n" + "future {\n" + "expiration_year: 2018\n" + "expiration_month: 9\n" + "expiration_day: 28\n" + "}\n" + "glbx {\n" + "exchange_id: 164760\n" + "security_desc: \"ZFU8\"\n" + "cfi_code: \"FFDXSX\"\n" + "cme_symbol: \"ZF\"\n" + "main_fraction: 32\n" + "sub_fraction: 4\n" + "price_display_format: 3\n" + "market_segment_id: 84\n" + "}\n" + ); + + // create security and obtain handle so we can update it later + std::vector producer_handles; + md::with_security_like(s, [&s,&producer,&producer_handles](auto &fs) { + md::convert_security(s, fs, true); + producer_handles.push_back(producer.add_security(fs)); + }); + + // initialized bid side book data + std::array bids = { + md::PriceSize::from_double<7> (1.0,10), + md::PriceSize::from_double<7> (2.0,20), + md::PriceSize::from_double<7> (3.0,30), + md::PriceSize::from_double<7> (4.0,40), + md::PriceSize::from_double<7> (5.0,50), + md::PriceSize::from_double<7> (6.0,60), + md::PriceSize::from_double<7> (7.0,70), + md::PriceSize::from_double<7> (8.0,80), + md::PriceSize::from_double<7> (9.0,90), + md::PriceSize::from_double<7> (10.0,100) + }; + + // initialized ask side book data + std::array asks = { + md::PriceSize::from_double<7> (1.0,10), + md::PriceSize::from_double<7> (2.0,20), + md::PriceSize::from_double<7> (3.0,30), + md::PriceSize::from_double<7> (4.0,40), + md::PriceSize::from_double<7> (5.0,50), + md::PriceSize::from_double<7> (6.0,60), + md::PriceSize::from_double<7> (7.0,70), + md::PriceSize::from_double<7> (8.0,80), + md::PriceSize::from_double<7> (9.0,90), + md::PriceSize::from_double<7> (10.0,100) + }; + + // update book + producer_handles[0].update_book(utils::TimeStamp::now(), bids, asks); +} int main() { - using namespace bts; - utils::init_spark_lib(); LOG(md, Info, "Hello world"); - sleep_for(1s); + produce(); utils::finit_spark_lib(); return 0; } diff --git a/src/sdk/make_sdk.sh b/src/sdk/make_sdk.sh index be1e273ba..b00bd8b0e 100755 --- a/src/sdk/make_sdk.sh +++ b/src/sdk/make_sdk.sh @@ -15,7 +15,8 @@ mkdir -p $1/sdk/include/externals/linux/ (cd $2/.. && find lib -type f -name "*.h" -exec cp --parents \{\} $1/sdk/include/spark/ \;) # generated headers -(cd $1/src && find lib -type f -name "*.h" -or -name "*.cc" -exec cp --parents \{\} $1/sdk/include/spark/ \;) +(cd $1/src && find lib -type f -name "*.h" -exec cp --parents \{\} $1/sdk/include/spark/ \;) +(cd $1/src && find lib -type f -name "*.cc" -exec cp --parents \{\} $1/sdk/include/spark/ \;) ln -sf $2/../../externals/linux/include $1/sdk/include/externals/linux ln -sf $1/server $1/sdk/lib