MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetch_ohlcv

Method fetch_ohlcv

python/ccxt/bullish.py:1303–1360  ·  view source on GitHub ↗

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/candle :param str symbol: unified symbol of the market to fetch OHLCV dat

(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={})

Source from the content-addressed store, hash-verified

1301 return []
1302
1303 def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1304 """
1305 fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1306
1307 https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/candle
1308
1309 :param str symbol: unified symbol of the market to fetch OHLCV data for
1310 :param str timeframe: the length of time each candle represents
1311 :param int [since]: timestamp in ms of the earliest candle to fetch
1312 :param int [limit]: the maximum amount of candles to fetch(max 100)
1313 :param dict [params]: extra parameters specific to the exchange API endpoint
1314 :param int [params.until]: timestamp in ms of the latest entry
1315 :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1316 :returns int[][]: A list of candles ordered, open, high, low, close, volume
1317 """
1318 self.load_markets()
1319 market = self.market(symbol)
1320 maxLimit = 100
1321 paginate = False
1322 paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate')
1323 if paginate:
1324 return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimit)
1325 request = {
1326 'symbol': market['id'],
1327 'timeBucket': self.safe_string(self.timeframes, timeframe, timeframe),
1328 '_pageSize': maxLimit,
1329 }
1330 request, params = self.handle_until_option('createdAtDatetime[lte]', request, params)
1331 until = self.safe_integer(request, 'createdAtDatetime[lte]')
1332 duration = self.parse_timeframe(timeframe)
1333 maxDelta = 1000 * duration * maxLimit
1334 startTime = since
1335 # both of since and until are required
1336 if startTime is None and until is None:
1337 until = self.milliseconds()
1338 startTime = until - maxDelta
1339 elif startTime is None:
1340 startTime = until - maxDelta
1341 elif until is None:
1342 until = self.sum(startTime, maxDelta)
1343 request['createdAtDatetime[gte]'] = self.iso8601(startTime)
1344 request['createdAtDatetime[lte]'] = self.iso8601(until)
1345 response = self.publicGetV1MarketsSymbolCandle(self.extend(request, params))
1346 #
1347 # [
1348 # {
1349 # "open": "100846.7490",
1350 # "high": "100972.4001",
1351 # "low": "100840.8129",
1352 # "close": "100972.2602",
1353 # "volume": "30.56064890",
1354 # "createdAtTimestamp": "1746720540000",
1355 # "createdAtDatetime": "2025-05-08T16:09:00.000Z",
1356 # "publishedAtTimestamp": "1746720636007"
1357 # }, ...
1358 # ]
1359 #
1360 return self.parse_ohlcvs(response, market, timeframe, since, limit)

Callers

nothing calls this directly

Calls 14

safe_stringMethod · 0.80
handle_until_optionMethod · 0.80
safe_integerMethod · 0.80
parse_timeframeMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
millisecondsMethod · 0.45
sumMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected