question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fetch_ohlcv candle size

See original GitHub issue

ATTENTION!!!

MUST READ THIS BEFORE SUBMITTING ISSUES:

https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue

  • Ubuntu:
  • Python:
  • 1.18.400:
  • Bitmex:
  • fetch_ohlcv:

Hi why I can’t fetch OHLCV data for 15m 30m, 4h, candles? My code:

def get_close_prices(exch, pair,candle):
	ohlcv = exch.fetch_ohlcv(pair,candle)
	close_prices =[]
	[close_prices.append(x[4]) for x in ohlcv]
	return close_prices

I get the error which look like this

'binSize': self.timeframes[timeframe],
KeyError: '4h'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Arrmletcommented, Mar 26, 2019
import ccxt
from pprint import pprint
from datetime import datetime
import itertools

exchange = ccxt.bitmex()

dt_obj = datetime.strptime('20.03.2019 00:00:00,00',
                           '%d.%m.%Y %H:%M:%S,%f')
millisec = dt_obj.timestamp() * 1000
const = 30000000 # 500 minutes into milisecond
dat = datetime.now() 
ml = dat.timestamp() * 1000
iterator = 0
a = (ml - millisec)/const +1

ohlcv_data = []
for i in range(0, int(a)):
    data = exchange.fetch_ohlcv('BTC/USD', '5m', since =millisec + iterator)
    ohlcv_data.append(data)
    iterator += const
    print(iterator)

merged = list(itertools.chain(*ohlcv_data))

pprint(merged)

Maybe its will be useful for someone.

1reaction
Arrmletcommented, Mar 26, 2019

@kroitor Wow, thank you very much:))

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get ohlcv data for your exchange with ccxt library?
I set the limit option 12 for 12 candles that are equivalent to an hour (the last 60 minutes).
Read more >
Exchanges — ccxt 2.4.71 documentation
The exchange boolean (true/false) property named has['fetchOHLCV'] indicates whether the exchange supports candlestick data series or not. The fetchOHLCV method ...
Read more >
Binance ccxt fetch ohlcv exceeding 1000 limit - python
I can't get more than 1000 candles from a single request. Tried limit=None , limit=1500 , etc. If the value is not between...
Read more >
Build 6373 | freqtrade/exchange/exchange.py
1 # pragma pylint: disable=W0603 2 """ 1× 3 Cryptocurrency Exchanges support 4 """
Read more >
Getting class binance-fetch-ohlcv not found? ▷ Download ccxt/ccxt ...
Download ccxt / ccxt / binance-fetch-ohlcv.py - Solve class ... low, close, volume ] index = 4 # use close price from each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found