diff --git a/src/cs/Bts.Spark.Sdk.Demo/TopOfBookQuoter.cs b/src/cs/Bts.Spark.Sdk.Demo/TopOfBookQuoter.cs index bc0872a71..d6ee2bc17 100644 --- a/src/cs/Bts.Spark.Sdk.Demo/TopOfBookQuoter.cs +++ b/src/cs/Bts.Spark.Sdk.Demo/TopOfBookQuoter.cs @@ -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)