mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 15:09:51 +00:00
* Exchanges: Remove Pair upgrade handling Now redundant behind #1401. These paths should never be met. Several legacy coin upgrade paths being deprecated as well: ZUSD and CNY Expecting any users with bad config from 3+ years ago would have to reset anyway. Also: At the time the intention of this was to upgrade the config format. However now, instead, it'd mostly serve to reset enabled pairs if there's a config mistake, which doesn't feel right. * Kraken: Fix typo in Kraken type struct * Exchanges: Abstract exchange Start() and Run() * Exchanges: Add test for abstracted Start * Exchanges: Move Start to Bootstrap * Simplify waitgroup usage * Add call to exchange.Bootstrap to allow overide or supplementation * Exchanges: Concurrent common bootstap actions * Gateio: Remove incorrect Run in test * GateIO: Fix pair dependencies in tests This ensures that the pairs are initialised no more than needed and kind-of just-in-time. Better pattern might be to use a function to get these pairs when we need them. * Exchanges: Complete UpdatePairs before ExecLims If we're going to update pairs, it needs to complete before we check for limits to avoid errors on old pairs * Exchanges: Remove Start and Run from tmpl Since they're replaced by bootstrap now and shouldn't need customisation normally * Alphapoint: Move Start to Bootstrap * GateIO: Fix linter shadow var
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"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 i := range exchange.Exchanges {
|
|
wg.Add(1)
|
|
go func(name string) {
|
|
defer wg.Done()
|
|
if err = engine.Bot.LoadExchange(name); err != nil {
|
|
log.Printf("Failed to load exchange %s. Err: %s", name, err)
|
|
}
|
|
}(exchange.Exchanges[i])
|
|
}
|
|
wg.Wait()
|
|
log.Println("Done.")
|
|
|
|
exchanges := engine.Bot.GetExchanges()
|
|
cfgs := make([]config.Exchange, 0, len(exchanges))
|
|
for x := range exchanges {
|
|
var cfg *config.Exchange
|
|
cfg, err = exchanges[x].GetDefaultConfig(context.Background())
|
|
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))
|
|
}
|