added sweep test for the sell side

This commit is contained in:
Taha Afzal committed 2020-12-09 14:49:57 -05:00
1 parent 2ac74c5e29
commit af1ab49219
1 file changed
+19
@@ -4118,6 +4118,7 @@ TEST_CASE ("sniper", "[spreader]"){
new uint16_t[5] {5,10,15,20,25},
true);
Book look_ahead_book = bk;
// buy sweep
bool res = SpreaderUtils::compute_book_from_sweep(bk,api::Side::SIDE_BUY,Price(80),Quantity(15),look_ahead_book);
REQUIRE(res);
res = SpreaderUtils::compute_book_from_sweep(bk,api::Side::SIDE_BUY,Price(80),Quantity(16),look_ahead_book);
@@ -4136,6 +4137,24 @@ TEST_CASE ("sniper", "[spreader]"){
new double[5] {90,100,os::nan(),os::nan(),os::nan()},
new uint16_t[5] {20,25,0,0,0},
true);
// sell sweep
res = SpreaderUtils::compute_book_from_sweep(bk,api::Side::SIDE_SELL,Price(40),Quantity(15),look_ahead_book);
REQUIRE(res);
res = SpreaderUtils::compute_book_from_sweep(bk,api::Side::SIDE_SELL,Price(40),Quantity(16),look_ahead_book);
REQUIRE(!res);
res = SpreaderUtils::compute_book_from_sweep(bk,api::Side::SIDE_SELL,Price(40.01),Quantity(15),look_ahead_book);
REQUIRE(!res);
res = SpreaderUtils::compute_book_from_sweep(bk,api::Side::SIDE_SELL,Price(40),Quantity(15),look_ahead_book);
REQUIRE(res);
validate_book(look_ahead_book,SecurityKey(10),api::Side::SIDE_BUY,0.001,
new double[5] {30,20,10,os::nan(),os::nan()},
new uint16_t[5] {25,35,45,0,0},
true);
validate_book(look_ahead_book,SecurityKey(10),api::Side::SIDE_SELL,0.001,
new double[5] {40,60,70,80,90},
new uint16_t[5] {1,5,10,15,20},
true);
}
}