feat order.py
This commit is contained in:
@@ -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("取消过期订单失败")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user