From b7a1a60c6fad2b67592401ded306ce6f7d644901 Mon Sep 17 00:00:00 2001 From: ZhouYongyou <128128010+zhouyongyou@users.noreply.github.com> Date: Sun, 2 Nov 2025 22:08:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=87=E6=BB=A4=E5=B9=BD=E7=81=B5?= =?UTF-8?q?=E6=8C=81=E4=BB=93=20-=20=E8=B7=B3=E8=BF=87=20quantity=3D0=20?= =?UTF-8?q?=E7=9A=84=E6=8C=81=E4=BB=93=E9=98=B2=E6=AD=A2=20AI=20=E8=AF=AF?= =?UTF-8?q?=E5=88=A4=20=E9=97=AE=E9=A2=98=EF=BC=9A=20-=20=E6=AD=A2?= =?UTF-8?q?=E6=8D=9F/=E6=AD=A2=E7=9B=88=E8=A7=A6=E5=8F=91=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=BA=A4=E6=98=93=E6=89=80=E8=BF=94=E5=9B=9E=20positi?= =?UTF-8?q?onAmt=3D0=20=E7=9A=84=E6=8C=81=E4=BB=93=E8=AE=B0=E5=BD=95=20-?= =?UTF-8?q?=20=E8=BF=99=E4=BA=9B=E5=B9=BD=E7=81=B5=E6=8C=81=E4=BB=93?= =?UTF-8?q?=E8=A2=AB=E4=BC=A0=E9=80=92=E7=BB=99=20AI=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20AI=20=E8=AF=AF=E4=BB=A5=E4=B8=BA=E4=BB=8D=E6=8C=81?= =?UTF-8?q?=E6=9C=89=E8=AF=A5=E5=B8=81=E7=A7=8D=20-=20AI=20=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=9F=BA=E4=BA=8E=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=81=9A=E5=87=BA=E5=86=B3=E7=AD=96=EF=BC=88=E5=A6=82=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E8=B0=83=E6=95=B4=E5=B7=B2=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=E6=AD=A2=E6=8D=9F=EF=BC=89=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=9A=20-=20buildTradingContext()=20=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20quantity=3D=3D0=20=E6=A3=80=E6=9F=A5=20-=20?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E5=B7=B2=E5=B9=B3=E4=BB=93=E7=9A=84=E6=8C=81?= =?UTF-8?q?=E4=BB=93=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=8F=AA=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E6=8C=81=E4=BB=93=E7=BB=99=20AI=20-=20?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=B8=85=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=9A?= =?UTF-8?q?=E6=92=A4=E9=94=80=E5=AD=A4=E5=84=BF=E8=AE=A2=E5=8D=95=E3=80=81?= =?UTF-8?q?=E6=B8=85=E7=90=86=E5=86=85=E9=83=A8=E7=8A=B6=E6=80=81=20?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E8=8C=83=E5=9B=B4=EF=BC=9A=20-=20trader/auto?= =?UTF-8?q?=5Ftrader.go:487-490=20=E6=B5=8B=E8=AF=95=EF=BC=9A=20-=20?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=88=90=E5=8A=9F=20-=20=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E9=87=8D=E5=BB=BA=E5=B9=B6=E5=90=AF=E5=8A=A8=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trader/auto_trader.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/trader/auto_trader.go b/trader/auto_trader.go index 1e93ab5c..6dfdac99 100644 --- a/trader/auto_trader.go +++ b/trader/auto_trader.go @@ -195,7 +195,8 @@ func NewAutoTrader(config AutoTraderConfig) (*AutoTrader, error) { // 设置默认系统提示词模板 systemPromptTemplate := config.SystemPromptTemplate if systemPromptTemplate == "" { - systemPromptTemplate = "default" // 默认使用 default 模板 + // feature/partial-close-dynamic-tpsl 分支默认使用 adaptive(支持动态止盈止损) + systemPromptTemplate = "adaptive" } return &AutoTrader{ @@ -481,6 +482,12 @@ func (at *AutoTrader) buildTradingContext() (*decision.Context, error) { if quantity < 0 { quantity = -quantity // 空仓数量为负,转为正数 } + + // 跳过已平仓的持仓(quantity = 0),防止"幽灵持仓"传递给AI + if quantity == 0 { + continue + } + unrealizedPnl := pos["unRealizedProfit"].(float64) liquidationPrice := pos["liquidationPrice"].(float64)