[fix] midprice fix
This commit is contained in:
parent
4cb31648ad
commit
e0657fc9b4
|
@ -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,
|
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()))
|
kline.High.Float64(), kline.Low.Float64(), kline.Open.Float64(), kline.Close.Float64()))
|
||||||
placePrice := fixedpoint.Value(0)
|
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" {
|
if s.TradeType[symbol] == "long" {
|
||||||
placePrice = midPrice
|
placePrice = kline.Low
|
||||||
|
//placePrice = midP
|
||||||
} else if s.TradeType[symbol] == "short" {
|
} else if s.TradeType[symbol] == "short" {
|
||||||
placePrice = midPrice
|
placePrice = kline.High
|
||||||
|
//placePrice = midP
|
||||||
} else {
|
} else {
|
||||||
return orders, nil
|
return orders, nil
|
||||||
}
|
}
|
||||||
|
@ -360,12 +363,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] > 1 {
|
if s.TradeType[symbol] != "" && s.TradeRetry[symbol] > 10 {
|
||||||
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] <= 1 {
|
if s.TradeType[symbol] != "" && s.TradeRetry[symbol] <= 10 {
|
||||||
s.TradeRetry[symbol] = s.TradeRetry[symbol] + 1
|
s.TradeRetry[symbol] = s.TradeRetry[symbol] + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user