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:
Ryan O'Hara-Reid
2021-07-29 14:42:28 +10:00
committed by GitHub
parent 4f5ab42bd8
commit a2381310da
64 changed files with 842 additions and 562 deletions

View File

@@ -1358,13 +1358,16 @@ func TestAcceptOTCQuote(t *testing.T) {
func TestGetHistoricTrades(t *testing.T) {
t.Parallel()
assets := f.GetAssetTypes()
assets := f.GetAssetTypes(false)
for i := range assets {
enabledPairs, err := f.GetEnabledPairs(assets[i])
if err != nil {
t.Fatal(err)
}
_, err = f.GetHistoricTrades(enabledPairs.GetRandomPair(), assets[i], time.Now().Add(-time.Minute*15), time.Now())
_, err = f.GetHistoricTrades(enabledPairs.GetRandomPair(),
assets[i],
time.Now().Add(-time.Minute*15),
time.Now())
if err != nil {
t.Error(err)
}
@@ -1373,7 +1376,7 @@ func TestGetHistoricTrades(t *testing.T) {
func TestGetRecentTrades(t *testing.T) {
t.Parallel()
assets := f.GetAssetTypes()
assets := f.GetAssetTypes(false)
for i := range assets {
enabledPairs, err := f.GetEnabledPairs(assets[i])
if err != nil {

View File

@@ -174,7 +174,7 @@ func (f *FTX) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription, erro
Channel: wsMarkets,
})
var channels = []string{wsTicker, wsTrades, wsOrderbook}
assets := f.GetAssetTypes()
assets := f.GetAssetTypes(true)
for a := range assets {
pairs, err := f.GetEnabledPairs(assets[a])
if err != nil {

View File

@@ -281,7 +281,7 @@ func (f *FTX) FetchTradablePairs(a asset.Item) ([]string, error) {
// UpdateTradablePairs updates the exchanges available pairs and stores
// them in the exchanges config
func (f *FTX) UpdateTradablePairs(forceUpdate bool) error {
assets := f.GetAssetTypes()
assets := f.GetAssetTypes(false)
for x := range assets {
pairs, err := f.FetchTradablePairs(assets[x])
if err != nil {
@@ -396,25 +396,30 @@ func (f *FTX) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook
}
// UpdateAccountInfo retrieves balances for all enabled currencies
func (f *FTX) UpdateAccountInfo(assetType asset.Item) (account.Holdings, error) {
func (f *FTX) UpdateAccountInfo(a asset.Item) (account.Holdings, error) {
var resp account.Holdings
data, err := f.GetBalances()
// Get all wallet balances used so we can transfer between accounts if
// needed.
data, err := f.GetAllWalletBalances()
if err != nil {
return resp, err
}
var acc account.SubAccount
for i := range data {
c := currency.NewCode(data[i].Coin)
hold := data[i].Total - data[i].Free
total := data[i].Total
acc.Currencies = append(acc.Currencies,
account.Balance{CurrencyName: c,
TotalValue: total,
Hold: hold})
}
resp.Accounts = append(resp.Accounts, acc)
resp.Exchange = f.Name
for subName, balances := range data {
// "main" defines the main account in the sub account list
var acc = account.SubAccount{ID: subName, AssetType: a}
for x := range balances {
c := currency.NewCode(balances[x].Coin)
hold := balances[x].Total - balances[x].Free
acc.Currencies = append(acc.Currencies,
account.Balance{CurrencyName: c,
TotalValue: balances[x].Total,
Hold: hold})
}
resp.Accounts = append(resp.Accounts, acc)
}
resp.Exchange = f.Name
err = account.Process(&resp)
if err != nil {
return account.Holdings{}, err