tests for order remove/modify and its affects on the book

This commit is contained in:
Taha Afzal committed 2020-08-21 18:49:00 -04:00
1 parent 29e080da71
commit b7f15986ad
1 file changed
+30
@@ -465,6 +465,36 @@ TEST_CASE("fifo_matching_engine_book", "[spartan_md]") {
Book bk = sec_me.book(api::Side::SIDE_BUY);
verify_book_level(bk.at(1),15.07,3240,80);
}
SECTION("modify") {
auto n_levels = 10;
// bids
for (struct {int i=0;double p=15;void inc(){i++;p+=0.01;}} lp;
lp.i<n_levels;lp.inc())
add_to_book((lp.i+1)*10,api::Side::SIDE_BUY, lp.p);
// asks
for (struct {int i=0;double p=15.10;void inc(){i++;p+=0.01;}} lp;
lp.i<n_levels;lp.inc())
add_to_book((lp.i+1)*10,api::Side::SIDE_SELL,lp.p);
// modify qty of all orders to 1
auto b = 360;
for (auto i=0;i<90;i++){
auto id = i+b;
auto ord = create_order(id,sec_key,api::Side::SIDE_BUY,id,15.08,1);
sec_me.on_order_update(ord);
}
Book bk = sec_me.book(api::Side::SIDE_BUY);
verify_book_level(bk.at(1),15.08,90,90);
// now change all these prices to move to a diff level
for (auto i=0;i<90;i++){
auto id = i+b;
auto ord = create_order(id,sec_key,api::Side::SIDE_BUY,id,15.09,1);
sec_me.on_order_update(ord);
}
// 15.08 is gone
bk = sec_me.book(api::Side::SIDE_BUY);
verify_book_level(bk.at(1),15.07,3240,80);
verify_book_level(bk.at(0),15.09,5140,190);
}
}
} // namespace bts::spartan::mdp3::tests