Added to SDK MD sample.

This commit is contained in:
Pedro Pinto committed 2018-07-06 19:42:40 +00:00
1 parent 93d0a21c9d
commit 0dd988fd1e
2 files changed
+76 -4

No files matched your search

+74 -3
View File
@@ -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<api::Security> (
"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<md::MDProducerHandle> 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<md::PriceSize, md::COCONUT_MAX_DEPTH> 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<md::PriceSize, md::COCONUT_MAX_DEPTH> 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;
}