diff --git a/bfxapi/rest/BfxRestInterface.py b/bfxapi/rest/BfxRestInterface.py index 3a02593..3b6db61 100644 --- a/bfxapi/rest/BfxRestInterface.py +++ b/bfxapi/rest/BfxRestInterface.py @@ -190,10 +190,10 @@ class _RestPublicEndpoints(_Requests): data = self._GET(f"candles/{resource}/last", params=params) return serializers.Candle.parse(*data) - def get_derivatives_status(self, type: str, keys: List[str]) -> List[DerivativesStatus]: - params = { "keys": ",".join(keys) } + def get_derivatives_status(self, symbols: Union[List[str], Literal["ALL"]]) -> List[DerivativesStatus]: + params = { "keys": ",".join(symbols) if type(symbols) == List else "ALL" } - data = self._GET(f"status/{type}", params=params) + data = self._GET(f"status/deriv", params=params) return [ serializers.DerivativesStatus.parse(*subdata) for subdata in data ] diff --git a/examples/rest/get_liquidations.py b/examples/rest/get_liquidations.py new file mode 100644 index 0000000..34ed47d --- /dev/null +++ b/examples/rest/get_liquidations.py @@ -0,0 +1,14 @@ +# python -c "from examples.rest.get_liquidations import *" + +import time + +from bfxapi.client import Client, Constants + +bfx = Client( + REST_HOST=Constants.REST_HOST +) + +now = int(round(time.time() * 1000)) + +liquidations = bfx.rest.public.get_liquidations(start=0, end=now) +print(f"Liquidations: {liquidations}") \ No newline at end of file diff --git a/examples/rest/get_public_data.py b/examples/rest/get_public_data.py new file mode 100644 index 0000000..ff86c14 --- /dev/null +++ b/examples/rest/get_public_data.py @@ -0,0 +1,52 @@ +# python -c "from examples.rest.get_public_data import *" + +import time + +from bfxapi.client import Client, Constants + +bfx = Client( + REST_HOST=Constants.REST_HOST +) + +now = int(round(time.time() * 1000)) + + +def log_historical_candles(): + candles = bfx.rest.public.get_candles_hist(start=0, end=now, resource='trade:1m:tBTCUSD') + print("Candles:") + [print(c) for c in candles] + + +def log_historical_trades(): + trades = bfx.rest.public.get_t_trades(pair='tBTCUSD', start=0, end=now) + print("Trades:") + [print(t) for t in trades] + + +def log_books(): + orders = bfx.rest.public.get_t_book(pair='BTCUSD', precision='P0') + print("Order book:") + [print(o) for o in orders] + + +def log_tickers(): + tickers = bfx.rest.public.get_t_tickers(pairs=['BTCUSD']) + print("Tickers:") + print(tickers) + + +def log_derivative_status(): + status = bfx.rest.public.get_derivatives_status('ALL') + print("Deriv status:") + print(status) + + +def run(): + log_historical_candles() + log_historical_trades() + log_books() + log_tickers() + log_derivative_status() + + +run() \ No newline at end of file