pkg/bbgo, pkg/types: add new interface PrivateChannelSymbolSetter

This commit is contained in:
Edwin 2023-11-14 11:22:42 +08:00
parent 580c6d2030
commit 720fe2e12e
2 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,10 @@ type ExchangeSession struct {
// This option is exchange specific
PrivateChannels []string `json:"privateChannels,omitempty" yaml:"privateChannels,omitempty"`
// PrivateChannelSymbols is used for filtering the private user data channel, .e.g, order symbol subscription.
// This option is exchange specific
PrivateChannelSymbols []string `json:"privateChannelSymbols,omitempty" yaml:"privateChannelSymbols,omitempty"`
Margin bool `json:"margin,omitempty" yaml:"margin"`
IsolatedMargin bool `json:"isolatedMargin,omitempty" yaml:"isolatedMargin,omitempty"`
IsolatedMarginSymbol string `json:"isolatedMarginSymbol,omitempty" yaml:"isolatedMarginSymbol,omitempty"`
@ -248,6 +252,11 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
setter.SetPrivateChannels(session.PrivateChannels)
}
}
if len(session.PrivateChannelSymbols) > 0 {
if setter, ok := session.UserDataStream.(types.PrivateChannelSymbolSetter); ok {
setter.SetPrivateChannelSymbols(session.PrivateChannelSymbols)
}
}
logger.Infof("querying account balances...")
account, err := session.Exchange.QueryAccount(ctx)

View File

@ -46,6 +46,10 @@ type PrivateChannelSetter interface {
SetPrivateChannels(channels []string)
}
type PrivateChannelSymbolSetter interface {
SetPrivateChannelSymbols(symbols []string)
}
type Unsubscriber interface {
// Unsubscribe unsubscribes the all subscriptions.
Unsubscribe()