mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
xfunding: customize netural position profit
This commit is contained in:
parent
f4a35132e8
commit
e5d2db0f72
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user