mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 15:09:51 +00:00
* stream: add exchange config pointer to setup WebsocketSetup struct to reduce and consolidate setting of variables. * config: reduce stutter * config: reduce minor stutter * glorious: nits addr. * Update exchanges/stream/websocket.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * websocket: implement fix * engine/helpers: fix test * exchanges: fix after merge issues * exchange_template: fix output Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"sync"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
"github.com/thrasher-corp/gocryptotrader/engine"
|
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
|
)
|
|
|
|
func main() {
|
|
var err error
|
|
engine.Bot, err = engine.New()
|
|
if err != nil {
|
|
log.Fatalf("Failed to initialise engine. Err: %s", err)
|
|
}
|
|
|
|
log.Printf("Loading exchanges..")
|
|
var wg sync.WaitGroup
|
|
for x := range exchange.Exchanges {
|
|
name := exchange.Exchanges[x]
|
|
err = engine.Bot.LoadExchange(name, &wg)
|
|
if err != nil {
|
|
log.Printf("Failed to load exchange %s. Err: %s", name, err)
|
|
continue
|
|
}
|
|
}
|
|
wg.Wait()
|
|
log.Println("Done.")
|
|
|
|
var cfgs []config.Exchange
|
|
exchanges := engine.Bot.GetExchanges()
|
|
for x := range exchanges {
|
|
var cfg *config.Exchange
|
|
cfg, err = exchanges[x].GetDefaultConfig()
|
|
if err != nil {
|
|
log.Printf("Failed to get exchanges default config. Err: %s", err)
|
|
continue
|
|
}
|
|
log.Printf("Adding %s", exchanges[x].GetName())
|
|
cfgs = append(cfgs, *cfg)
|
|
}
|
|
|
|
data, err := json.MarshalIndent(cfgs, "", " ")
|
|
if err != nil {
|
|
log.Fatalf("Unable to marshal cfgs. Err: %s", err)
|
|
}
|
|
|
|
log.Println(string(data))
|
|
}
|