Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not enough candle for Binance BTCUSDT is present in the database #4

Closed
emansammuta100533 opened this issue Apr 18, 2020 · 3 comments
Closed

Comments

@emansammuta100533
Copy link

emansammuta100533 commented Apr 18, 2020

I imported candles as instructed on documentation from 1st January 2020:
jesse import-candles Binance BTCUSDT 2020-01-01

Database now have around ~151000 rows

Tried running a backtest as shown in documentation:
jesse backtest 2020-01-01 2020-04-06

And getting the following error:
`File "c:\programdata\anaconda3\lib\site-packages\jesse_init_.py", line 286, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init_.py", line 40, in run
candles = load_candles(start_date, finish_date)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init
.py", line 91, in _load_candles
required_candles.load_required_candles(c[0], c[1], start_date_str, finish_date_str),
File "c:\programdata\anaconda3\lib\site-packages\jesse\services\required_candles.py", line 94, in load_required_candles
exchange, symbol

Uncaught Exception: CandleNotFoundInDatabase: Not enough candle for Binance BTCUSDT is present in the database. Try importing candles.`

Am I missing something?

Also when importing candles at what time frame are they being downloaded at?

@emansammuta100533
Copy link
Author

I noticed that the data only goes back to 2020-02-06 even tough I specified from 2020-01-01, also had to remove the ('Binance', 'BTCUSDT', anchor_timeframe('4h')), from extra_candles for the backtest to execute.

@saleh-old
Copy link
Contributor

Maybe I need to change the behavior somehow or mention it in the docs. Here's the reason:

For example when your backtest starts since 2020-01-01 you need data from an earlier date. How early? 210 candles earlier. Which timeframe? The biggest timeframe you're using in your backtest. For example if 4h is the biggest timeframe you're using, you need to have candles present since 35 days earlier than 2020-01-01. This is to make sure that there will be enough data to actually execute the strategy since the very first day of your backtest.

To make sure you won't be bothered by this, simply import more candles. For example in the case of Binance, import since 2018.

Also when importing candles at what time frame are they being downloaded at?

1m timeframe only. All the other timeframes will be generated during your backtest. This is to prevent the look-ahead bias. It also gives more flexibility to add support for all timeframes even if the exchange doesn't offer it in their API.

@emansammuta100533
Copy link
Author

Thanks for the explanation and yes I think best is to add this explanation to the documentation as well, cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants