mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix/bollmaker: fix s.MinProfitActivationRate condition
This commit is contained in:
parent
ca4890425c
commit
0a6c41cfe7
|
@ -85,7 +85,7 @@ type Strategy struct {
|
|||
// MinProfitActivationRate activates MinProfitSpread when position RoI higher than the specified percentage
|
||||
MinProfitActivationRate *fixedpoint.Value `json:"minProfitActivationRate"`
|
||||
|
||||
// UseTickerPrice use the ticker api to get the mid price instead of the closed kline price.
|
||||
// UseTickerPrice use the ticker api to get the mid-price instead of the closed kline price.
|
||||
// The back-test engine is kline-based, so the ticker price api is not supported.
|
||||
// Turn this on if you want to do real trading.
|
||||
UseTickerPrice bool `json:"useTickerPrice"`
|
||||
|
@ -336,7 +336,7 @@ func (s *Strategy) placeOrders(ctx context.Context, midPrice fixedpoint.Value, k
|
|||
|
||||
// Apply quantity skew
|
||||
// CASE #1:
|
||||
// WHEN: price is in the neutral bollginer band (window 1) == neutral
|
||||
// WHEN: price is in the neutral bollinger band (window 1) == neutral
|
||||
// THEN: we don't apply skew
|
||||
// CASE #2:
|
||||
// WHEN: price is in the upper band (window 2 > price > window 1) == upTrend
|
||||
|
@ -385,7 +385,7 @@ func (s *Strategy) placeOrders(ctx context.Context, midPrice fixedpoint.Value, k
|
|||
isLongPosition := s.Position.IsLong()
|
||||
isShortPosition := s.Position.IsShort()
|
||||
|
||||
if s.MinProfitActivationRate == nil || s.Position.ROI(midPrice).Compare(*s.MinProfitActivationRate) >= 0 {
|
||||
if s.MinProfitActivationRate == nil || (s.MinProfitActivationRate != nil && s.Position.ROI(midPrice).Compare(*s.MinProfitActivationRate) >= 0) {
|
||||
minProfitPrice := s.Position.AverageCost.Mul(fixedpoint.One.Add(s.MinProfitSpread))
|
||||
if isShortPosition {
|
||||
minProfitPrice = s.Position.AverageCost.Mul(fixedpoint.One.Sub(s.MinProfitSpread))
|
||||
|
|
Loading…
Reference in New Issue
Block a user