feat order.py

This commit is contained in:
2026-08-30 14:46:34 +08:00
parent cdccc48d8c
commit 6334f10904
19 changed files with 70 additions and 46 deletions

View File

@@ -73,15 +73,15 @@ def StartTrend() -> None:
)
assets = client.assets()
_, positions = client.positions()
order_book = OrderBook()
order_book.refresh()
storeState = State.for_strategy(
config.global_config.qmt_data_dir,
config.account_config.strategy,
config.account_config.account_id,
)
orders = client.trade_detail_data("order")
deals = client.deals()
storeState.reconcile(positions, orders, deals)
storeState.reconcile(positions, order_book.data)
# 获取本策略的信号开仓数据
signals = init_signals(
@@ -93,7 +93,7 @@ def StartTrend() -> None:
global_cfg=config.global_config,
account_cfg=config.account_config,
state=storeState,
orders=OrderBook(),
orders=order_book,
open_watch=DipWatch(),
add_watch=DipWatch(),
profit_tracker=GridTrailingTracker(config.account_config.grid_step_pct),
@@ -120,7 +120,7 @@ def RunOnce(run: Runtime, signals) -> None:
# 1. 取消超过有效期仍未完成的委托订单。
try:
run.orders.cancel_expired(run.client)
run.orders.refresh(run.client)
except Exception:
logging.exception("取消过期订单失败")