package trade // 平仓策略参数 type CloseStrategyParam struct { StopLossPct float64 // 固定止损 static stoploss TakeProfitPct float64 // 固定止盈 static take profit TrailMinProfit float64 // 启动移动止损的最小盈利阈值(例如达到 1% 后才开始追踪) minimum profit (fraction) before trailing activates (e.g. 0.01 = 1%); TrailingPct float64 // 移动止损百分比(例如 0.02 表示从最高价回撤 2% 时触发追踪止损) trailing stop percent (e.g. 0.02 = 2%); ProfitRetracePct float64 // close when profit retraces more than this fraction of peak profit;基于最高利润回撤触发平仓(例如从最高利润回撤超过 30% 则平仓)。 } type CloseStrategy struct { } func NewCloseStrategy(param CloseStrategyParam) { } // OnPriceUpdate 当价格更新判断是否关闭仓位 func (s *CloseStrategy) OnPriceUpdate(price float64, position *string) (closePos bool) { return }