diff --git a/src/lib/md/test/Co2TestInstrument.h b/src/lib/md/test/Co2TestInstrument.h index 0e1601007..dfd784908 100644 --- a/src/lib/md/test/Co2TestInstrument.h +++ b/src/lib/md/test/Co2TestInstrument.h @@ -15,6 +15,9 @@ struct Co2TestInstrument MDProducerHandle producer(); MDConsumerHandle consumer(); + + ColdEntry& cold() { return *_cold; } + private: std::shared_ptr _cold_buffer; ColdEntry* _cold; diff --git a/src/lib/md/test/synthetic_book_merge_tests.cpp b/src/lib/md/test/synthetic_book_merge_tests.cpp index 87e8ce79a..2e67ceda0 100644 --- a/src/lib/md/test/synthetic_book_merge_tests.cpp +++ b/src/lib/md/test/synthetic_book_merge_tests.cpp @@ -103,22 +103,29 @@ tuple,vector> make_securities(c api::Side side; std::tie(quantity, mult, tick_size, side) = ldesc; Co2TestInstrument instr("ES", api::SECURITYTYPE_FUTURE); + // tick_size / display_factor + auto display_factor = pow10(instr.cold().security.display_factor); + instr.cold().security.low_tick = tick_size / display_factor; + instr.cold().security.high_tick = tick_size / display_factor; instr.producer().set_key(security_key); ++security_key; auto& s = synthetic->security; + // Set the synthetic tick size equal to the (last) leg. (needs to not be 0) s.mutable_contract_spec()->set_low_tick(tick_size); s.mutable_contract_spec()->set_high_tick(tick_size); auto* ps = s.mutable_synthetic(); auto l = ps->mutable_legs()->Add(); l->mutable_security()->CopyFrom(instr.consumer().get_normalized_security()); + l->mutable_security()->mutable_contract_spec()->set_low_tick(tick_size); + l->mutable_security()->mutable_contract_spec()->set_high_tick(tick_size); l->set_quantity(quantity); l->set_price_multiplier(quantity * (side == api::SIDE_BUY ? 1.0 : -1)); l->set_side(side); synthetic->legs.push_back(instr.consumer()); legs.push_back(instr); - } + return { synthetic, legs }; } // tuple = (quantity, tick_size, side) @@ -381,7 +388,11 @@ TEST_CASE("AggregationAcrossLevels", "[md][synthetic]") { TEST_CASE("Synthetic_net_change", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.01, api::SIDE_BUY}, {2.0, 0.01, api::SIDE_SELL }}); + // This tick size is what you get when you make up a test and then later have to figure out the tick size because NetChange suddenly depends on tick size + tie(synthetic, test_instr) = make_securities({ {1.0, 10.0, api::SIDE_BUY}, {2.0, 10.0, api::SIDE_SELL }}); + // Set to tick in "# ticks" + synthetic->security.mutable_contract_spec()->set_low_tick(1.0); + synthetic->security.mutable_contract_spec()->set_high_tick(1.0); auto es_buy1 = test_instr[0]; auto es_sell2 = test_instr[1]; MDConsumerHandle synthetic_handle{synthetic}; @@ -404,11 +415,9 @@ TEST_CASE("Synthetic_net_change", "[md][synthetic]") { {{90,5}, {80,9}, {70,11}, {60,10}, {50,1}}, {{100,16}, {110,8}, {120,12}, {130,5}}); - // Validate merge expect_market(synthetic_handle, - {{-10,1}, {-20,7}, {-40,4}, {-70,4}, {-80,2}, {-100,2}}, - {{20,2}, {50,5}, {70,1}, {80,4}, {100,4}, {110,1}, {130,1}}); - // precise {{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, {110,1}, {120,1}}); + {{-1,1}, {-2,7}, {-4,4}, {-7,4}, {-8,2}, {-10,2}}, + {{2,2}, {5,5}, {7,1}, {8,4}, {10,4}, {11,1}, {13,1}}); } }