chore: Set min notional value for secs in bybit md provider
This commit is contained in:
1 parent
5f141a8030
commit
7483665b5a
1 file changed
+20
-9
@@ -65,21 +65,25 @@ def fetch_futures_specs(contracts: Iterable[str], use_testnet: bool = True) -> d
|
||||
if contract in contracts:
|
||||
try:
|
||||
price_tick = float(item.get("priceFilter", {}).get("tickSize", 0.1))
|
||||
lot_size = float(item.get("lotSizeFilter", {}).get("qtyStep", 0.001))
|
||||
lot_size = item.get("lotSizeFilter", {})
|
||||
qty_step = float(lot_size.get("qtyStep", 0.001))
|
||||
|
||||
if price_tick == 0 or lot_size == 0:
|
||||
logger.error(f"Invalid tick or lot size for {contract}: tickSize={price_tick}, qtyStep={lot_size}")
|
||||
if price_tick == 0 or qty_step == 0:
|
||||
logger.error(f"Invalid tick or lot size for {contract}: tickSize={price_tick}, qtyStep={qty_step}")
|
||||
continue
|
||||
|
||||
tick_unit, tick_base = get_tick_factors(price_tick)
|
||||
qty_tick_base = min(int(1 / lot_size), 1000000) if lot_size != 0 else 10000
|
||||
qty_tick_base = min(int(1 / qty_step), 1000000) if qty_step != 0 else 10000
|
||||
|
||||
specs_dict[contract] = {
|
||||
"tick_unit": tick_unit,
|
||||
"tick_base": tick_base,
|
||||
"cash_per_point": 1,
|
||||
"qty_tick_unit": 1,
|
||||
"qty_tick_base": qty_tick_base
|
||||
"qty_tick_base": qty_tick_base,
|
||||
"min_notional_value": float(
|
||||
lot_size.get("minNotionalValue", tick_unit / tick_base)
|
||||
),
|
||||
}
|
||||
found_contracts.add(contract)
|
||||
logger.info(f"Fetched futures specs for {contract}: {specs_dict[contract]}")
|
||||
@@ -162,13 +166,20 @@ class BybitMdProvider(MdProvider):
|
||||
continue
|
||||
|
||||
try:
|
||||
price_tick_unit = specs.get("tick_unit", 1)
|
||||
price_tick_base=specs.get("tick_base", 10)
|
||||
spec = get_contract_spec(
|
||||
price_info=get_price_info(
|
||||
tick_unit=specs.get("tick_unit", 1),
|
||||
tick_base=specs.get("tick_base", 10),
|
||||
cash_per_point=specs.get("cash_per_point", 0.1)
|
||||
tick_unit=price_tick_unit,
|
||||
tick_base=price_tick_base,
|
||||
cash_per_point=specs.get("cash_per_point", 0.1),
|
||||
),
|
||||
qty_info=qty_info,
|
||||
notional_qty_info=get_quantity_info(
|
||||
tick_unit=price_tick_unit,
|
||||
tick_base=price_tick_base,
|
||||
min_value=specs.get("min_notional_value"),
|
||||
),
|
||||
qty_info=qty_info
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to get contract spec for contract: {contract}, error: {e}")
|
||||
|
||||
Reference in new issue
Block a user