mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
xdepthmaker: adjust covered position when order is canceled
This commit is contained in:
parent
60d5126b61
commit
329b8a40d9
|
@ -148,6 +148,16 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
||||||
// bbgo.Sync(ctx, s)
|
// bbgo.Sync(ctx, s)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
s.HedgeOrderExecutor.ActiveMakerOrders().OnCanceled(func(o types.Order) {
|
||||||
|
remaining := o.Quantity.Sub(o.ExecutedQuantity)
|
||||||
|
switch o.Side {
|
||||||
|
case types.SideTypeSell:
|
||||||
|
remaining = remaining.Neg()
|
||||||
|
}
|
||||||
|
|
||||||
|
s.CoveredPosition.Sub(remaining)
|
||||||
|
})
|
||||||
|
|
||||||
s.HedgeOrderExecutor.TradeCollector().OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) {
|
s.HedgeOrderExecutor.TradeCollector().OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) {
|
||||||
c := trade.PositionChange()
|
c := trade.PositionChange()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user