mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 15:10:19 +00:00
GCT: general updates across codebase (#699)
* orderbook: export orderbook nodes for external strategy inspection * orderbook: Add in methods for locking and unlocking multiple books at the same time e.g. book1.LockWith(book2); defer book1.UnlockWith(book2) * include waiting functionality for depth change alert * backtester: add word. * log: include logger changes to impl with downstream integration * engine: reduce params for loading exchange * assort: rm verbose in tests, change wording in ob, expose sync.waitgroup for ext. sync options * ticker: reduce map look ups and contention when using RW mutex when there are over 80% writes adds find last function to get the latest rate * engine/syncmanager: add in waitgroup for step over for external package calls * cleaup * engine: linter fix * currency/fx: include all references to fiat currencies to default * orderbook: Add in fields to Unsafe type for strategies to detect potential out of sync book operations * syncmanager: changed config variable to display correct time * ordermanager: Add time when none provided * currency/manager: update getasset param to get enabled assets for minor optimizations * ftx: use get all wallet balances for a better accounts breakdown * orderbook: unlock in reverse order * bithumb: fixes bug on market buy and sell orders * bithumb: fix bug for nonce is also time window sensitive * bithumb: get orders add required parameter * bithumb: Add asset type to account struct * currency: improve log output when checking currency and it fails * bithumb: Add error return on incomplete pair * ticker:unexport all service related methods * ticker/currency: fixes * orderbook: fix comment * engine: revert variable name in LoadExchange method * sync_manager: fix panic when enabling disabling manager * engine: fix naming convention of exported function and comments * engine: update comment * orderbook: fix comment for unsafe type
This commit is contained in:
@@ -705,8 +705,9 @@ func (bot *Engine) GetExchanges() []exchange.IBotExchange {
|
||||
return bot.ExchangeManager.GetExchanges()
|
||||
}
|
||||
|
||||
// LoadExchange loads an exchange by name
|
||||
func (bot *Engine) LoadExchange(name string, useWG bool, wg *sync.WaitGroup) error {
|
||||
// LoadExchange loads an exchange by name. Optional wait group can be added for
|
||||
// external synchronization.
|
||||
func (bot *Engine) LoadExchange(name string, wg *sync.WaitGroup) error {
|
||||
exch, err := bot.ExchangeManager.NewExchangeByName(name)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -728,7 +729,7 @@ func (bot *Engine) LoadExchange(name string, useWG bool, wg *sync.WaitGroup) err
|
||||
|
||||
if bot.Settings.EnableAllPairs &&
|
||||
exchCfg.CurrencyPairs != nil {
|
||||
assets := exchCfg.CurrencyPairs.GetAssetTypes()
|
||||
assets := exchCfg.CurrencyPairs.GetAssetTypes(false)
|
||||
for x := range assets {
|
||||
var pairs currency.Pairs
|
||||
pairs, err = exchCfg.CurrencyPairs.GetPairs(assets[x], false)
|
||||
@@ -797,7 +798,7 @@ func (bot *Engine) LoadExchange(name string, useWG bool, wg *sync.WaitGroup) err
|
||||
base := exch.GetBase()
|
||||
if base.API.AuthenticatedSupport ||
|
||||
base.API.AuthenticatedWebsocketSupport {
|
||||
assetTypes := base.GetAssetTypes()
|
||||
assetTypes := base.GetAssetTypes(false)
|
||||
var useAsset asset.Item
|
||||
for a := range assetTypes {
|
||||
err = base.CurrencyPairs.IsAssetEnabled(assetTypes[a])
|
||||
@@ -820,7 +821,7 @@ func (bot *Engine) LoadExchange(name string, useWG bool, wg *sync.WaitGroup) err
|
||||
}
|
||||
}
|
||||
|
||||
if useWG {
|
||||
if wg != nil {
|
||||
exch.Start(wg)
|
||||
} else {
|
||||
tempWG := sync.WaitGroup{}
|
||||
@@ -886,21 +887,20 @@ func (bot *Engine) SetupExchanges() error {
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
cfg := configs[x]
|
||||
go func(currCfg config.ExchangeConfig) {
|
||||
go func(c config.ExchangeConfig) {
|
||||
defer wg.Done()
|
||||
err := bot.LoadExchange(currCfg.Name, true, &wg)
|
||||
err := bot.LoadExchange(c.Name, &wg)
|
||||
if err != nil {
|
||||
gctlog.Errorf(gctlog.ExchangeSys, "LoadExchange %s failed: %s\n", currCfg.Name, err)
|
||||
gctlog.Errorf(gctlog.ExchangeSys, "LoadExchange %s failed: %s\n", c.Name, err)
|
||||
return
|
||||
}
|
||||
gctlog.Debugf(gctlog.ExchangeSys,
|
||||
"%s: Exchange support: Enabled (Authenticated API support: %s - Verbose mode: %s).\n",
|
||||
currCfg.Name,
|
||||
common.IsEnabled(currCfg.API.AuthenticatedSupport),
|
||||
common.IsEnabled(currCfg.Verbose),
|
||||
c.Name,
|
||||
common.IsEnabled(c.API.AuthenticatedSupport),
|
||||
common.IsEnabled(c.Verbose),
|
||||
)
|
||||
}(cfg)
|
||||
}(configs[x])
|
||||
}
|
||||
wg.Wait()
|
||||
if len(bot.ExchangeManager.GetExchanges()) == 0 {
|
||||
@@ -908,3 +908,9 @@ func (bot *Engine) SetupExchanges() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WaitForInitialCurrencySync allows for a routine to wait for the initial sync
|
||||
// of the currency pair syncer management system.
|
||||
func (bot *Engine) WaitForInitialCurrencySync() error {
|
||||
return bot.currencyPairSyncer.WaitForInitialSync()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user