fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot :param str symbol: unified symbol of the market to fetch OHLCV d
(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={})
| 1385 | }, market) |
| 1386 | |
| 1387 | def fetch_ohlcv(self, symbol: str, timeframe: str = '1m', since: Int = None, limit: Int = None, params={}) -> List[list]: |
| 1388 | """ |
| 1389 | fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market |
| 1390 | |
| 1391 | https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot |
| 1392 | |
| 1393 | :param str symbol: unified symbol of the market to fetch OHLCV data for |
| 1394 | :param str timeframe: the length of time each candle represents, support '1m', '15m', '1h', '1d' |
| 1395 | :param int [since]: timestamp in ms of the earliest candle to fetch |
| 1396 | :param int [limit]: the maximum amount of candles to fetch |
| 1397 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1398 | :param int [params.until]: timestamp in ms of the latest candle to fetch |
| 1399 | :returns int[][]: A list of candles ordered, open, high, low, close, volume |
| 1400 | """ |
| 1401 | self.load_markets() |
| 1402 | market = self.market(symbol) |
| 1403 | until = self.safe_integer(params, 'until', self.milliseconds()) |
| 1404 | useTail = since is None |
| 1405 | originalSince = since |
| 1406 | if since is None: |
| 1407 | if limit is not None: |
| 1408 | # optimization if limit is provided |
| 1409 | timeframeInMilliseconds = self.parse_timeframe(timeframe) * 1000 |
| 1410 | since = self.sum(until, timeframeInMilliseconds * limit * -1) |
| 1411 | if since < 0: |
| 1412 | since = 0 |
| 1413 | useTail = False |
| 1414 | else: |
| 1415 | since = 0 |
| 1416 | params = self.omit(params, ['until']) |
| 1417 | request = { |
| 1418 | 'type': 'candleSnapshot', |
| 1419 | 'req': { |
| 1420 | 'coin': market['baseName'] if market['swap'] else market['id'], |
| 1421 | 'interval': self.safe_string(self.timeframes, timeframe, timeframe), |
| 1422 | 'startTime': since, |
| 1423 | 'endTime': until, |
| 1424 | }, |
| 1425 | } |
| 1426 | response = self.publicPostInfo(self.extend(request, params)) |
| 1427 | # |
| 1428 | # [ |
| 1429 | # { |
| 1430 | # "T": 1704287699999, |
| 1431 | # "c": "2226.4", |
| 1432 | # "h": "2247.9", |
| 1433 | # "i": "15m", |
| 1434 | # "l": "2224.6", |
| 1435 | # "n": 46, |
| 1436 | # "o": "2247.9", |
| 1437 | # "s": "ETH", |
| 1438 | # "t": 1704286800000, |
| 1439 | # "v": "591.6427" |
| 1440 | # } |
| 1441 | # ] |
| 1442 | # |
| 1443 | return self.parse_ohlcvs(response, market, timeframe, originalSince, limit, useTail) |
| 1444 |
nothing calls this directly
no test coverage detected