Integrate theos into Algo Testing Framework

(For Laguna)
This commit is contained in:
John Colvin committed 2024-05-13 14:28:16 +00:00
1 parent b91cdd6d91
commit 90705cac83
2 files changed
+23 -3

No files matched your search

@@ -3,6 +3,7 @@
#include "lib/api/services/OrderService.pb.h"
#include "lib/logging/logging.h"
#include "lib/md/relay/RelayRecorder.h"
#include "lib/orderman/calculations/ITheoCalculator.h"
#include "lib/orderman/orderman_utils/Book.h"
#include <optional>
@@ -93,6 +94,7 @@ struct AlgoTestDriverBase::Impl : public RecursionCounter {
std::vector<ChildOrder> detached_orders;
std::map<SecurityKey, Book> books;
std::shared_ptr<analytics::ITheoCalculator> theo_calc{nullptr};
std::map<SecurityKey, Price> settlements;
std::map<SecurityKey, bool> book_subs;
std::map<SecurityKey, bool> settlement_subs;
@@ -100,6 +102,7 @@ struct AlgoTestDriverBase::Impl : public RecursionCounter {
std::map<SecurityKey, bool> status_subs;
bool sub_timer = false;
bool sub_position = false;
bool is_subscribed_to_theos = false;
// Callbacks
std::vector<std::function<void(OrderKey, Quantity, Price)>>
@@ -159,7 +162,7 @@ AlgoTestDriverBase::AlgoTestDriverBase(
me->now = Timer::now();
me->state = AlgoState::CREATED;
auto securities = get_some_securities();
auto securities = get_test_securities();
REQUIRE(securities.size() > 0);
me->security = securities.begin()->second;
@@ -203,6 +206,14 @@ void AlgoTestDriverBase::update_book(const Book &book) {
}
}
void AlgoTestDriverBase::update_theos(
std::shared_ptr<analytics::ITheoCalculator> theo_calc) {
me->theo_calc = theo_calc;
if (me->is_subscribed_to_theos && theo_calc != nullptr) {
me->algo.on_theos(me->theo_calc.get());
}
}
void AlgoTestDriverBase::update_settlement(SecurityKey key, Price price) {
me->settlements[key] = price;
auto iter = me->settlement_subs.find(key);
@@ -493,8 +504,16 @@ void AlgoTestDriverBase::unsubscribe_timer() { me->sub_timer = false; }
void AlgoTestDriverBase::subscribe_position() { me->sub_position = true; }
void AlgoTestDriverBase::unsubscribe_position() { me->sub_position = false; }
void AlgoTestDriverBase::subscribe_theos() {}
void AlgoTestDriverBase::unsubscribe_theos() {}
void AlgoTestDriverBase::subscribe_theos() {
me->is_subscribed_to_theos = true;
if (me->theo_calc != nullptr) {
me->algo.on_theos(me->theo_calc.get());
}
}
void AlgoTestDriverBase::unsubscribe_theos() {
me->is_subscribed_to_theos = false;
}
OrderKey AlgoTestDriverBase::launch_child(
ChildTemplate &, Price price, Quantity qty, bool sub) {
@@ -1,5 +1,6 @@
#pragma once
#include "lib/md/IntPrice.h"
#include "lib/orderman/calculations/ITheoCalculator.h"
#include "lib/orderman/events/TickerUpdateEvent.h"
#include "lib/orderman/orders/algo/IAlgoOrder.h"
#include "lib/orderman/orders/algo/IAlgoServices.h"