From 7ea8b5ae1c54339a24ea81bf80652ad8dabcd1b0 Mon Sep 17 00:00:00 2001 From: itsdeka Date: Tue, 17 Jan 2023 12:40:09 +0100 Subject: [PATCH] add seed candles --- bfxapi/rest/BfxRestInterface.py | 8 ++++---- examples/rest/get_candles_hist.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 examples/rest/get_candles_hist.py diff --git a/bfxapi/rest/BfxRestInterface.py b/bfxapi/rest/BfxRestInterface.py index deb5bdc..c16c555 100644 --- a/bfxapi/rest/BfxRestInterface.py +++ b/bfxapi/rest/BfxRestInterface.py @@ -176,20 +176,20 @@ class _RestPublicEndpoints(_Requests): def get_candles_hist( self, - resource: str, + symbol: str, tf: str = "1m", sort: Optional[Sort] = None, start: Optional[str] = None, end: Optional[str] = None, limit: Optional[int] = None ) -> List[Candle]: params = { "sort": sort, "start": start, "end": end, "limit": limit } - data = self._GET(f"candles/{resource}/hist", params=params) + data = self._GET(f"candles/trade:{tf}:{symbol}/hist", params=params) return [ serializers.Candle.parse(*subdata) for subdata in data ] def get_candles_last( self, - resource: str, + symbol: str, tf: str = "1m", sort: Optional[Sort] = None, start: Optional[str] = None, end: Optional[str] = None, limit: Optional[int] = None ) -> Candle: params = { "sort": sort, "start": start, "end": end, "limit": limit } - data = self._GET(f"candles/{resource}/last", params=params) + data = self._GET(f"candles/trade:{tf}:{symbol}/last", params=params) return serializers.Candle.parse(*data) def get_derivatives_status(self, symbols: Union[List[str], Literal["ALL"]]) -> List[DerivativesStatus]: diff --git a/examples/rest/get_candles_hist.py b/examples/rest/get_candles_hist.py new file mode 100644 index 0000000..fde6212 --- /dev/null +++ b/examples/rest/get_candles_hist.py @@ -0,0 +1,13 @@ +# python -c "from examples.rest.get_candles_hist import *" + +from bfxapi.client import Client, Constants + +bfx = Client( + REST_HOST=Constants.REST_HOST +) + +print(f"Candles: {bfx.rest.public.get_candles_hist(symbol='tBTCUSD')}") + +# Be sure to specify a period or aggregated period when retrieving funding candles. +# If you wish to mimic the candles found in the UI, use the following setup to aggregate all funding candles: a30:p2:p30 +print(f"Candles: {bfx.rest.public.get_candles_hist(tf='15m', symbol='fUSD:a30:p2:p30')}") \ No newline at end of file