xfunding: add guard condition for starting and stopping

This commit is contained in:
c9s 2023-03-23 22:58:42 +08:00
parent e016892a70
commit 108bb5deeb
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -620,6 +620,10 @@ func (s *Strategy) detectPremiumIndex(premiumIndex *types.PremiumIndex) (changed
}
func (s *Strategy) startOpeningPosition(pt types.PositionType, t time.Time) {
if s.positionAction == PositionOpening {
return
}
s.positionAction = PositionOpening
s.positionType = pt
@ -630,6 +634,10 @@ func (s *Strategy) startOpeningPosition(pt types.PositionType, t time.Time) {
}
func (s *Strategy) startClosingPosition() {
if s.positionAction == PositionClosing {
return
}
s.positionAction = PositionClosing
// reset the transfer stats