mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
* Currency: Do not use a default forex provider exchangerate.host now requires an API key. Instead of finding a new Free (for now) default, this change simply disables the currency exchange when nothing is enabled. * SyncManager: Report ?.?? for an unknown forex amount In a situation where we thought forex was available but we got an error, this avoids showing 0.00 when there was actually an error. * Currency: Tests for no default forex * Currency: Use mock provider for tests * Currency: Add API key to exchangerate.host * Currency: Remove Exchangerate.host Exchangerate.host was bought by apilayer, the old API deprecated, and replaced with a proxy to the apilayer api. We already have currencylayer support, so ther's no reason to keep exh. Worth noting: New ERH keys actually work on currencylayer * Currencies: Add test coverage for currency layer * fixup! Currency: Tests for no default forex Remove duplicate assignment Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395#discussion_r1395178513) * fixup! Currency: Add API key to exchangerate.host Remove unused ErrVar Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395#discussion_r1396647418) * fixup! Currency: Tests for no default forex Fix spelling of override in test Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395#discussion_r1396701476) * fixup! SyncManager: Report ?.?? for an unknown forex amount Fix display of non-positive currency conversions. Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395/files#r1398527134)
133 lines
4.2 KiB
Go
133 lines
4.2 KiB
Go
package engine
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
// Settings stores engine params. Please define a settings struct for automatic
|
|
// display of instance settings. For example, if you define a struct named
|
|
// ManagerSettings, it will be displayed as a subheading "Manager Settings"
|
|
// and individual field names such as 'EnableManager' will be displayed
|
|
// as "Enable Manager: true/false".
|
|
type Settings struct {
|
|
ConfigFile string
|
|
DataDir string
|
|
MigrationDir string
|
|
LogFile string
|
|
GoMaxProcs int
|
|
CheckParamInteraction bool
|
|
|
|
CoreSettings
|
|
ExchangeSyncerSettings
|
|
ForexSettings
|
|
ExchangeTuningSettings
|
|
GCTScriptSettings
|
|
WithdrawSettings
|
|
|
|
// Main shutdown channel
|
|
Shutdown chan struct{}
|
|
}
|
|
|
|
// CoreSettings defines settings related to core engine operations
|
|
type CoreSettings struct {
|
|
EnableDryRun bool
|
|
EnableAllExchanges bool
|
|
EnableAllPairs bool
|
|
EnableCoinmarketcapAnalysis bool
|
|
EnablePortfolioManager bool
|
|
EnableDataHistoryManager bool
|
|
PortfolioManagerDelay time.Duration
|
|
EnableGRPC bool
|
|
EnableGRPCProxy bool
|
|
EnableGRPCShutdown bool
|
|
EnableWebsocketRPC bool
|
|
EnableDeprecatedRPC bool
|
|
EnableCommsRelayer bool
|
|
EnableExchangeSyncManager bool
|
|
EnableDepositAddressManager bool
|
|
EnableEventManager bool
|
|
EnableOrderManager bool
|
|
EnableConnectivityMonitor bool
|
|
EnableDatabaseManager bool
|
|
EnableGCTScriptManager bool
|
|
EnableNTPClient bool
|
|
EnableWebsocketRoutine bool
|
|
EnableCurrencyStateManager bool
|
|
EventManagerDelay time.Duration
|
|
EnableFuturesTracking bool
|
|
Verbose bool
|
|
EnableDispatcher bool
|
|
DispatchMaxWorkerAmount int
|
|
DispatchJobsLimit int
|
|
}
|
|
|
|
// ExchangeSyncerSettings defines settings for the exchange pair synchronisation
|
|
type ExchangeSyncerSettings struct {
|
|
EnableTickerSyncing bool
|
|
EnableOrderbookSyncing bool
|
|
EnableTradeSyncing bool
|
|
SyncWorkersCount int
|
|
SyncContinuously bool
|
|
SyncTimeoutREST time.Duration
|
|
SyncTimeoutWebsocket time.Duration
|
|
}
|
|
|
|
// ForexSettings defines settings related to the foreign exchange services
|
|
type ForexSettings struct {
|
|
EnableCurrencyConverter bool
|
|
EnableCurrencyLayer bool
|
|
EnableExchangeRates bool
|
|
EnableFixer bool
|
|
EnableOpenExchangeRates bool
|
|
}
|
|
|
|
// ExchangeTuningSettings defines settings related to an exchange
|
|
type ExchangeTuningSettings struct {
|
|
EnableExchangeHTTPRateLimiter bool
|
|
EnableExchangeHTTPDebugging bool
|
|
EnableExchangeVerbose bool
|
|
ExchangePurgeCredentials bool
|
|
EnableExchangeAutoPairUpdates bool
|
|
DisableExchangeAutoPairUpdates bool
|
|
EnableExchangeRESTSupport bool
|
|
EnableExchangeWebsocketSupport bool
|
|
MaxHTTPRequestJobsLimit int
|
|
TradeBufferProcessingInterval time.Duration
|
|
RequestMaxRetryAttempts int
|
|
AlertSystemPreAllocationCommsBuffer int // See exchanges/alert.go
|
|
ExchangeShutdownTimeout time.Duration
|
|
HTTPTimeout time.Duration
|
|
HTTPUserAgent string
|
|
HTTPProxy string
|
|
GlobalHTTPTimeout time.Duration
|
|
GlobalHTTPUserAgent string
|
|
GlobalHTTPProxy string
|
|
}
|
|
|
|
// GCTScriptSettings defines settings related to the GCTScript virtual machine
|
|
type GCTScriptSettings struct {
|
|
MaxVirtualMachines uint
|
|
}
|
|
|
|
// WithdrawSettings defines settings related to Withdrawing cryptocurrency
|
|
type WithdrawSettings struct {
|
|
WithdrawCacheSize uint64
|
|
}
|
|
|
|
const (
|
|
// MsgStatusOK message to display when status is "OK"
|
|
MsgStatusOK string = "ok"
|
|
// MsgStatusSuccess message to display when status is successful
|
|
MsgStatusSuccess string = "success"
|
|
// MsgStatusError message to display when failure occurs
|
|
MsgStatusError string = "error"
|
|
grpcName string = "grpc"
|
|
grpcProxyName string = "grpc_proxy"
|
|
)
|
|
|
|
// newConfigMutex only locks and unlocks on engine creation functions
|
|
// as engine modifies global files, this protects the main bot creation
|
|
// functions from interfering with each other
|
|
var newEngineMutex sync.Mutex
|