mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
* Add exchange manager to engine
* Several improvements for engine and friends
1) New file.Exists func
2) gRPC TLS cert expiration date check and regeneration
3) New donation var for use across the codebase
4) Use Go log package until the logger is initialised
* Add cert tests and create dir tree if it doesn't exist for file.Write
* Link up donation address to documentation tool plus minor adjustments
* Fix remaining donation addrs
* Move non-needed reload exchange funcs
* Revert accidental config_example.json changes 🕯️
* Use go logger for logging until the logger has initiliased, otherwise no output will be seen
* Link up portfolio delay val and other fixes
* Run go mod tidy after dependabot PR
* Address nitterinos
53 lines
1.2 KiB
Go
53 lines
1.2 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.LoadExchange(name, true, &wg)
|
|
if err != nil {
|
|
log.Printf("Failed to load exchange %s. Err: %s", name, err)
|
|
continue
|
|
}
|
|
}
|
|
wg.Wait()
|
|
log.Println("Done.")
|
|
|
|
var cfgs []config.ExchangeConfig
|
|
exchanges := engine.GetExchanges()
|
|
for x := range exchanges {
|
|
var cfg *config.ExchangeConfig
|
|
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))
|
|
}
|