mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xfunding: fix position sync bug
This commit is contained in:
parent
0efb56c43e
commit
7c975da575
|
@ -703,12 +703,19 @@ func (s *Strategy) syncFuturesPosition(ctx context.Context) {
|
|||
return
|
||||
}
|
||||
log.Infof("calculated futures account quote value = %s", quoteValue.String())
|
||||
if quoteValue.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// max futures base position (without negative sign)
|
||||
maxFuturesBasePosition := fixedpoint.Min(
|
||||
spotBase.Mul(s.Leverage),
|
||||
s.State.TotalBaseTransfer.Mul(s.Leverage))
|
||||
|
||||
if maxFuturesBasePosition.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// if - futures position < max futures position, increase it
|
||||
if futuresBase.Neg().Compare(maxFuturesBasePosition) >= 0 {
|
||||
s.setPositionState(PositionReady)
|
||||
|
|
Loading…
Reference in New Issue
Block a user