41 const auto broker =
static_cast<std::size_t
>(fill.broker_id);
42 if (fill.journal_seq == 0) {
45 if (fill.replayed && !store_) {
48 return broker < journaled_.size() && fill.journal_seq <= journaled_[broker];
58 std::unordered_map<std::string, Position>
get_all_positions(
const std::string& strategy_id)
const;
61 std::unordered_map<std::string, std::unordered_map<std::string, Position>>
get_all_positions()
const;
85 struct PositionWithLots {
87 std::vector<Lot> lots;
90 PositionWithLots() =
default;
91 explicit PositionWithLots(
const std::string& inst) : position(inst) {}
96 void persist(
const std::string& strategy_id, PositionWithLots& pos,
const OrderFillEvent* fill =
nullptr);
99 void apply_fill(PositionWithLots& pos,
bool is_buy,
qty_t fill_qty,
price_t fill_price, uint64_t timestamp,
price_t fee_amount);
105 FeeStructure fee_structure_;
107 PositionStore* store_{
nullptr};
109 std::array<uint64_t, PositionStore::MAX_BROKERS> journaled_{};
111 std::unordered_map<std::string, double> contract_multipliers_;
114 std::unordered_map<std::string, std::unordered_map<std::string, PositionWithLots>> positions_;