From e0657fc9b4cb616c3a58a47e31b2997942d09f05 Mon Sep 17 00:00:00 2001 From: ying liu Date: Mon, 29 Jul 2024 13:15:56 +0800 Subject: [PATCH] [fix] midprice fix --- pkg/strategy/ccinr/strategy.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/strategy/ccinr/strategy.go b/pkg/strategy/ccinr/strategy.go index 371e9f1..69e3b60 100644 --- a/pkg/strategy/ccinr/strategy.go +++ b/pkg/strategy/ccinr/strategy.go @@ -149,11 +149,14 @@ func (s *Strategy) generateOrders(ctx context.Context, kline types.KLine) ([]typ log.Infof(fmt.Sprintf("place order keline info: symbol %s, high %v, low %v, open %v, close %v", symbol, kline.High.Float64(), kline.Low.Float64(), kline.Open.Float64(), kline.Close.Float64())) placePrice := fixedpoint.Value(0) - 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 if s.TradeType[symbol] == "long" { - placePrice = midPrice + placePrice = kline.Low + //placePrice = midP } else if s.TradeType[symbol] == "short" { - placePrice = midPrice + placePrice = kline.High + //placePrice = midP } else { return orders, nil } @@ -360,12 +363,12 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor, if !s.Traded[symbol] { // 如若在下一根k线未成交 则取消订单 - if s.TradeType[symbol] != "" && s.TradeRetry[symbol] > 1 { + if s.TradeType[symbol] != "" && s.TradeRetry[symbol] > 10 { qbtrade.Notify(fmt.Sprintf("交易信号未成交,取消订单: %s", symbol)) s.cancelOrders(ctx, symbol) } - if s.TradeType[symbol] != "" && s.TradeRetry[symbol] <= 1 { + if s.TradeType[symbol] != "" && s.TradeRetry[symbol] <= 10 { s.TradeRetry[symbol] = s.TradeRetry[symbol] + 1 } }