mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
refactor and add doc comment for InitExchangeSession
This commit is contained in:
parent
307d0b8e1f
commit
ba8ebfe3a7
|
@ -213,7 +213,7 @@ func (environ *Environment) AddExchangesByViperKeys() error {
|
|||
|
||||
func (environ *Environment) AddExchangesFromSessionConfig(sessions map[string]*ExchangeSession) error {
|
||||
for sessionName, session := range sessions {
|
||||
if err := InitExchangeSession(sessionName, session, nil); err != nil {
|
||||
if err := session.InitExchange(sessionName, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -683,7 +683,10 @@ func (session *ExchangeSession) FindPossibleSymbols() (symbols []string, err err
|
|||
return symbols, nil
|
||||
}
|
||||
|
||||
func InitExchangeSession(name string, session *ExchangeSession, exchange types.Exchange) error {
|
||||
// InitExchange initialize the exchange instance and allocate memory for fields
|
||||
// In this stage, the session var could be loaded from the JSON config, so the pointer fields are still nil
|
||||
// The Init method will be called after this stage, environment.Init will call the session.Init method later.
|
||||
func (session *ExchangeSession) InitExchange(name string, exchange types.Exchange) error {
|
||||
var err error
|
||||
var exchangeName = session.ExchangeName
|
||||
if exchange == nil {
|
||||
|
|
|
@ -133,7 +133,7 @@ func (s *Server) newEngine() *gin.Engine {
|
|||
return
|
||||
}
|
||||
|
||||
err := bbgo.InitExchangeSession(session.ExchangeName.String(), &session, nil)
|
||||
err := session.InitExchange(session.ExchangeName.String(), nil)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
|
@ -182,7 +182,7 @@ func (s *Server) newEngine() *gin.Engine {
|
|||
return
|
||||
}
|
||||
|
||||
if err := bbgo.InitExchangeSession(session.ExchangeName.String(), &session, nil); err != nil {
|
||||
if err := session.InitExchange(session.ExchangeName.String(), nil); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user