mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
grid2: call TruncatePrice on profitSpread
This commit is contained in:
parent
dd591c936f
commit
aa5f2a032a
|
@ -16,8 +16,8 @@ sessions:
|
||||||
# example command:
|
# example command:
|
||||||
# go run ./cmd/bbgo backtest --config config/grid2.yaml --base-asset-baseline
|
# go run ./cmd/bbgo backtest --config config/grid2.yaml --base-asset-baseline
|
||||||
backtest:
|
backtest:
|
||||||
startTime: "2022-06-01"
|
startTime: "2021-06-01"
|
||||||
endTime: "2022-06-30"
|
endTime: "2021-12-31"
|
||||||
symbols:
|
symbols:
|
||||||
- BTCUSDT
|
- BTCUSDT
|
||||||
sessions: [binance]
|
sessions: [binance]
|
||||||
|
@ -25,16 +25,16 @@ backtest:
|
||||||
binance:
|
binance:
|
||||||
balances:
|
balances:
|
||||||
BTC: 0.0
|
BTC: 0.0
|
||||||
USDT: 10000.0
|
USDT: 21_000.0
|
||||||
|
|
||||||
exchangeStrategies:
|
exchangeStrategies:
|
||||||
|
|
||||||
- on: binance
|
- on: binance
|
||||||
grid2:
|
grid2:
|
||||||
symbol: BTCUSDT
|
symbol: BTCUSDT
|
||||||
upperPrice: 15_000.0
|
upperPrice: 60_000.0
|
||||||
lowerPrice: 10_000.0
|
lowerPrice: 28_000.0
|
||||||
gridNumber: 10
|
gridNumber: 1000
|
||||||
|
|
||||||
## 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.
|
||||||
|
@ -45,14 +45,14 @@ exchangeStrategies:
|
||||||
## meaning that earn BTC instead of USDT when trading in the BTCUSDT pair.
|
## meaning that earn BTC instead of USDT when trading in the BTCUSDT pair.
|
||||||
# earnBase: true
|
# earnBase: true
|
||||||
|
|
||||||
## triggerPrice is used for opening your grid only when the last price touches your trigger price.
|
## triggerPrice (optional) is used for opening your grid only when the last price touches your trigger price.
|
||||||
## this is useful when you don't want to create a grid from a higher price.
|
## this is useful when you don't want to create a grid from a higher price.
|
||||||
## for example, when the last price hit 17_000.0 then open a grid with the price range 13_000 to 20_000
|
## for example, when the last price hit 17_000.0 then open a grid with the price range 13_000 to 20_000
|
||||||
triggerPrice: 17_000.0
|
# triggerPrice: 17_000.0
|
||||||
|
|
||||||
## triggerPrice is used for closing your grid only when the last price touches your stop loss price.
|
## triggerPrice (optional) is used for closing your grid only when the last price touches your stop loss price.
|
||||||
## for example, when the price drops to 17_000.0 then close the grid and sell all base inventory.
|
## for example, when the price drops to 17_000.0 then close the grid and sell all base inventory.
|
||||||
stopLossPrice: 10_000.0
|
# stopLossPrice: 10_000.0
|
||||||
|
|
||||||
## profitSpread is the profit spread of the arbitrage order (sell order)
|
## profitSpread is the profit spread of the arbitrage order (sell order)
|
||||||
## greater the profitSpread, greater the profit you make when the sell order is filled.
|
## greater the profitSpread, greater the profit you make when the sell order is filled.
|
||||||
|
@ -73,12 +73,20 @@ exchangeStrategies:
|
||||||
## 3) quoteInvestment and baseInvestment: when using quoteInvestment, the strategy will automatically calculate your best quantity for the whole grid.
|
## 3) quoteInvestment and baseInvestment: when using quoteInvestment, the strategy will automatically calculate your best quantity for the whole grid.
|
||||||
## quoteInvestment is required, and baseInvestment is optional (could be zero)
|
## quoteInvestment is required, and baseInvestment is optional (could be zero)
|
||||||
## if you have existing BTC position and want to reuse it you can set the baseInvestment.
|
## if you have existing BTC position and want to reuse it you can set the baseInvestment.
|
||||||
quoteInvestment: 10_000
|
quoteInvestment: 20_000
|
||||||
|
|
||||||
## baseInvestment is optional
|
## baseInvestment (optional) can be useful when you have existing inventory, maybe bought at much lower price
|
||||||
baseInvestment: 0.0
|
baseInvestment: 0.0
|
||||||
|
|
||||||
|
## closeWhenCancelOrder (optional)
|
||||||
|
## default to false
|
||||||
closeWhenCancelOrder: true
|
closeWhenCancelOrder: true
|
||||||
|
|
||||||
|
## resetPositionWhenStart (optional)
|
||||||
|
## default to false
|
||||||
resetPositionWhenStart: false
|
resetPositionWhenStart: false
|
||||||
|
|
||||||
|
## clearOpenOrdersWhenStart (optional)
|
||||||
|
## default to false
|
||||||
clearOpenOrdersWhenStart: false
|
clearOpenOrdersWhenStart: false
|
||||||
keepOrdersWhenShutdown: false
|
keepOrdersWhenShutdown: false
|
||||||
|
|
|
@ -931,6 +931,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
s.groupID = util.FNV32(instanceID)
|
s.groupID = util.FNV32(instanceID)
|
||||||
s.logger.Infof("using group id %d from fnv(%s)", s.groupID, instanceID)
|
s.logger.Infof("using group id %d from fnv(%s)", s.groupID, instanceID)
|
||||||
|
|
||||||
|
if s.ProfitSpread.Sign() > 0 {
|
||||||
|
s.ProfitSpread = s.Market.TruncatePrice(s.ProfitSpread)
|
||||||
|
}
|
||||||
|
|
||||||
if s.GridProfitStats == nil {
|
if s.GridProfitStats == nil {
|
||||||
s.GridProfitStats = newGridProfitStats(s.Market)
|
s.GridProfitStats = newGridProfitStats(s.Market)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user