grid2: fill fixedpoint.Zero for stats

This commit is contained in:
c9s 2022-12-04 21:43:40 +08:00
parent ec6b170f01
commit 19e0a20c67
3 changed files with 13 additions and 5 deletions

View File

@ -50,7 +50,7 @@ exchangeStrategies:
## triggerPrice is used for opening your grid only when the last price touches your pre-set 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
triggerPrice: 16_900.0
# triggerPrice: 16_900.0
stopLossPrice: 16_000.0

View File

@ -29,8 +29,16 @@ type GridProfitStats struct {
func newGridProfitStats(market types.Market) *GridProfitStats {
return &GridProfitStats{
Symbol: market.Symbol,
Market: market,
Symbol: market.Symbol,
TotalBaseProfit: fixedpoint.Zero,
TotalQuoteProfit: fixedpoint.Zero,
FloatProfit: fixedpoint.Zero,
GridProfit: fixedpoint.Zero,
ArbitrageCount: 0,
TotalFee: fixedpoint.Zero,
Volume: fixedpoint.Zero,
Market: market,
ProfitEntries: nil,
}
}

View File

@ -658,7 +658,7 @@ func (s *Strategy) openGrid(ctx context.Context, session *bbgo.ExchangeSession)
Quantity: quantity,
Market: s.Market,
TimeInForce: types.TimeInForceGTC,
Tag: "grid",
Tag: "grid2",
})
usedBase = usedBase.Add(quantity)
} else if i > 0 {
@ -674,7 +674,7 @@ func (s *Strategy) openGrid(ctx context.Context, session *bbgo.ExchangeSession)
Quantity: quantity,
Market: s.Market,
TimeInForce: types.TimeInForceGTC,
Tag: "grid",
Tag: "grid2",
})
quoteQuantity := quantity.Mul(price)
usedQuote = usedQuote.Add(quoteQuantity)