From e5d2db0f72d1e0ddd2aa5dca0a936cbba2dcbfe6 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 26 Mar 2023 02:32:21 +0800 Subject: [PATCH] xfunding: customize netural position profit --- pkg/strategy/xfunding/strategy.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/strategy/xfunding/strategy.go b/pkg/strategy/xfunding/strategy.go index c4f5589cd..57c8f9f25 100644 --- a/pkg/strategy/xfunding/strategy.go +++ b/pkg/strategy/xfunding/strategy.go @@ -876,11 +876,12 @@ func (s *Strategy) allocateOrderExecutor(ctx context.Context, session *bbgo.Exch bbgo.Sync(ctx, s) }) orderExecutor.TradeCollector().OnTrade(func(trade types.Trade, _ fixedpoint.Value, _ fixedpoint.Value) { + s.ProfitStats.AddTrade(trade) + if profit, netProfit, madeProfit := s.NeutralPosition.AddTrade(trade); madeProfit { - _ = profit - _ = netProfit + p := s.NeutralPosition.NewProfit(trade, profit, netProfit) + s.ProfitStats.AddProfit(p) } }) - orderExecutor.BindProfitStats(s.ProfitStats.ProfitStats) return orderExecutor }