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

@@ -1882,3 +1882,24 @@ func (b *Binance) formatUSDTMarginedFuturesPair(p currency.Pair, pairFmt currenc
}
return p.Format(currency.UnderscoreDelimiter, pairFmt.Uppercase)
}
// GetServerTime returns the current exchange server time.
func (b *Binance) GetServerTime(ctx context.Context, ai asset.Item) (time.Time, error) {
switch ai {
case asset.USDTMarginedFutures:
return b.UServerTime(ctx)
case asset.Spot:
info, err := b.GetExchangeInfo(ctx)
if err != nil {
return time.Time{}, err
}
return info.Servertime, nil
case asset.CoinMarginedFutures:
info, err := b.FuturesExchangeInfo(ctx)
if err != nil {
return time.Time{}, err
}
return time.UnixMilli(info.ServerTime), nil
}
return time.Time{}, fmt.Errorf("%s %w", ai, asset.ErrNotSupported)
}