[fix] place price

This commit is contained in:
ying liu 2024-07-29 13:47:20 +08:00
parent f976de85cc
commit 7bb439f8d3
2 changed files with 5 additions and 5 deletions

View File

@ -44,7 +44,7 @@ exchangeStrategies:
longCCI: -150.0 longCCI: -150.0
shortCCI: 150.0 shortCCI: 150.0
leverage: 5.0 leverage: 5.0
profitRange: 0.25% profitRange: 2%
lossRange: 1% lossRange: 1%
amount: 20 amount: 20
# recalculate: false # recalculate: false

View File

@ -151,10 +151,10 @@ func (s *Strategy) generateOrders(ctx context.Context, kline types.KLine) ([]typ
//midPrice := (kline.High.Add(kline.Low)).Div(fixedpoint.Value(2.0)) //midPrice := (kline.High.Add(kline.Low)).Div(fixedpoint.Value(2.0))
//midP := (kline.High + kline.Low) / 2 //midP := (kline.High + kline.Low) / 2
if s.TradeType[symbol] == "long" { if s.TradeType[symbol] == "long" {
placePrice = kline.Low placePrice = kline.High
//placePrice = midP //placePrice = midP
} else if s.TradeType[symbol] == "short" { } else if s.TradeType[symbol] == "short" {
placePrice = kline.High placePrice = kline.Low
//placePrice = midP //placePrice = midP
} else { } else {
return orders, nil return orders, nil
@ -361,12 +361,12 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor,
if !s.Traded[symbol] { if !s.Traded[symbol] {
// 如若在下一根k线未成交 则取消订单 // 如若在下一根k线未成交 则取消订单
if s.TradeType[symbol] != "" && s.TradeRetry[symbol] > 10 { if s.TradeType[symbol] != "" && s.TradeRetry[symbol] > 1 {
qbtrade.Notify(fmt.Sprintf("交易信号未成交,取消订单: %s", symbol)) qbtrade.Notify(fmt.Sprintf("交易信号未成交,取消订单: %s", symbol))
s.cancelOrders(ctx, symbol) s.cancelOrders(ctx, symbol)
} }
if s.TradeType[symbol] != "" && s.TradeRetry[symbol] <= 10 { if s.TradeType[symbol] != "" && s.TradeRetry[symbol] <= 1 {
s.TradeRetry[symbol] = s.TradeRetry[symbol] + 1 s.TradeRetry[symbol] = s.TradeRetry[symbol] + 1
} }
} }