mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
xfunding: pull out interval option
This commit is contained in:
parent
6349566ce9
commit
ff35fd06c4
|
@ -94,7 +94,9 @@ type Strategy struct {
|
||||||
Environment *bbgo.Environment
|
Environment *bbgo.Environment
|
||||||
|
|
||||||
// These fields will be filled from the config file (it translates YAML to JSON)
|
// These fields will be filled from the config file (it translates YAML to JSON)
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
|
Interval types.Interval `json:"interval"`
|
||||||
|
|
||||||
Market types.Market `json:"-"`
|
Market types.Market `json:"-"`
|
||||||
|
|
||||||
// Leverage is the leverage of the futures position
|
// Leverage is the leverage of the futures position
|
||||||
|
@ -158,13 +160,8 @@ func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
|
||||||
spotSession := sessions[s.SpotSession]
|
spotSession := sessions[s.SpotSession]
|
||||||
futuresSession := sessions[s.FuturesSession]
|
futuresSession := sessions[s.FuturesSession]
|
||||||
|
|
||||||
spotSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{
|
spotSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: s.Interval})
|
||||||
Interval: types.Interval1m,
|
futuresSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: s.Interval})
|
||||||
})
|
|
||||||
|
|
||||||
futuresSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{
|
|
||||||
Interval: types.Interval1m,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {}
|
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {}
|
||||||
|
@ -178,6 +175,10 @@ func (s *Strategy) Defaults() error {
|
||||||
s.MinHoldingPeriod = types.Duration(3 * 24 * time.Hour)
|
s.MinHoldingPeriod = types.Duration(3 * 24 * time.Hour)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.Interval == "" {
|
||||||
|
s.Interval = types.Interval1m
|
||||||
|
}
|
||||||
|
|
||||||
s.positionType = types.PositionShort
|
s.positionType = types.PositionShort
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -364,7 +365,7 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
s.futuresSession.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) {
|
s.futuresSession.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) {
|
||||||
s.queryAndDetectPremiumIndex(ctx, binanceFutures)
|
s.queryAndDetectPremiumIndex(ctx, binanceFutures)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user