diff --git a/config/ccinr.yaml b/config/ccinr.yaml index 272b74f..cc3183e 100644 --- a/config/ccinr.yaml +++ b/config/ccinr.yaml @@ -55,6 +55,8 @@ exchangeStrategies: placePriceType: 2 lossType: 1 profitOrderType: 0 + atrProfitRange: 0.8 + atrLossRange: 1.0 # recalculate: false # dry_run: false # # quantity: 3 diff --git a/pkg/strategy/ccinr/strategy.go b/pkg/strategy/ccinr/strategy.go index cce2bd9..9e31b41 100644 --- a/pkg/strategy/ccinr/strategy.go +++ b/pkg/strategy/ccinr/strategy.go @@ -47,6 +47,8 @@ type Strategy struct { Leverage fixedpoint.Value `json:"leverage"` ProfitRange fixedpoint.Value `json:"profitRange"` LossRange fixedpoint.Value `json:"lossRange"` + AtrProfitRange float64 `json:"atrProfitRange"` + AtrLossRange float64 `json:"atrLossRange"` qbtrade.QuantityOrAmount @@ -221,16 +223,16 @@ func (s *Strategy) generateOrders(ctx context.Context, kline types.KLine) ([]typ lossPrice = placePrice.Sub(placePrice.Mul(s.LossRange)) profitPrice = placePrice.Add(placePrice.Mul(s.ProfitRange)) } else if s.LossType == 1 { - lossPrice = placePrice.Sub(fixedpoint.Value(1e8 * lastATR)) - profitPrice = placePrice.Add(fixedpoint.Value(1e8 * lastATR * 2)) + lossPrice = placePrice.Sub(fixedpoint.Value(1e8 * lastATR * s.AtrLossRange)) + profitPrice = placePrice.Add(fixedpoint.Value(1e8 * lastATR * s.AtrProfitRange)) } } else if s.TradeType[symbol] == "short" { if s.LossType == 0 || s.atr[symbol].Last(0) == 0.0 { lossPrice = placePrice.Add(placePrice.Mul(s.LossRange)) profitPrice = placePrice.Sub(placePrice.Mul(s.ProfitRange)) } else if s.LossType == 1 { - lossPrice = placePrice.Add(fixedpoint.Value(1e8 * lastATR)) - profitPrice = placePrice.Sub(fixedpoint.Value(1e8 * lastATR * 2)) + lossPrice = placePrice.Add(fixedpoint.Value(1e8 * lastATR * s.AtrLossRange)) + profitPrice = placePrice.Sub(fixedpoint.Value(1e8 * lastATR * s.AtrProfitRange)) } }