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

Function test_fetch_ohlcv

python/ccxt/test/exchange/sync/test_fetch_ohlcv.py:18–35  ·  view source on GitHub ↗
(exchange, skipped_properties, symbol)

Source from the content-addressed store, hash-verified

16from ccxt.test.exchange.base import test_shared_methods # noqa E402
17
18def test_fetch_ohlcv(exchange, skipped_properties, symbol):
19 method = 'fetchOHLCV'
20 timeframe_keys = list(exchange.timeframes.keys())
21 assert len(timeframe_keys), exchange.id + ' ' + method + ' - no timeframes found'
22 # prefer 1m timeframe if available, otherwise return the first one
23 chosen_timeframe_key = '1m'
24 if not exchange.in_array(chosen_timeframe_key, timeframe_keys):
25 chosen_timeframe_key = timeframe_keys[0]
26 limit = 10
27 duration = exchange.parse_timeframe(chosen_timeframe_key)
28 since = exchange.milliseconds() - duration * limit * 1000 - 1000
29 ohlcvs = exchange.fetch_ohlcv(symbol, chosen_timeframe_key, since, limit)
30 test_shared_methods.assert_non_emtpy_array(exchange, skipped_properties, method, ohlcvs, symbol)
31 now = exchange.milliseconds()
32 for i in range(0, len(ohlcvs)):
33 test_ohlcv(exchange, skipped_properties, method, ohlcvs[i], symbol, now)
34 # todo: sorted timestamps check
35 return True

Callers

nothing calls this directly

Calls 6

test_ohlcvFunction · 0.90
in_arrayMethod · 0.80
parse_timeframeMethod · 0.80
rangeFunction · 0.50
millisecondsMethod · 0.45
fetch_ohlcvMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…