Files
big-qmt/py-client/strategy/zt/open.py
2026-08-31 13:00:22 +08:00

28 lines
1.1 KiB
Python

"""使用 dcm 信号建立做 T 底仓。"""
from __future__ import annotations
import logging
from libs.calc import calc_buy_volume
from sdk import OP_BUY
from strategy.trend.order import PlaceOrderRequest
def open_base(run, ticks, signals) -> None:
"""仅处理 dcm 信号,使用趋势策略同款反弹确认建立底仓。"""
for signal in signals:
if signal.signal_key != "dcm" or run.orders.busy(signal.code, "BUY"):
continue
tick = ticks.get(signal.code)
price = tick.last_price if tick else 0.0
if price <= 0 or price > run.account_cfg.zt_max_price:
continue
volume = calc_buy_volume(price, run.account_cfg.buy_value)
if volume <= 0 or not run.buy_watch.triggered("ZT 建仓", signal.code, price):
continue
request = PlaceOrderRequest(run.client, OP_BUY, signal.code, volume, run.orders.new_order_id("base"), run.account_cfg.strategy)
if run.orders.place(request):
run.buy_watch.forget(signal.code)
logging.info("[ZT 建仓] %s 买入 %d", signal.code, volume)