Split exchange and strategy modules for future Binance support.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""交易所行情适配器协议:策略/撮合只依赖此接口,不直接碰 OKX/币安。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Protocol, Sequence, runtime_checkable
|
||||
|
||||
from .types import BookLevel, MarketSnapshot, OptionPair, Quote
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class ExchangeMarket(Protocol):
|
||||
name: str
|
||||
|
||||
async def start(self) -> None: ...
|
||||
|
||||
async def stop(self) -> None: ...
|
||||
|
||||
def list_option_contracts(self, family: str) -> list[dict[str, Any]]:
|
||||
"""中性期权合约列表:inst_id/expiry_ymd/strike/side/ct_mult。"""
|
||||
...
|
||||
|
||||
def fetch_index(self, index_id: str) -> float | None: ...
|
||||
|
||||
def fetch_mark(self, inst_id: str) -> float | None: ...
|
||||
|
||||
def fetch_book(
|
||||
self, inst_id: str, depth: int = 5
|
||||
) -> tuple[list[BookLevel], list[BookLevel], int | None]: ...
|
||||
|
||||
def get_ct_mult(self, option_inst_id: str, family: str, default: float) -> float: ...
|
||||
|
||||
def set_pair(self, pair: OptionPair | None) -> None: ...
|
||||
|
||||
def warm_and_subscribe(self, inst_ids: Sequence[str]) -> None:
|
||||
"""REST 预热盘口 + 设置 WS 订阅列表。"""
|
||||
...
|
||||
|
||||
async def resubscribe(self, inst_ids: Sequence[str]) -> None: ...
|
||||
|
||||
def quote(self, inst_id: str) -> Quote | None: ...
|
||||
|
||||
def snapshot(self, perp_inst_id: str) -> MarketSnapshot: ...
|
||||
|
||||
def snapshot_dict(self, perp_inst_id: str) -> dict[str, Any]: ...
|
||||
|
||||
def set_index_px(self, px: float | None) -> None: ...
|
||||
|
||||
def set_mark_px(self, inst_id: str, mark_px: float | None) -> None: ...
|
||||
Reference in New Issue
Block a user