diff --git a/src/lib/config/protos/jetfix.proto b/src/lib/config/protos/jetfix.proto index e54d40247..26377929a 100644 --- a/src/lib/config/protos/jetfix.proto +++ b/src/lib/config/protos/jetfix.proto @@ -79,6 +79,7 @@ message JetFIX { optional int32 udf_support_indicator = 340 [default=1]; optional bool use_cme_secure_logon = 341 [default=true]; optional bool auto_cert_mode = 342 [default=false]; + optional int32 price_encoding_precision = 343 [default=7]; } repeated Connection connection = 10; diff --git a/src/lib/domain_model/SecurityTests.cpp b/src/lib/domain_model/SecurityTests.cpp index 7613e799e..e95f1b5d2 100644 --- a/src/lib/domain_model/SecurityTests.cpp +++ b/src/lib/domain_model/SecurityTests.cpp @@ -15,8 +15,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("BS") @@ -26,8 +26,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("BF") @@ -37,8 +37,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("CF") @@ -48,8 +48,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("DF") @@ -59,8 +59,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("MP") @@ -70,8 +70,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("PB") @@ -81,8 +81,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } SECTION("PS") { @@ -91,8 +91,8 @@ TEST_CASE ("Security name formatting tests" , "[securities]") std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); - for (auto const &m : matches) - std::cout << "match: " << m.str() << "\n"; + // for (auto const &m : matches) + // std::cout << "match: " << m.str() << "\n"; } } diff --git a/src/server/sparkd/cmds/QuickTest.cpp b/src/server/sparkd/cmds/QuickTest.cpp index 42be10181..2494a26fb 100644 --- a/src/server/sparkd/cmds/QuickTest.cpp +++ b/src/server/sparkd/cmds/QuickTest.cpp @@ -14,21 +14,16 @@ namespace cmd { int QuickTest::execute(std::vector const &args) { using namespace double_conversion; - static char buffer[102]; + static char buffer1[102]; static char buffer2[102]; static char buffer3[102]; - int flags = DoubleToStringConverter::UNIQUE_ZERO; - static DoubleToStringConverter converter(flags, "Infinity", "NaN", 'e', -6, - 21, 0, 0); auto n = std::stod(args[0], nullptr); auto p = std::stoi(args[1], nullptr); - { - double_conversion::StringBuilder builder(buffer, sizeof(buffer)); - converter.ToPrecision(n, p, &builder); - } - d_toa(n, buffer2, sizeof(buffer2), p); + d_toa(n, buffer1, sizeof(buffer1), 7,p); + d_toa(n, buffer2, sizeof(buffer2),7); d_toa(n, buffer3, sizeof(buffer3)); - std::cout << n << " -> " << buffer << " (" << strlen(buffer) << ") " + std::cout << n + << " -> " << buffer1 << " (" << strlen(buffer1) << ") " << " -> " << buffer2 << " (" << strlen(buffer2) << ") " << " -> " << buffer3 << " (" << strlen(buffer3) << ") \n"; return 0; diff --git a/src/server/sparkd/jetfix/codec/FieldDefinitions.h b/src/server/sparkd/jetfix/codec/FieldDefinitions.h index f79f1be6b..a61635081 100644 --- a/src/server/sparkd/jetfix/codec/FieldDefinitions.h +++ b/src/server/sparkd/jetfix/codec/FieldDefinitions.h @@ -8,107 +8,100 @@ namespace bts { namespace jetfix { namespace fix { -typedef StringField<8> BeginString; -typedef IntField<9> BodyLength; -typedef StringField<35> MsgType; -typedef IntField<34> MsgSeqNum; -typedef IntField<369> LastSeqNumProcessed; -typedef StringField<49> SenderCompID; -typedef StringField<50> SenderSubID ; -typedef TimeField<52> SendingTime; -typedef TimeField<122> OrigSendingTime; -typedef StringField<56> TargetCompId; -typedef StringField<57> TargetSubID; -typedef StringField<142> SenderLocationID; -typedef StringField<37> OrderID; -typedef StringField<117> QuoteID; -typedef IntField<117> QuoteIDInt; -typedef IntField<204> CustomerOrFirm; -typedef IntField<296> NoQuoteSets; -typedef StringField<302> QuoteSetID; -typedef StringField<307> UnderlyingSecurityDesc; -typedef IntField<304> TotQuoteEntries; -typedef IntField<295> NoQuoteEntries; -typedef StringField<304> TotQuoteEntriesStr; -typedef StringField<295> NoQuoteEntriesStr; - typedef BoolField<1028> ManualOrderIndicator; -typedef StringField<7928> SelfMatchPreventionID; -typedef CharField<9702> CtiCode; -typedef StringField<9771> MMAccount; +typedef BoolField<123> GapFillFlag; +typedef BoolField<43> PossDupFlag; +typedef BoolField<9768> InFlightMitigation; +typedef CharField<150> ExecType; typedef CharField<21> HandlInst; -typedef CharField<40> OrdType; -typedef CharField<59> TimeInForce; -typedef CharField<39> OrdStatus; -typedef StringField<41> OrigClOrdID; -typedef StringField<9717> CorrelationClOrdID; -typedef IntField<102> CXlRejReason; - - -typedef FloatField<132> BidPx; -typedef IntField<134> BidSize; -typedef StringField<132> BidPxStr; -typedef StringField<134> BidSizeStr; - -typedef FloatField<133> OfferPx; -typedef IntField<135> OfferSize; -typedef StringField<133> OfferPxStr; -typedef StringField<135> OfferSizeStr; - -typedef StringField<299> QuoteEntryID; -typedef IntField<299> QuoteEntryIDInt; -typedef StringField<55> Symbol; -typedef StringField<167> SecurityType; -typedef StringField<107> SecurityDesc; -typedef StringField<48> SecurityID; typedef CharField<22> SecurityIDSource; -typedef TimeField<60> TransactTime; -typedef TimeField<5979> RequestTime; -typedef StringField<60> TransactTimeStr; -typedef StringField<143> TargetLocationID; -typedef StringField<142> SenderLocationID; -typedef StringField<142> SenderLocationID; -typedef IntField<10> Checksum; -typedef IntField<98> EncryptMethod; +typedef CharField<39> OrdStatus; +typedef CharField<40> OrdType; +typedef CharField<47> Rule80a; +typedef CharField<54> Side; +typedef CharField<59> TimeInForce; +typedef CharField<9702> CtiCode; +typedef CharField<9775> UnsolicitedCancelType; +typedef FloatField<132> BidPx; +typedef FloatField<133> OfferPx; +typedef FloatField<151> LeavesQty; +typedef FloatField<31> LastPx; +typedef FloatField<6> AvgPx; +typedef IntField<102> CXlRejReason; typedef IntField<108> HeartBtInt; +typedef IntField<10> Checksum; +typedef IntField<117> QuoteIDInt; +typedef IntField<134> BidSize; +typedef IntField<135> OfferSize; +typedef IntField<14> CumQty; +typedef IntField<16> EndSeqNo; +typedef IntField<204> CustomerOrFirm; +typedef IntField<295> NoQuoteEntries; +typedef IntField<296> NoQuoteSets; +typedef IntField<297> QuoteAckStatus; +typedef IntField<298> QuoteCancelType; +typedef IntField<299> QuoteEntryIDInt; +typedef IntField<300> QuoteRejectReason; +typedef IntField<304> TotQuoteEntries; +typedef IntField<32> LastShares; +typedef IntField<34> MsgSeqNum; +typedef IntField<368> QuoteEntryRejectReason; +typedef IntField<369> LastSeqNumProcessed; +typedef IntField<36> NewSeqNo; +typedef IntField<386> NoTradingSessions; +typedef IntField<442> MultiLegReportingType; +typedef IntField<7> BeginSeqNo; +typedef IntField<95> RawDataLength; +typedef IntField<98> EncryptMethod; +typedef IntField<9> BodyLength; +typedef StringField<107> SecurityDesc; +typedef StringField<109> ClientID; +typedef StringField<112> TestReqId; +typedef StringField<117> QuoteID; +typedef StringField<11> ClOrdID; +typedef StringField<132> BidPxStr; +typedef StringField<133> OfferPxStr; +typedef StringField<134> BidSizeStr; +typedef StringField<135> OfferSizeStr; +typedef StringField<142> SenderLocationID; +typedef StringField<143> TargetLocationID; typedef StringField<1603> ApplicationSystemName; typedef StringField<1604> ApplicationSystemVersion; typedef StringField<1605> ApplicationSystemVendor; -typedef IntField<95> RawDataLength; -typedef StringField<96> RawData; -typedef StringField<109> ClientID; -typedef IntField<7> BeginSeqNo; -typedef IntField<16> EndSeqNo; -typedef StringField<112> TestReqId; -typedef BoolField<123> GapFillFlag; -typedef IntField<36> NewSeqNo; -typedef BoolField<43> PossDupFlag; -typedef IntField<297> QuoteAckStatus; -typedef CharField<9775> UnsolicitedCancelType; -typedef IntField<300> QuoteRejectReason; -typedef StringField<58> Text; -typedef IntField<368> QuoteEntryRejectReason; -typedef IntField<298> QuoteCancelType; -typedef StringField<1> Account; -typedef CharField<150> ExecType; -typedef StringField<11> ClOrdID; -typedef CharField<54> Side; -typedef FloatField<31> LastPx; -typedef FloatField<6> AvgPx; -typedef IntField<32> LastShares; -typedef IntField<14> CumQty; -typedef StringField<527> SecondaryExecID; -typedef StringField<76> ExecBroker; +typedef StringField<167> SecurityType; typedef StringField<17> ExecID; typedef StringField<19> ExecRefID; -typedef FloatField<151> LeavesQty; -typedef IntField<442> MultiLegReportingType; -typedef IntField<386> NoTradingSessions; +typedef StringField<1> Account; +typedef StringField<295> NoQuoteEntriesStr; +typedef StringField<299> QuoteEntryID; +typedef StringField<302> QuoteSetID; +typedef StringField<304> TotQuoteEntriesStr; +typedef StringField<307> UnderlyingSecurityDesc; typedef StringField<336> TradingSessionID; +typedef StringField<35> MsgType; +typedef StringField<37> OrderID; +typedef StringField<41> OrigClOrdID; typedef StringField<440> ClearingAccount; -typedef CharField<47> Rule80a; +typedef StringField<48> SecurityID; +typedef StringField<49> SenderCompID; +typedef StringField<50> SenderSubID ; +typedef StringField<527> SecondaryExecID; +typedef StringField<55> Symbol; +typedef StringField<56> TargetCompId; +typedef StringField<57> TargetSubID; +typedef StringField<58> Text; +typedef StringField<60> TransactTimeStr; +typedef StringField<76> ExecBroker; +typedef StringField<7928> SelfMatchPreventionID; +typedef StringField<8> BeginString; typedef StringField<9324> OrderOptionalData; -typedef BoolField<9768> InFlightMitigation; +typedef StringField<96> RawData; +typedef StringField<9717> CorrelationClOrdID; +typedef StringField<9771> MMAccount; +typedef TimeField<122> OrigSendingTime; +typedef TimeField<52> SendingTime; +typedef TimeField<5979> RequestTime; +typedef TimeField<60> TransactTime; typedef Group write (char*buffer,double d,int pad = 0) + static std::pair write (char*buffer,double d,int decimals, int pad ) { - auto written = d_toa (d,buffer,max_value_size (d,pad)+1,pad); + auto written = d_toa (d,buffer,max_value_size (d,decimals, pad)+1,decimals,pad); return std::make_pair (written,sum_bytes (buffer,written)); } }; @@ -207,3 +207,4 @@ public: }; }} + diff --git a/src/server/sparkd/jetfix/codec/f_toa.h b/src/server/sparkd/jetfix/codec/f_toa.h index 9d1068b8d..ed6d8bb65 100644 --- a/src/server/sparkd/jetfix/codec/f_toa.h +++ b/src/server/sparkd/jetfix/codec/f_toa.h @@ -2,32 +2,70 @@ #include "lib/utils/bts_assert.h" -#include #include +#include namespace bts { -inline int d_toa (double n,char*buffer, size_t buffer_size,int pad=0) -{ +inline int d_toa(double n, char *buffer, size_t buffer_size, int decimal_digits=-1, int pad = -1) { static double_conversion::DoubleToStringConverter const &c = - double_conversion::DoubleToStringConverter::EcmaScriptConverter (); + double_conversion::DoubleToStringConverter::EcmaScriptConverter(); - double_conversion::StringBuilder builder(buffer,buffer_size); - if (pad == 0) { - bts_assert (c.ToShortest (n,&builder)); - return builder.position (); - } else { - bts_assert ((int) buffer_size >= pad); + bts_assert(buffer_size); + + if (pad == -1) { + // no padding, return the smallest number that contains all the + // specified digits + double_conversion::StringBuilder builder(buffer, buffer_size); - if (n < 0) - bts_assert (c.ToPrecision (n,pad-2,&builder)); - else - bts_assert (c.ToPrecision (n,pad-1,&builder)); + if (decimal_digits == -1 ) { + if (c.ToShortest(n,&builder)) + return builder.position(); + } + else { + if(c.ToFixed(n,decimal_digits,&builder)) + return builder.position(); + } + buffer[0] = 0; + return 0; + } + else { + + // padding, return something with a fixed size + + std::array pre_buffer; + bts_assert((int)buffer_size > pad); + bts_assert((int)pre_buffer.size() >= pad); + + double_conversion::StringBuilder builder(&pre_buffer[0], pre_buffer.size()); + + auto ok = false; + if (decimal_digits == -1) + ok = c.ToShortest(n,&builder); + else + ok = c.ToFixed(n,decimal_digits,&builder); + + if(ok) { + auto sz = builder.position(); + if (sz < pad) { + auto n_left_zeros = pad - sz; + memset(&buffer[0], '0',n_left_zeros); + memcpy(&buffer[n_left_zeros], &pre_buffer[0],sz); + if (n < 0) { + buffer[0] = '-'; + buffer[n_left_zeros] = '0'; + } + buffer[pad]=0; + return pad; + } + } + + for (int i = 0; i < pad;i++) + buffer[i] = ' '; + buffer[pad] = 0; return pad; } } - -inline int f_toa (float n,char*buffer, size_t buffer_size,int pad=0) -{return d_toa(n,buffer,buffer_size,pad);} - } + + diff --git a/src/server/sparkd/jetfix/tests/fix_fragment_tests.cpp b/src/server/sparkd/jetfix/tests/fix_fragment_tests.cpp index 5ee3715e2..85e4069b0 100644 --- a/src/server/sparkd/jetfix/tests/fix_fragment_tests.cpp +++ b/src/server/sparkd/jetfix/tests/fix_fragment_tests.cpp @@ -53,12 +53,12 @@ TEST_CASE ("JetFIX Field2Tests", "[jetfix]") std::string out (20, ' '); typedef FloatField<123> Field; - REQUIRE (Field::max_value_size (1.2,6)==6); + REQUIRE (Field::max_value_size (1.2,-1,6)==6); - auto result = Field::write (&out[0],1.2,6); + auto result = Field::write (&out[0],1.2,-1,6); REQUIRE (result.first==6); REQUIRE (result.second=='0'+'0'+'0'+'1'+'.'+'2'); - REQUIRE (out.compare (0,6,"1.2000") == 0); + REQUIRE (out.compare (0,6,"0001.2") == 0); REQUIRE (out[6]=='\0'); } @@ -111,7 +111,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") { FIXFragment g (0); g.add> ('a'); - g.add> (1.2,6); + g.add> (1.2,-1,6); g.add> ("hello"); g.add> (123,3); const char*t_s = "20150427-19:05:18.922"; @@ -121,7 +121,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") std::string out = g.to_str (); REQUIRE (out == "1=a" "\001" - "2=1.2000" "\001" + "2=0001.2" "\001" "3=hello" "\001" "4=123" "\001" "5=20150427-19:05:18.922" "\001" @@ -140,14 +140,14 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") FIXFragment g; auto c_bm = g.add> ('a'); - auto f_bm = g.add> (1.2,6); + auto f_bm = g.add> (1.2,-1,6); auto s_bm = g.add> ("hello"); auto i_bm = g.add> (123,3); auto t_bm = g.add> (datetime::parse_FIX_timestamp (t_s1)); auto b_bm = g.add> (true); g.overwrite (c_bm,'b'); - g.overwrite (f_bm,1.3,6); + g.overwrite (f_bm,1.3,-1,6); g.overwrite (s_bm,"olleh"); g.overwrite (i_bm,321,3); g.overwrite (t_bm,(datetime::parse_FIX_timestamp (t_s2))); @@ -155,7 +155,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") std::string out = g.to_str (); REQUIRE (out== "1=b" "\001" - "2=1.3000" "\001" + "2=0001.3" "\001" "3=olleh" "\001" "4=321" "\001" "5=20150427-19:05:18.923" "\001" @@ -171,7 +171,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") { FIXFragment g1;; g1.add> ('a'); - g1.add> (1.2,6); + g1.add> (1.2,-1,6); g1.add> ("hello"); auto chk1 = g1.checksum (); @@ -184,7 +184,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") std::string out = g1.to_str (); REQUIRE (out== "1=a" "\001" - "2=1.2000" "\001" + "2=0001.2" "\001" "3=hello" "\001" "4=goodbye" "\001" "5=321" "\001"); @@ -197,3 +197,4 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") }} + diff --git a/src/server/sparkd/jetfix/tests/jetfix_performance_tests.cpp b/src/server/sparkd/jetfix/tests/jetfix_performance_tests.cpp index 7b6d761bd..98c5de6a6 100644 --- a/src/server/sparkd/jetfix/tests/jetfix_performance_tests.cpp +++ b/src/server/sparkd/jetfix/tests/jetfix_performance_tests.cpp @@ -164,18 +164,18 @@ TEST_CASE ("JetFIX Performance Tests", "[jetfix] [benchmark]") g.add("55",sizeof("55")-1); g.add("ESK5 C1855",sizeof("ESK5 C1855")-1); g.add("OPT",sizeof("OPT")-1); - g.add(25200.0); + g.add(25200.0,-1,-1); g.add(1); - g.add(25200.0); + g.add(25200.0,-1,-1); g.add(1); g.add("10857",sizeof("10857")-1); g.add("55",sizeof("55")-1); g.add("ESK5 C1855",sizeof("ESK5 C1855")-1); g.add("OPT",sizeof("OPT")-1); - g.add(25200.0); + g.add(25200.0,-1,-1); g.add(1); - g.add(25200.0); + g.add(25200.0,-1,-1); g.add(1); g.add(2,3); @@ -207,9 +207,9 @@ TEST_CASE ("JetFIX Performance Tests", "[jetfix] [benchmark]") qt1.add("ESK5 C1855",sizeof("ESK5 C1855")-1); qt1.add("OPT",sizeof("OPT")-1); - auto qt1_bid_px = qt1.add(25200.0); + auto qt1_bid_px = qt1.add(25200.0,-1,-1); auto qt1_bid_sz = qt1.add(1); - auto qt1_offer_px = qt1.add(25200.0); + auto qt1_offer_px = qt1.add(25200.0,-1,-1); auto qt1_offer_sz = qt1.add(1); FIXFragment qt2; @@ -218,9 +218,9 @@ TEST_CASE ("JetFIX Performance Tests", "[jetfix] [benchmark]") qt2.add("ESK5 C1855",sizeof("ESK5 C1855")-1); qt2.add("OPT",sizeof("OPT")-1); - auto qt2_bid_px = qt2.add(25200.0); + auto qt2_bid_px = qt2.add(25200.0,-1,-1); auto qt2_bid_sz = qt2.add(1); - auto qt2_offer_px = qt2.add(25200.0); + auto qt2_offer_px = qt2.add(25200.0,-1,-1); auto qt2_offer_sz = qt2.add(1); FIXFragment g; @@ -233,16 +233,16 @@ TEST_CASE ("JetFIX Performance Tests", "[jetfix] [benchmark]") g.add (2); qt1.overwrite (qt1_quote_entry_id,"10857",sizeof("10857")-1); - qt1.overwrite (qt1_bid_px,25200.0); + qt1.overwrite (qt1_bid_px,25200.0,-1,-1); qt1.overwrite (qt1_bid_sz,1); - qt1.overwrite (qt1_offer_px,25200.0); + qt1.overwrite (qt1_offer_px,25200.0,-1,-1); qt1.overwrite (qt1_offer_sz,1); g.append (qt1); qt2.overwrite (qt2_quote_entry_id,"10857",sizeof("10857")-1); - qt2.overwrite (qt2_bid_px,25200.0); + qt2.overwrite (qt2_bid_px,25200.0,-1,-1); qt2.overwrite (qt2_bid_sz,1); - qt2.overwrite (qt2_offer_px,25200.0); + qt2.overwrite (qt2_offer_px,25200.0,-1,-1); qt2.overwrite (qt2_offer_sz,1); g.append (qt2); diff --git a/src/server/sparkd/orderman/actors/order_manager/OrderServices.h b/src/server/sparkd/orderman/actors/order_manager/OrderServices.h index 40323540b..579c46092 100644 --- a/src/server/sparkd/orderman/actors/order_manager/OrderServices.h +++ b/src/server/sparkd/orderman/actors/order_manager/OrderServices.h @@ -24,7 +24,8 @@ public: {} std::string const &session_name() const { return _session_data->session; } - + config::JetFIX::Connection const &session_cfg() const { return _session_data->cfg; } + jetfix::OutFIXPtr get_fix_buffer() { jetfix::OutFIXPtr result; if (_session_data->free_buffers.size()) { diff --git a/src/server/sparkd/orderman/orders/NativeOrder.cpp b/src/server/sparkd/orderman/orders/NativeOrder.cpp index 7251320b3..9489b58f7 100644 --- a/src/server/sparkd/orderman/orders/NativeOrder.cpp +++ b/src/server/sparkd/orderman/orders/NativeOrder.cpp @@ -27,7 +27,8 @@ OrderStatus map_external_status(NativeOrderStatus); struct NativeOrder::PImpl { PImpl() : services(nullptr), session_services(), sec(nullptr), - previous_position_contribution(0) {} + previous_position_contribution(0), definition(), state(), + price_encoding_precision(7) {} OrderServices *services; SessionServices *session_services; @@ -37,6 +38,7 @@ struct NativeOrder::PImpl { OrderDefinition definition; OrderState state; + int price_encoding_precision; jetfix::FIXFragment update_encoding; jetfix::FIXFragment::Bookmark update_price_bm; @@ -266,7 +268,7 @@ NativeOrder::~NativeOrder() {} void NativeOrder::on_activate(Price p, Quantity q, bts::orderman::OrderServices &services, TickToTradeCorID cid) { - tracepoint (bts_trace,trace_order,(char*) "on_activate", 0,cid); + tracepoint(bts_trace, trace_order, (char *)"on_activate", 0, cid); bts_assert(!me->services); me->services = &services; @@ -277,6 +279,8 @@ void NativeOrder::on_activate(Price p, Quantity q, me->session_services = &me->services->get_session_services( get_native_state(me->state).routing_record().session()); + me->price_encoding_precision = + me->session_services->session_cfg().price_encoding_precision(); // is our gateway connected? if (!me->session_services->is_gateway_connected()) { @@ -337,7 +341,7 @@ void NativeOrder::on_activate(Price p, Quantity q, case CustomOrderDefinition::kStopLimit: me->create_price_bm = encoding.overwrite( me->create_price_bm, - securities::encode_exchange_price(*me->sec, p).value(), + securities::encode_exchange_price(*me->sec, p).value(), 7, price_sz()); break; case CustomOrderDefinition::kStop: @@ -426,7 +430,7 @@ void NativeOrder::on_activate(Price p, Quantity q, } void NativeOrder::on_update(Price p, Quantity q, TickToTradeCorID cid) { - tracepoint (bts_trace,trace_order,(char*) "on_update", 0,cid); + tracepoint(bts_trace, trace_order, (char *)"on_update", 0, cid); switch (me->state.status()) { case ORDER_STATUS_WORKING: { @@ -463,7 +467,7 @@ void NativeOrder::on_update(Price p, Quantity q, TickToTradeCorID cid) { auto &encoding = me->update_encoding; me->update_price_bm = encoding.overwrite( me->update_price_bm, - securities::encode_exchange_price(*me->sec, p).value(), + securities::encode_exchange_price(*me->sec, p).value(), 7, price_sz()); me->update_quantity_bm = encoding.overwrite(me->update_quantity_bm, q.value(), quantity_sz()); @@ -790,8 +794,8 @@ void NativeOrder::init_fix() { cancel_encoding.add(NATIVE_ORDER_TYPE_LIMIT); // price - me->create_price_bm = create_encoding.add(0, price_sz()); - me->update_price_bm = update_encoding.add(0, price_sz()); + me->create_price_bm = create_encoding.add(0, 7, price_sz()); + me->update_price_bm = update_encoding.add(0, 7, price_sz()); break; case CustomOrderDefinition::kStop: { @@ -804,8 +808,8 @@ void NativeOrder::init_fix() { auto stop_px = def.custom_def().stop().stop_price(); auto encoded_stop_px = securities::encode_exchange_price(*me->sec, Price(stop_px)).value(); - create_encoding.add(encoded_stop_px); - update_encoding.add(encoded_stop_px); + create_encoding.add(encoded_stop_px, -1, -1); + update_encoding.add(encoded_stop_px, -1, -1); break; } @@ -819,12 +823,12 @@ void NativeOrder::init_fix() { auto stop_px = def.custom_def().stop_limit().stop_price(); auto encoded_stop_px = securities::encode_exchange_price(*me->sec, Price(stop_px)).value(); - create_encoding.add(encoded_stop_px); - update_encoding.add(encoded_stop_px); + create_encoding.add(encoded_stop_px, -1, -1); + update_encoding.add(encoded_stop_px, -1, -1); // price - me->create_price_bm = create_encoding.add(0, price_sz()); - me->update_price_bm = update_encoding.add(0, price_sz()); + me->create_price_bm = create_encoding.add(0, 7, price_sz()); + me->update_price_bm = update_encoding.add(0, 7, price_sz()); break; } default: