Expose latest open order ids to platform runtime

This commit is contained in:
boris
2026-04-23 04:55:44 -07:00
parent 4fdcfdae7d
commit 4d43d1b176
3 changed files with 155 additions and 2 deletions

View File

@@ -134,6 +134,23 @@ impl StrategyContext<'_> {
.sum()
}
pub fn latest_open_order_id(&self) -> u64 {
self.open_orders
.iter()
.map(|order| order.order_id)
.max()
.unwrap_or(0)
}
pub fn latest_symbol_open_order_id(&self, symbol: &str) -> u64 {
self.open_orders
.iter()
.filter(|order| order.symbol == symbol)
.map(|order| order.order_id)
.max()
.unwrap_or(0)
}
pub fn available_sellable_qty(&self, symbol: &str, raw_sellable_qty: u32) -> u32 {
raw_sellable_qty.saturating_sub(self.symbol_open_sell_quantity(symbol))
}