fix: Support integer ticks in sparkd, py plugins

Bugs (fixed):
  * sparkd crashes if DUCK is added to bybit symbols

  Cause: DUCKUSDT qty tick is 10 (previously, we only supported qty
  ticks <= 1)
This commit is contained in:
John Colvin committed 2025-06-24 18:09:20 +00:00
1 parent 38afd3055f
commit 0133159296
3 files changed
+12 -3

No files matched your search

@@ -74,13 +74,13 @@ def fetch_futures_specs(contracts: Iterable[str], use_testnet: bool = True) -> d
continue
tick_unit, tick_base = get_tick_factors(price_tick)
qty_tick_base = min(int(1 / qty_step), 1000000) if qty_step != 0 else 10000
qty_tick_unit, qty_tick_base = get_tick_factors(qty_step)
specs_dict[contract] = {
"tick_unit": tick_unit,
"tick_base": tick_base,
"cash_per_point": 1,
"qty_tick_unit": 1,
"qty_tick_unit": qty_tick_unit,
"qty_tick_base": qty_tick_base,
"min_notional_value": float(
lot_size.get("minNotionalValue", tick_unit / tick_base)
@@ -219,6 +219,9 @@ def get_tick_factors(tick_sz: float):
"""
if not (tick_sz > 0):
raise ValueError(f"Invalid tick size {tick_sz}")
if tick_sz > 1:
# integer tick
return (tick_sz, 1)
tick_denom = 1.0 / tick_sz
match tick_denom:
case 1:
@@ -335,7 +338,7 @@ def get_quantity_info(
max_price: Optional[float] = None,
):
# Use 'not' checks to account for nans (for which every op evaluates to false)
if not (tick_unit > 0) or not (tick_base >= tick_unit):
if not (tick_unit > 0):
raise ValueError(f"Invalid tick factors {tick_unit}/{tick_base}")
if not min_value:
min_value = tick_unit / tick_base