mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
grid2: add doc comment for gridNumber
This commit is contained in:
parent
c2e219e180
commit
68e7d0ec24
|
@ -35,9 +35,13 @@ exchangeStrategies:
|
||||||
- on: binance
|
- on: binance
|
||||||
grid2:
|
grid2:
|
||||||
symbol: BTCUSDT
|
symbol: BTCUSDT
|
||||||
upperPrice: 50_000.0
|
|
||||||
lowerPrice: 28_000.0
|
lowerPrice: 28_000.0
|
||||||
gridNumber: 1000
|
upperPrice: 50_000.0
|
||||||
|
|
||||||
|
## gridNumber is the total orders between the upper price and the lower price
|
||||||
|
## gridSpread = (upperPrice - lowerPrice) / gridNumber
|
||||||
|
## Make sure your gridNumber satisfy this: MIN(gridSpread/lowerPrice, gridSpread/upperPrice) > (makerFeeRate * 2)
|
||||||
|
gridNumber: 150
|
||||||
|
|
||||||
## compound is used for buying more inventory when the profit is made by the filled SELL order.
|
## compound is used for buying more inventory when the profit is made by the filled SELL order.
|
||||||
## when compound is disabled, fixed quantity is used for each grid order.
|
## when compound is disabled, fixed quantity is used for each grid order.
|
||||||
|
|
|
@ -131,12 +131,15 @@ func (s *Strategy) Validate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !s.ProfitSpread.IsZero() {
|
if !s.ProfitSpread.IsZero() {
|
||||||
percent := s.ProfitSpread.Div(s.LowerPrice)
|
// the min fee rate from 2 maker/taker orders (with 0.1 rate for profit)
|
||||||
|
gridFeeRate := s.FeeRate.Mul(fixedpoint.NewFromFloat(2.01))
|
||||||
|
|
||||||
// the min fee rate from 2 maker/taker orders
|
if s.ProfitSpread.Div(s.LowerPrice).Compare(gridFeeRate) < 0 {
|
||||||
minProfitSpread := s.FeeRate.Mul(fixedpoint.NewFromInt(2))
|
return fmt.Errorf("profitSpread %f %s is too small for lower price, less than the fee rate: %s", s.ProfitSpread.Float64(), s.ProfitSpread.Div(s.LowerPrice).Percentage(), s.FeeRate.Percentage())
|
||||||
if percent.Compare(minProfitSpread) < 0 {
|
}
|
||||||
return fmt.Errorf("profitSpread %f %s is too small, less than the fee rate: %s", s.ProfitSpread.Float64(), percent.Percentage(), s.FeeRate.Percentage())
|
|
||||||
|
if s.ProfitSpread.Div(s.UpperPrice).Compare(gridFeeRate) < 0 {
|
||||||
|
return fmt.Errorf("profitSpread %f %s is too small for upper price, less than the fee rate: %s", s.ProfitSpread.Float64(), s.ProfitSpread.Div(s.UpperPrice).Percentage(), s.FeeRate.Percentage())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user