Files
big-qmt/py-client/strategy/zt/runtime.py

32 lines
873 B
Python
Raw Normal View History

2026-09-06 11:53:28 +08:00
"""做 T 策略单次运行所需的上下文对象。"""
2026-08-31 13:00:22 +08:00
from dataclasses import dataclass
from config import AccountConfig, GlobalConfig
from libs.grid_take_profit import GridTrailingTracker
from sdk import Client
2026-09-06 11:53:28 +08:00
from .order import OrderBook
from .watch import DipWatch
2026-08-31 13:00:22 +08:00
from .state import TState
2026-09-06 11:34:23 +08:00
@dataclass(slots=True)
2026-08-31 13:00:22 +08:00
class Runtime:
2026-09-06 11:53:28 +08:00
"""集中保存策略运行期间共享的依赖和状态。
将这些对象集中到一个 dataclass 开仓持仓管理和单轮调度函数
只需接收一个 Runtime无需重复传递大量参数
"""
# 外部服务与账户配置。
2026-08-31 13:00:22 +08:00
client: Client
global_cfg: GlobalConfig
account_cfg: AccountConfig
2026-09-06 11:53:28 +08:00
# 策略运行过程中共享的状态组件。
2026-08-31 13:00:22 +08:00
state: TState
orders: OrderBook
2026-09-06 11:53:28 +08:00
open_watch: DipWatch
2026-08-31 13:00:22 +08:00
buy_watch: DipWatch
sell_tracker: GridTrailingTracker