exchanges/wrappers: Refactor fetch orderbook/ticker/account info funcs (#1440)

* acrost: Pull thread, examine

* fix tests

* linter

* fix_linter

* revert rm ctx param to limit breakages when merging usptream

* linter fix

* Add in priority update grouping so that tests pass

* Update cmd/exchange_wrapper_standards/exchange_wrapper_standards_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious nits

* fixed spelling

* whoopsie

* aanother whoops

* glorious: NITTERS!

* glorious: further nitters

* srry linter gods

* glorious: nits continued

* sub test p ara lel

* drop main t.Parallel

* fix whoops

* wrappertests: use context with cancel (test)

* linter: fix

* ensure primary execution

* kucoin test fix

* revert standards test changes and bypass non critical errors

* rm single override

* wrap exported error for accounts

* thrasher: nits ch name

* gk: nits

* gk: nits FetchTickerCached -> GetCachedTicker

* gk: nits rn FetchOrderbookCached -> GetCachedOrderbook

* gk: nits rn FetchAccountInfoCached -> GetCachedAccountInfo

* linter: fix

* gk: nits

* thrasher: nitters 1

* thrasher: nitters tmpls

* gk: nitter

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2025-02-19 10:47:10 +11:00
committed by GitHub
parent 2fc7e8e3e3
commit 08e015a125
122 changed files with 545 additions and 1962 deletions

View File

@@ -349,20 +349,6 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
log.Printf("Executing wrappers for %v %v %v", base.GetName(), assetTypes[i], p)
if !authenticatedOnly {
var fetchTickerResponse *ticker.Price
fetchTickerResponse, err = e.FetchTicker(context.TODO(), p, assetTypes[i])
msg = ""
if err != nil {
msg = err.Error()
responseContainer.ErrorCount++
}
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
SentParams: jsonifyInterface([]interface{}{p, assetTypes[i]}),
Function: "FetchTicker",
Error: msg,
Response: jsonifyInterface([]interface{}{fetchTickerResponse}),
})
var updateTickerResponse *ticker.Price
updateTickerResponse, err = e.UpdateTicker(context.TODO(), p, assetTypes[i])
msg = ""
@@ -377,8 +363,8 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
Response: jsonifyInterface([]interface{}{updateTickerResponse}),
})
var fetchOrderbookResponse *orderbook.Base
fetchOrderbookResponse, err = e.FetchOrderbook(context.TODO(), p, assetTypes[i])
var GetCachedTickerResponse *ticker.Price
GetCachedTickerResponse, err = e.GetCachedTicker(p, assetTypes[i])
msg = ""
if err != nil {
msg = err.Error()
@@ -386,9 +372,9 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
}
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
SentParams: jsonifyInterface([]interface{}{p, assetTypes[i]}),
Function: "FetchOrderbook",
Function: "GetCachedTicker",
Error: msg,
Response: jsonifyInterface([]interface{}{fetchOrderbookResponse}),
Response: jsonifyInterface([]interface{}{GetCachedTickerResponse}),
})
var updateOrderbookResponse *orderbook.Base
@@ -405,6 +391,20 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
Response: jsonifyInterface([]interface{}{updateOrderbookResponse}),
})
var GetCachedOrderbookResponse *orderbook.Base
GetCachedOrderbookResponse, err = e.GetCachedOrderbook(p, assetTypes[i])
msg = ""
if err != nil {
msg = err.Error()
responseContainer.ErrorCount++
}
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
SentParams: jsonifyInterface([]interface{}{p, assetTypes[i]}),
Function: "GetCachedOrderbook",
Error: msg,
Response: jsonifyInterface([]interface{}{GetCachedOrderbookResponse}),
})
var fetchTradablePairsResponse []currency.Pair
fetchTradablePairsResponse, err = e.FetchTradablePairs(context.TODO(), assetTypes[i])
msg = ""
@@ -553,17 +553,17 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
})
}
var fetchAccountInfoResponse account.Holdings
fetchAccountInfoResponse, err = e.FetchAccountInfo(context.TODO(), assetTypes[i])
var GetCachedAccountInfoResponse account.Holdings
GetCachedAccountInfoResponse, err = e.GetCachedAccountInfo(context.TODO(), assetTypes[i])
msg = ""
if err != nil {
msg = err.Error()
responseContainer.ErrorCount++
}
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
Function: "FetchAccountInfo",
Function: "GetCachedAccountInfo",
Error: msg,
Response: jsonifyInterface([]interface{}{fetchAccountInfoResponse}),
Response: jsonifyInterface([]interface{}{GetCachedAccountInfoResponse}),
})
var getFundingHistoryResponse []exchange.FundingHistory