mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xfunding: improve checkAndRestorePositionRisks
This commit is contained in:
parent
8257c4ffbe
commit
c437837210
|
@ -1027,12 +1027,21 @@ func (s *Strategy) checkAndRestorePositionRisks(ctx context.Context) error {
|
|||
}
|
||||
|
||||
for _, positionRisk := range positionRisks {
|
||||
if positionRisk.Symbol == s.Symbol {
|
||||
s.FuturesPosition.Base = positionRisk.PositionAmount
|
||||
s.FuturesPosition.AverageCost = positionRisk.EntryPrice
|
||||
if positionRisk.Symbol != s.Symbol {
|
||||
continue
|
||||
}
|
||||
|
||||
if positionRisk.PositionAmount.IsZero() || positionRisk.EntryPrice.IsZero() {
|
||||
continue
|
||||
}
|
||||
|
||||
s.FuturesPosition.Base = positionRisk.PositionAmount
|
||||
s.FuturesPosition.AverageCost = positionRisk.EntryPrice
|
||||
log.Infof("restored futures position from positionRisk: base=%s, average_cost=%s, position_risk=%+v",
|
||||
s.FuturesPosition.Base.String(),
|
||||
s.FuturesPosition.AverageCost.String(),
|
||||
positionRisk)
|
||||
}
|
||||
|
||||
log.Infof("positions: %+v", positionRisks)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user