xfunding: customize netural position profit

This commit is contained in:
c9s 2023-03-26 02:32:21 +08:00
parent f4a35132e8
commit e5d2db0f72
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -876,11 +876,12 @@ func (s *Strategy) allocateOrderExecutor(ctx context.Context, session *bbgo.Exch
bbgo.Sync(ctx, s) bbgo.Sync(ctx, s)
}) })
orderExecutor.TradeCollector().OnTrade(func(trade types.Trade, _ fixedpoint.Value, _ fixedpoint.Value) { orderExecutor.TradeCollector().OnTrade(func(trade types.Trade, _ fixedpoint.Value, _ fixedpoint.Value) {
s.ProfitStats.AddTrade(trade)
if profit, netProfit, madeProfit := s.NeutralPosition.AddTrade(trade); madeProfit { if profit, netProfit, madeProfit := s.NeutralPosition.AddTrade(trade); madeProfit {
_ = profit p := s.NeutralPosition.NewProfit(trade, profit, netProfit)
_ = netProfit s.ProfitStats.AddProfit(p)
} }
}) })
orderExecutor.BindProfitStats(s.ProfitStats.ProfitStats)
return orderExecutor return orderExecutor
} }