tests were failing because of direct vs merged

This commit is contained in:
Taha Afzal committed 2019-02-28 11:10:56 -05:00
1 parent d582ed8436
commit d615dcc7d6
2 files changed
+19 -10

No files matched your search

@@ -3856,6 +3856,10 @@ TEST_CASE ("net_change_transformation", "[spreader]")
int n_runs=1000;
size_t n_levels=5;
for(int i=0;i<n_runs;i++){
double leg1_qty=gen_rand(1,5,1),
leg2_qty=-1.0*gen_rand(1,5,1),
leg1_pmult=gen_rand(1,5,0.25),
leg2_pmult=-1*gen_rand(1,5,0.25);
double settle1=gen_rand(1,3,tick1),
settle2=gen_rand(1,3,tick2);
double price = bts::securities::raw_round_to_quote_price(gen_rand(-20,20),1.0,api::Side::SIDE_BUY);
@@ -3873,19 +3877,19 @@ TEST_CASE ("net_change_transformation", "[spreader]")
SpreaderUtils::copy_book(b1_raw,
md::IntPrice_from_double<7>(settle1),
tick1,
spark::LegSpreaderParams::DIRECT,
spark::LegSpreaderParams::MERGED,
bts::api::SyntheticContract::PRICECALC_NET_CHANGE,
b1_ticks);
SpreaderUtils::copy_book(b2_raw,
md::IntPrice_from_double<7>(settle2),
tick2,
spark::LegSpreaderParams::DIRECT,
spark::LegSpreaderParams::MERGED,
bts::api::SyntheticContract::PRICECALC_NET_CHANGE,
b2_ticks);
// generate the leg properties accordingly (notice the tick size is 1
// since the market is in ticks)
LegPropertyData lp1=create_leg_property_data(0,1,1.0,api::Side::SIDE_BUY,1,0,true),
lp2=create_leg_property_data(1,-1,-1.0,api::Side::SIDE_SELL,1,1,true);
LegPropertyData lp1=create_leg_property_data(0,leg1_qty,leg1_pmult,api::Side::SIDE_BUY,1,0,true),
lp2=create_leg_property_data(1,leg2_qty,leg2_pmult,api::Side::SIDE_SELL,1,1,true);
Price out_p_ticks; Quantity out_q_ticks;
SpreaderUtils::compute_price_quantity_2_legs(Price(price),
Quantity(5),
@@ -3909,10 +3913,15 @@ TEST_CASE ("net_change_transformation", "[spreader]")
b1_raw,
out_p_raw,
out_q_raw);
REQUIRE(bts::securities::test_price_equality(out_p_ticks.value()*tick2+settle2,
out_p_raw.value(),
tick2)==
true);
if(!bts::securities::test_price_equality(out_p_ticks.value()*tick2+settle2,
out_p_raw.value(),
tick2)){
REQUIRE(out_p_ticks.value()*tick2+settle2 == out_p_raw.value());
}
// REQUIRE(bts::securities::test_price_equality(out_p_ticks.value()*tick2+settle2,
// out_p_raw.value(),
// tick2)==
// true);
REQUIRE(out_q_ticks.value()==out_q_raw.value());
}
}
@@ -675,12 +675,12 @@ void generate_random_book(size_t n_levels,
double b=top_book,
a=top_ask;
for(size_t i=0;i<n_levels;i++){
bid_prices[i]=b;
bid_prices[i]= bts::securities::raw_round_to_quote_price(b,tick_size,api::Side::SIDE_BUY);
direct_bid_sizes[i]=gen_rand(10,100);
implied_bid_sizes[i]=gen_rand(10,100);
b-=gen_rand(1,10)*tick_size;
ask_prices[i]=a;
ask_prices[i]=bts::securities::raw_round_to_quote_price(a,tick_size,api::Side::SIDE_SELL);
direct_ask_sizes[i]=gen_rand(10,100);
implied_ask_sizes[i]=gen_rand(10,100);
a+=gen_rand(1,10)*tick_size;