def scrape_ohlcv(exchange, max_retries, symbol, timeframe, since, limit):
    earliest_timestamp = exchange.milliseconds()
    timeframe_duration_in_seconds = exchange.parse_timeframe(timeframe)
    timeframe_duration_in_ms = (timeframe_duration_in_seconds * 1000)
    timedelta = (limit * timeframe_duration_in_ms)
    all_ohlcv = []
    while True:
        fetch_since = (earliest_timestamp - timedelta)
        ohlcv = retry_fetch_ohlcv(exchange, max_retries, symbol, timeframe, fetch_since, limit)
        if (ohlcv[0][0] >= earliest_timestamp):
            break
        earliest_timestamp = ohlcv[0][0]
        all_ohlcv = (ohlcv + all_ohlcv)
        print(len(all_ohlcv), 'candles in total from', exchange.iso8601(all_ohlcv[0][0]), 'to', exchange.iso8601(all_ohlcv[(- 1)][0]))
        if (fetch_since < since):
            break
    return all_ohlcv
def scrape_ohlcv(exchange, max_retries, symbol, timeframe, since, limit):
    earliest_timestamp = exchange.milliseconds()
    timeframe_duration_in_seconds = exchange.parse_timeframe(timeframe)
    timeframe_duration_in_ms = (timeframe_duration_in_seconds * 1000)
    timedelta = (limit * timeframe_duration_in_ms)
    all_ohlcv = []
    while True:
        fetch_since = (earliest_timestamp - timedelta)
        ohlcv = retry_fetch_ohlcv(exchange, max_retries, symbol, timeframe, fetch_since, limit)
        if (ohlcv[0][0] >= earliest_timestamp):
            break
        earliest_timestamp = ohlcv[0][0]
        all_ohlcv = (ohlcv + all_ohlcv)
        print(len(all_ohlcv), 'candles in total from', exchange.iso8601(all_ohlcv[0][0]), 'to', exchange.iso8601(all_ohlcv[(- 1)][0]))
        if (fetch_since < since):
            break
    return all_ohlcv