fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market https://trade.cex.io/docs/#rest-public-api-calls-candles :param str symbol: unified symbol of the market to fetch OHLCV data for :param str timeframe: th
(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={})
| 746 | return self.parse_order_book(orderBook, market['symbol'], timestamp) |
| 747 | |
| 748 | async def fetch_ohlcv(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={}) -> List[list]: |
| 749 | """ |
| 750 | fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market |
| 751 | |
| 752 | https://trade.cex.io/docs/#rest-public-api-calls-candles |
| 753 | |
| 754 | :param str symbol: unified symbol of the market to fetch OHLCV data for |
| 755 | :param str timeframe: the length of time each candle represents |
| 756 | :param int [since]: timestamp in ms of the earliest candle to fetch |
| 757 | :param int [limit]: the maximum amount of candles to fetch |
| 758 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 759 | :param int [params.until]: timestamp in ms of the latest entry |
| 760 | :returns int[][]: A list of candles ordered, open, high, low, close, volume |
| 761 | """ |
| 762 | dataType = None |
| 763 | dataType, params = self.handle_option_and_params(params, 'fetchOHLCV', 'dataType') |
| 764 | if dataType is None: |
| 765 | raise ArgumentsRequired(self.id + ' fetchOHLCV requires a parameter "dataType" to be either "bestBid" or "bestAsk"') |
| 766 | await self.load_markets() |
| 767 | market = self.market(symbol) |
| 768 | request = { |
| 769 | 'pair': market['id'], |
| 770 | 'resolution': self.timeframes[timeframe], |
| 771 | 'dataType': dataType, |
| 772 | } |
| 773 | if since is not None: |
| 774 | request['fromISO'] = self.iso8601(since) |
| 775 | until = None |
| 776 | until, params = self.handle_param_integer_2(params, 'until', 'till') |
| 777 | if until is not None: |
| 778 | request['toISO'] = self.iso8601(until) |
| 779 | elif since is None: |
| 780 | # exchange still requires that we provide one of them |
| 781 | request['toISO'] = self.iso8601(self.milliseconds()) |
| 782 | if since is not None and until is not None and limit is not None: |
| 783 | raise ArgumentsRequired(self.id + ' fetchOHLCV does not support fetching candles with both a limit and since/until') |
| 784 | elif (since is not None or until is not None) and limit is None: |
| 785 | raise ArgumentsRequired(self.id + ' fetchOHLCV requires a limit parameter when fetching candles with since or until') |
| 786 | if limit is not None: |
| 787 | request['limit'] = limit |
| 788 | response = await self.publicPostGetCandles(self.extend(request, params)) |
| 789 | # |
| 790 | # { |
| 791 | # "ok": "ok", |
| 792 | # "data": [ |
| 793 | # { |
| 794 | # "timestamp": "1728643320000", |
| 795 | # "open": "61061", |
| 796 | # "high": "61095.1", |
| 797 | # "low": "61048.5", |
| 798 | # "close": "61087.8", |
| 799 | # "volume": "0", |
| 800 | # "resolution": "1m", |
| 801 | # "isClosed": True, |
| 802 | # "timestampISO": "2024-10-11T10:42:00.000Z" |
| 803 | # }, |
| 804 | # ... |
| 805 | # |
nothing calls this directly
no test coverage detected