SP-131
This commit is contained in:
1 parent
2bafc12502
commit
c40eef7b03
2 files changed
+52
-1
No files matched your search
@@ -248,8 +248,11 @@ void DormanAlgo::on_book(SecurityKey key, const Book& book) {
|
||||
}
|
||||
// See if we need to adjust
|
||||
else {
|
||||
if (target == me->exposed_qty) {
|
||||
me->next_size = std::nullopt;
|
||||
}
|
||||
// If target < size reduce immidiately
|
||||
if (target < me->exposed_qty) {
|
||||
else if (target < me->exposed_qty) {
|
||||
update_child(target);
|
||||
me->next_size = std::nullopt;
|
||||
}
|
||||
|
||||
@@ -649,6 +649,54 @@ TEST_CASE("Dorman updates child", "[algo][dorman]") {
|
||||
// When updating the Dorman price the price of the child should also update
|
||||
}
|
||||
|
||||
TEST_CASE("Dorman market move up then back down", "[algo][dorman]") {
|
||||
// Start dorman algo
|
||||
// Move market up so we plan to increase the exposed qty after trail_seconds
|
||||
// Move market back down before trail_seconds elapses
|
||||
// check that algo does *not* increase exposure
|
||||
|
||||
AlgoParams input;
|
||||
input.steps.step_table = {
|
||||
{500, 250},
|
||||
{1000, 450},
|
||||
{2000, 650},
|
||||
{3500, 750},
|
||||
};
|
||||
input.steps.maximum = 750;
|
||||
input.steps.trail_seconds = 30;
|
||||
input.clip_limit = 100;
|
||||
api::orderman::OrderDefinition def;
|
||||
def.set_side(api::SIDE_BUY);
|
||||
def.mutable_custom_def()->mutable_dynamic()->CopyFrom(to_dynamic_order_params(input));
|
||||
// auto price = Price { some_price.price() };
|
||||
|
||||
AlgoTestDriver<DormanAlgo> state(def, some_price, Quantity {1337});
|
||||
auto secid = SecurityKey(state.security().id());
|
||||
|
||||
Book book(secid);
|
||||
book.bid()[0] = { some_price, 350 };
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
REQUIRE(state.child_orders().size() == 1);
|
||||
state.advance_time(std::chrono::seconds(1));
|
||||
|
||||
// Update book sets future quantity = 450
|
||||
book.bid()[0] = { some_price, 999 };
|
||||
state.update_book(book);
|
||||
state.advance_time(std::chrono::seconds(10));
|
||||
// Algo does not increase exposure after 10 second
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
|
||||
book.bid()[0] = { some_price, 425 };
|
||||
state.update_book(book);
|
||||
state.advance_time(std::chrono::seconds(40));
|
||||
// Algo does not increase exposure after trail_seconds
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}}//namespace
|
||||
|
||||
Reference in new issue
Block a user