improve: Use quantity sign to indicate side in TopOfBookQuoter example

This commit is contained in:
John Colvin committed 2026-05-14 10:43:01 -04:00
1 parent c507f20a8e
commit aa403b83ef
1 file changed
+6 -5
+6 -5
View File
@@ -41,8 +41,8 @@ class TopOfBookQuoter : IHostedService {
throw new ArgumentException("Failed to parse venue", nameof(config));
}
var quantity = config.Quantity;
if (!(quantity > 0)) {
throw new ArgumentException("Quantity is not positive", nameof(config));
if (quantity == 0 || !double.IsRealNumber(quantity)) {
throw new ArgumentException("Quantity must be real and non-zero", nameof(config));
}
this.config = new(venue, contract, account, config.OffsetTicks, quantity);
}
@@ -86,11 +86,12 @@ class TopOfBookQuoter : IHostedService {
if (!bk.Security.HasValue) {
return;
}
var bidPrice = bk[Side.Buy, 0].Price;
var orderPrice = bidPrice;
var orderQty = config.Quantity;
var bidPrice = bk[orderQty < 0 ? Side.Sell : Side.Buy, 0].Price;
orderQty = Math.Abs(orderQty);
var orderPrice = bidPrice;
if (config.OffsetTicks != 0) {
orderPrice = bk.Security.Value.tick_factors().tickdown(orderPrice, config.OffsetTicks);
orderPrice = bk.Security.Value.tick_factors().tick(orderPrice, config.OffsetTicks);
}
if (securityToOrderId.TryGetValue(bk.SecurityId, out var orderId)
&& orders.TryGetValue(orderId, out var orderTree)