This commit is contained in:
2026-09-05 20:39:58 +08:00
parent 1fc3e119d3
commit af55324e2a
4 changed files with 110 additions and 80 deletions

View File

@@ -123,7 +123,7 @@ def handle_profit(
volume = position.can_use_volume - position.can_use_volume % 100
if volume <= 0:
return TradeDecision(False, "无可用整手持仓")
order_id = runtime.orders.new_order_id()
order_id = runtime.orders.new_order_id("SELL")
request = PlaceOrderRequest(
op=OP_SELL,
code=position.stock_code,
@@ -165,7 +165,7 @@ def handle_loss(
if volume <= 0 or amount > available:
return TradeDecision(False, "本轮可用资金不足")
order_id = runtime.orders.new_order_id()
order_id = runtime.orders.new_order_id("BUY")
request = PlaceOrderRequest(
op=OP_BUY,
code=position.stock_code,
@@ -174,8 +174,9 @@ def handle_loss(
strategy_name=runtime.account_cfg.strategy,
kind="add",
)
if not runtime.state.new_order(PendingOrder(order_id, position.stock_code, "added", volume)):
return TradeDecision(False, "已有待确认买单")
#runtime.state.new_order(PendingOrder(order_id, position.stock_code, "added", volume))
if not runtime.orders.place(runtime.client, request):
reserved = amount if runtime.state.busy(position.stock_code) else 0.0
return TradeDecision(False, "补仓委托失败或待确认", reserved)