xfunding: implement CrossSubscribe

This commit is contained in:
c9s 2023-03-22 21:42:06 +08:00
parent b881aea228
commit d6c430a4b4
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -17,8 +17,10 @@ import (
const ID = "xfunding"
type PositionAction int
const (
PositionNoOp = iota
PositionNoOp PositionAction = iota
PositionOpening
PositionClosing
)
@ -81,6 +83,9 @@ type Strategy struct {
SpotSession string `json:"spotSession"`
FuturesSession string `json:"futuresSession"`
// positionAction is default to NoOp
positionAction PositionAction
}
func (s *Strategy) ID() string {
@ -88,8 +93,17 @@ func (s *Strategy) ID() string {
}
func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
// TODO implement me
panic("implement me")
// TODO: add safety check
spotSession := sessions[s.SpotSession]
futuresSession := sessions[s.FuturesSession]
spotSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{
Interval: types.Interval1m,
})
futuresSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{
Interval: types.Interval1m,
})
}
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {