mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xfunding: pull out premium check to detectPremiumIndex
This commit is contained in:
parent
dc5e0cbcc2
commit
928f668fec
|
@ -206,8 +206,14 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
|
|||
return
|
||||
}
|
||||
|
||||
fundingRate := premiumIndex.LastFundingRate
|
||||
s.detectPremiumIndex(premiumIndex)
|
||||
}))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) detectPremiumIndex(premiumIndex *types.PremiumIndex) {
|
||||
fundingRate := premiumIndex.LastFundingRate
|
||||
if s.ShortFundingRate != nil {
|
||||
if fundingRate.Compare(s.ShortFundingRate.High) >= 0 {
|
||||
s.positionAction = PositionOpening
|
||||
|
@ -216,9 +222,6 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
|
|||
s.positionAction = PositionClosing
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) allocateOrderExecutor(ctx context.Context, session *bbgo.ExchangeSession, instanceID string, position *types.Position) *bbgo.GeneralOrderExecutor {
|
||||
|
|
Loading…
Reference in New Issue
Block a user