backtesting.py icon indicating copy to clipboard operation
backtesting.py copied to clipboard

dealing with large data sets

Open jamhot1 opened this issue 6 years ago • 5 comments

I tried to process a data set with 5000 bars aprx 8 years of hourly data.

The algo got about 3 years through and stopped simulating trades. Is there a limit to the data set size?

jamhot1 avatar Jun 10 '20 21:06 jamhot1

Is there a limit to the data set size?

Only as confined by available runtime system resources, such as virtual memory in particular. Normally, 5k bars is really not a lot and should, for simpler strategies, run in a few seconds.

What is your strategy like? What do you mean by "stopped simulating trades"?

kernc avatar Jun 10 '20 23:06 kernc

Hi Kernc. Sorry, I missed a zero from that. its 50k of bars, not 5k. What I mean is that it stops any buy and sells after just under 3 years very abruptly. See attached. There seems to be a high density of trades within the 3 years. graph

jamhot1 avatar Jun 11 '20 10:06 jamhot1

That's very curious indeed. Without insight into reproducible strategy code itself, I'd suggest clipping the data to sufficient one third (or try to reduce the problem as far as possible in another way) and placing a breakpoint somewhere into _Broker.next() to investigate what is going on: https://github.com/kernc/backtesting.py/blob/0436e56ab42186a167c5ee187ff33e40eb39334b/backtesting/backtesting.py#L529-L533 For lack of better debugging means given unfamiliarity of your environment, I guess you could use ipdb debugger:

pip install ipdb

and to set the breakpoint:

import ipdb; ipdb.set_trace()

where you want the Python interpreter to stop to investigate. I think this should work within Jupyter notebooks too.

kernc avatar Jun 11 '20 10:06 kernc

@jamhot1 Have you maybe figured something out? :smiley: 0.2.0 has been released which is quite a lot different.

kernc avatar Jul 15 '20 13:07 kernc

Closing this issue as unreproducible. If not the case, reopen.

kernc avatar Nov 06 '20 02:11 kernc