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

@@ -162,8 +162,8 @@ func (b *BTSE) GetPrice(ctx context.Context, symbol string) (Price, error) {
return p, b.SendHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, path, &p, true, queryFunc)
}
// GetServerTime returns the exchanges server time
func (b *BTSE) GetServerTime(ctx context.Context) (*ServerTime, error) {
// GetCurrentServerTime returns the exchanges server time
func (b *BTSE) GetCurrentServerTime(ctx context.Context) (*ServerTime, error) {
var s ServerTime
return &s, b.SendHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, btseTime, &s, true, queryFunc)
}

View File

@@ -291,14 +291,26 @@ func TestUpdateTickers(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 TestGetWalletInformation(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {

View File

@@ -1106,3 +1106,12 @@ func OrderSizeLimits(pair string) (limits OrderSizeLimit, found bool) {
val, ok := resp.(OrderSizeLimit)
return val, ok
}
// GetServerTime returns the current exchange server time.
func (b *BTSE) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error) {
st, err := b.GetCurrentServerTime(ctx)
if err != nil {
return time.Time{}, err
}
return st.ISO, nil
}