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.

Issue with getting history ohlcv from example

See original GitHub issue
  • OS: Win10 64x
  • Programming Language version: python 3.8.2
  • CCXT version: 1.26.54

Hi. I’m stuck here almost for 2 days and couldn’t find a solution. It is possible example is too outdated

My goal is to fetch data to csv. But when i try to just bluntly use an example to give it a test, it gets me wrong data.

you see, in the example @kroitor wants to get ohlcv from 016-01-01T00:00:00Z with limit = 100 days But instead data passed to csv from 2017-12-22T00:00:00.000Z to 2020-04-20T00:00:00.000Z

I posted the last line. Whole code is available here: ccxt/examples/py/binance-fetch-ohlcv-to-csv.py

scrape_candles_to_csv('binance.csv', 'binance', 3, 'NEBL/ETH', '1d', '2016-01-01T00:00:00Z', 100)
"C:\Program Files\Python38\python.exe" C:/Users/Leo/PycharmProjects/NewProject/get_currs_history_fuck.py
100 candles in total from 2020-01-12T00:00:00.000Z to 2020-04-20T00:00:00.000Z
200 candles in total from 2019-10-04T00:00:00.000Z to 2020-04-20T00:00:00.000Z
...
800 candles in total from 2018-02-11T00:00:00.000Z to 2020-04-20T00:00:00.000Z
900 candles in total from 2017-12-22T00:00:00.000Z to 2020-04-20T00:00:00.000Z
Saved 900 candles from 2017-12-22T00:00:00.000Z to 2020-04-20T00:00:00.000Z to binance.csv

Process finished with exit code 0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kroitorcommented, Apr 21, 2020

@SpinningSlash let me know if the above does not resolve the issue.

0reactions
kroitorcommented, Apr 21, 2020

@SpinningSlash by default, that example will fetch OHLCV in batches by 100 candles (100 days) backwards in time, starting from today – into the past. That is why it returned slightly more candles, starting earlier than your since date. If you want the starting date to be exactly at your since value – just filter your candles accordingly.

Change line 47 here:

    return all_ohlcv

    return exchange.filter_by_since_limit(all_ohlcv, since, None, key=0)

In short, those snippets are examples showing the concepts of how to use the CCXT code, but they’re not supposed to be used as is for your production needs. In other words, you’re expected to read the example code and understand what it does to be able to change it and manage it how you want, depending on your needs.

I’ve uploaded the edited example:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: How to set ticker in krakenex for fetching historical ...
Here is a simple usage example: import krakenex from pprint import pprint k = krakenex.API() pprint(k.query_public('OHLC', ...
Read more >
History Requests - QuantConnect.com
Each column of the DataFrame is a property of that price data (for example, open, high, low, and close (OHLC)). If you request...
Read more >
alpaca-trade-api 0.47rc1 - PyPI
The Alpaca API requires API key ID and secret key, which you can obtain from the ... The example below gives AAPL daily...
Read more >
How To Get Free Historical Crypto Data (OHLCV Candlesticks)
Example OHLCV charting data from the Bittrex Exchange. As always, the Shrimpy APIs are the easiest way for developers to integrate data across ......
Read more >
coinmarketcapr: Get 'Cryptocurrencies' Market Cap Prices ...
BugReports https://github.com/amrrs/coinmarketcapr/issues ... UTC day along with all historic days using /cryptocurrency/ohlcv/historical.
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