mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
xfunding: use early return
This commit is contained in:
parent
300506f9f9
commit
0c6e9496b3
|
@ -718,16 +718,21 @@ func (s *Strategy) detectPremiumIndex(premiumIndex *types.PremiumIndex) bool {
|
|||
switch s.getPositionState() {
|
||||
|
||||
case PositionClosed:
|
||||
if fundingRate.Compare(s.ShortFundingRate.High) >= 0 {
|
||||
if fundingRate.Compare(s.ShortFundingRate.High) < 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
log.Infof("funding rate %s is higher than the High threshold %s, start opening position...",
|
||||
fundingRate.Percentage(), s.ShortFundingRate.High.Percentage())
|
||||
|
||||
s.startOpeningPosition(types.PositionShort, premiumIndex.Time)
|
||||
return true
|
||||
}
|
||||
|
||||
case PositionReady:
|
||||
if fundingRate.Compare(s.ShortFundingRate.Low) <= 0 {
|
||||
if fundingRate.Compare(s.ShortFundingRate.Low) > 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
log.Infof("funding rate %s is lower than the Low threshold %s, start closing position...",
|
||||
fundingRate.Percentage(), s.ShortFundingRate.Low.Percentage())
|
||||
|
||||
|
@ -740,7 +745,6 @@ func (s *Strategy) detectPremiumIndex(premiumIndex *types.PremiumIndex) bool {
|
|||
s.startClosingPosition()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user