SPARK-283 more tests

This commit is contained in:
Taha Afzal committed 2017-11-15 10:18:09 -05:00
1 parent 4f77edbe93
commit 08a62988f0
2 files changed
+24 -1

No files matched your search

@@ -360,6 +360,27 @@ TEST_CASE ("test_leg_quantity_normalization", "[spreader]")
expected_value = std::round(std::abs(leg_mult * spr_qty));
REQUIRE (calc_value == expected_value);
}
for (int i = 0; i < n_runs; i++)
{
double leg_mult_1 = gen_rand(-5.0, 2.0),
leg_mult_2 = gen_rand(-5.0, 2.0);
uint32_t leg_qty = gen_rand(0, 100);
std::string symbol = "ES";
ContractLeg leg_1, leg_2;
fill_future_contract_leg (leg_1, 0, symbol, bts::api::Venue::VENUE_GLBX, 2017, 12, 15, leg_mult_1, api::Side::SIDE_BUY, 1.0);
fill_future_contract_leg (leg_2, 1, symbol, bts::api::Venue::VENUE_GLBX, 2018, 3, 15, leg_mult_2, api::Side::SIDE_SELL, 1.0);
QuoteParams qp_1, qp_2;
fill_quote_params(qp_1, 1.0);
fill_quote_params(qp_2, 1.0);
LegSpreaderParams lsp_1, lsp_2;
fill_leg_spreader_params (lsp_1, 1.0, true, qp_1);
fill_leg_spreader_params (lsp_2, 1.0, true, qp_2);
LegPropertyData leg_prop_data_1 (0, leg_1, lsp_1, api::Side::SIDE_BUY);
LegPropertyData leg_prop_data_2 (1, leg_2, lsp_2, api::Side::SIDE_BUY);
double calc_value = SpreaderUtils::get_equivelant_size (leg_prop_data_1, Quantity(leg_qty), leg_prop_data_2),
expected_value = std::round(std::abs(leg_qty * leg_mult_2 / leg_mult_1));
REQUIRE (calc_value == expected_value);
}
}
// given a qty, traverses the book to find the level
// where the accumulated qty >= given qty
+3 -1
View File
@@ -87,7 +87,9 @@ public:
static double get_equivelant_size (const LegPropertyData& source_leg, Quantity source_leg_quantity,
const LegPropertyData& target_leg)
{
return target_leg.size_multiplier () * source_leg_quantity.value () / source_leg.size_multiplier ();
double rv = std::abs(target_leg.size_multiplier () * source_leg_quantity.value () / source_leg.size_multiplier ());
rv = std::round(rv);
return rv;
}
// given the quantity of the spreader order, determines the quality
// of the leg