grid2: remove default profit stats

This commit is contained in:
c9s 2022-12-26 01:24:56 +08:00
parent 0a6261b6b9
commit 6444fd5e03
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -115,9 +115,8 @@ type Strategy struct {
SkipSpreadCheck bool `json:"skipSpreadCheck"` SkipSpreadCheck bool `json:"skipSpreadCheck"`
GridProfitStats *GridProfitStats `persistence:"grid_profit_stats"` GridProfitStats *GridProfitStats `persistence:"grid_profit_stats"`
ProfitStats *types.ProfitStats `persistence:"profit_stats"` Position *types.Position `persistence:"position"`
Position *types.Position `persistence:"position"`
grid *Grid grid *Grid
session *bbgo.ExchangeSession session *bbgo.ExchangeSession
@ -1251,10 +1250,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.GridProfitStats = newGridProfitStats(s.Market) s.GridProfitStats = newGridProfitStats(s.Market)
} }
if s.ProfitStats == nil {
s.ProfitStats = types.NewProfitStats(s.Market)
}
if s.Position == nil { if s.Position == nil {
s.Position = types.NewPositionFromMarket(s.Market) s.Position = types.NewPositionFromMarket(s.Market)
} }
@ -1276,7 +1271,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
orderExecutor := bbgo.NewGeneralOrderExecutor(session, s.Symbol, ID, instanceID, s.Position) orderExecutor := bbgo.NewGeneralOrderExecutor(session, s.Symbol, ID, instanceID, s.Position)
orderExecutor.BindEnvironment(s.Environment) orderExecutor.BindEnvironment(s.Environment)
orderExecutor.BindProfitStats(s.ProfitStats)
orderExecutor.Bind() orderExecutor.Bind()
orderExecutor.TradeCollector().OnTrade(func(trade types.Trade, _, _ fixedpoint.Value) { orderExecutor.TradeCollector().OnTrade(func(trade types.Trade, _, _ fixedpoint.Value) {
s.GridProfitStats.AddTrade(trade) s.GridProfitStats.AddTrade(trade)