fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market https://developers.bydfi.com/en/futures/market#candlestick-data :param str symbol: unified symbol of the market to fetch OHLCV data for :param str timefr
(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={})
| 802 | return self.safe_string(types, type, type) |
| 803 | |
| 804 | def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]: |
| 805 | """ |
| 806 | fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market |
| 807 | |
| 808 | https://developers.bydfi.com/en/futures/market#candlestick-data |
| 809 | |
| 810 | :param str symbol: unified symbol of the market to fetch OHLCV data for |
| 811 | :param str timeframe: the length of time each candle represents |
| 812 | :param int [since]: timestamp in ms of the earliest candle to fetch |
| 813 | :param int [limit]: the maximum amount of candles to fetch(max 500) |
| 814 | :param dict [params]: extra parameters specific to the bitteam api endpoint |
| 815 | :param int [params.until]: timestamp in ms of the latest candle to fetch |
| 816 | :returns int[][]: A list of candles ordered, open, high, low, close, volume |
| 817 | """ |
| 818 | self.load_markets() |
| 819 | maxLimit = 500 # docs says max 1500, but in practice only 500 works |
| 820 | paginate = False |
| 821 | paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate') |
| 822 | if paginate: |
| 823 | return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimit) |
| 824 | market = self.market(symbol) |
| 825 | interval = self.safe_string(self.timeframes, timeframe, timeframe) |
| 826 | request = { |
| 827 | 'symbol': market['id'], |
| 828 | 'interval': interval, |
| 829 | } |
| 830 | startTime = since |
| 831 | numberOfCandles = limit if limit else maxLimit |
| 832 | until = None |
| 833 | until, params = self.handle_option_and_params(params, 'fetchOHLCV', 'until') |
| 834 | now = self.milliseconds() |
| 835 | duration = self.parse_timeframe(timeframe) * 1000 |
| 836 | timeDelta = duration * numberOfCandles |
| 837 | if startTime is None and until is None: |
| 838 | startTime = now - timeDelta |
| 839 | until = now |
| 840 | elif until is None: |
| 841 | until = startTime + timeDelta |
| 842 | if until > now: |
| 843 | until = now |
| 844 | elif startTime is None: |
| 845 | startTime = until - timeDelta |
| 846 | request['startTime'] = startTime |
| 847 | request['endTime'] = until |
| 848 | if limit is not None: |
| 849 | request['limit'] = limit |
| 850 | response = self.publicGetV1FapiMarketKlines(self.extend(request, params)) |
| 851 | # |
| 852 | # { |
| 853 | # "code": 200, |
| 854 | # "message": "success", |
| 855 | # "data": [ |
| 856 | # { |
| 857 | # "s": "ETH-USDT", |
| 858 | # "t": "1766166000000", |
| 859 | # "c": "2964.990000000000000000", |
| 860 | # "o": "2967.830000000000000000", |
| 861 | # "h": "2967.830000000000000000", |
nothing calls this directly
no test coverage detected