assign account and stream when allocating session object

This commit is contained in:
c9s 2020-10-21 17:42:37 +08:00
parent 1f71fa623c
commit b1a9a66dba
2 changed files with 3 additions and 2 deletions

View File

@ -38,6 +38,7 @@ type Environment struct {
sessions map[string]*ExchangeSession
}
// NewDefaultEnvironment prepares the exchange sessions from the viper settings.
func NewDefaultEnvironment(db *sqlx.DB) *Environment {
environment := NewEnvironment(db)
@ -89,8 +90,6 @@ func (environ *Environment) Init(ctx context.Context) (err error) {
}
session.markets = markets
session.Account = &types.Account{}
session.Stream = session.Exchange.NewStream()
}
return nil

View File

@ -37,6 +37,8 @@ func NewExchangeSession(name string, exchange types.Exchange) *ExchangeSession {
return &ExchangeSession{
Name: name,
Exchange: exchange,
Stream: exchange.NewStream(),
Account: &types.Account{},
Subscriptions: make(map[types.Subscription]types.Subscription),
markets: make(map[string]types.Market),
Trades: make(map[string][]types.Trade),