exchange/wrapper: add GetServerTime() for exchange analytics (#938)

* exchange/wrapper: add GetServerTime() for exchange analytics

* binance: fix linter issue

* glorious: nits

* glorious: nits rides again

* thrasher: nits implement huobi

* thrasher: nits add to exchange_wrapper_issues cmd
This commit is contained in:
Ryan O'Hara-Reid
2022-05-06 11:38:59 +10:00
committed by GitHub
parent c6ad429827
commit d735effc8e
24 changed files with 230 additions and 28 deletions

View File

@@ -270,8 +270,8 @@ func (b *BTCMarkets) GetMultipleOrderbooks(ctx context.Context, marketIDs []stri
return orderbooks, nil
}
// GetServerTime gets time from btcmarkets
func (b *BTCMarkets) GetServerTime(ctx context.Context) (time.Time, error) {
// GetCurrentServerTime gets time from btcmarkets
func (b *BTCMarkets) GetCurrentServerTime(ctx context.Context) (time.Time, error) {
var resp TimeResp
return resp.Time, b.SendHTTPRequest(ctx, btcMarketsAPIURL+btcMarketsAPIVersion+btcMarketsGetTime,
&resp)

View File

@@ -142,14 +142,26 @@ func TestGetMultipleOrderbooks(t *testing.T) {
}
}
func TestGetServerTime(t *testing.T) {
func TestGetCurrentServerTime(t *testing.T) {
t.Parallel()
_, err := b.GetServerTime(context.Background())
_, err := b.GetCurrentServerTime(context.Background())
if err != nil {
t.Error(err)
}
}
func TestWrapperGetServerTime(t *testing.T) {
t.Parallel()
st, err := b.GetServerTime(context.Background(), asset.Spot)
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
if st.IsZero() {
t.Fatal("expected a time")
}
}
func TestGetAccountBalance(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {

View File

@@ -1086,3 +1086,8 @@ func (b *BTCMarkets) GetHistoricCandlesExtended(ctx context.Context, p currency.
ret.SortCandlesByTimestamp(false)
return ret, nil
}
// GetServerTime returns the current exchange server time.
func (b *BTCMarkets) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error) {
return b.GetCurrentServerTime(ctx)
}