@ab_trader On a quick check I couldn't find a way to make optunity do multiprocessing, so I just run it [cores] times and take the best result.
Posts made by Harel Rozental
-
RE: Smart optimizations and Backtrader
-
RE: Genetic Optimization
Something I just thought about - are you sure it's the same number of evaluations?
If you look at a parameter such as period, going from 1 to 5,
GrisSearch only has to run 5 times on it, whereas the other algorithms go over real numbers so they also try things such as 1.25 (which is just another way of saying 1 for this parameter). -
RE: Smart optimizations and Backtrader
A bit of an update:
I managed to get my optimizations to run as quick as optstrategy by subclassing Cerebro and pulling out some stuff out of run() and addstrategy() into different functions (one to initialize data loading, and another which gets re-executed from outside the class for optimization).
I also manage multiprocessing from the outside. -
RE: Smart optimizations and Backtrader
@backtrader I did restrict the file (actually I use a pandas dataframe) before loading it into a backtrader data object, though my restriction is changing minute-data from 7 years to 2 or 1 year. Even when resampling to say 30 mins, I still want the 1 minute to replay the data.
I guess the reusing of optstrategy is what makes if faster, I'll try to mimic that.@ab_trader I don't know if running the same cerebro instance will work, but I will try something like it in order to, as I said, mimic optstrategy.
-
RE: Genetic Optimization
Hi,
Well grid search should be the same as what backtrader does when you do optstrategy,
so given the data-caching and other things it does behind the scenes it should be even faster for that.I don't see why grid-search should be faster than "smarter" algorithms, though obviously it is always optimal (in the constrained region).
Weird.My intention is to try to make backtrader let me use optstrategy's speed with smart algorithms such as particle swarm or a variation of hill-climbing
-
RE: Smart optimizations and Backtrader
Slower per iteration.
The iteration including initializing cerebro is more than 2x slower than optstrategy when using large amounts of data.Even a month of minute data takes about 10 seconds per iteration.
-
RE: Smart optimizations and Backtrader
I think I see what the source of the problem is.
Creating the cerebro instance and loading the data is taking a lot of time.
When using optunity it goes through the process of cerebro creation every time.Is there a way I can use the same instance (and same data) for every run, like it does when using cerebro.optstrategy ?
-
RE: Smart optimizations and Backtrader
@ab_trader For now I used exactly what they said in that thread, optunity library.
But the problem isn't in the time it takes to choose new parameters (this wouldn't be Backtrader's problem), the problem is the time it takes to conduct one test (i.e going through 1 month or 1 year of minute data).
-
RE: Smart optimizations and Backtrader
Hey, thanks for the reply.
That's pretty much what I did.
It runs much slower (per parameter combination) than just running cerebro.optstrategy. -
Smart optimizations and Backtrader
Hi there!
I've been trying to use Backtrader in order to backtest and optimize trading strategies.
I've noticed that the optimizer is just going through all the parameter ranges without using any heuristics (for example hill-climbing).I tried to just create a cerebro instance, running it and getting the broke value at the end while using an optimizer from the outside, though this resulted in very slow performance, compared to optstrategy, even when considering multiple cpus.
Does anyone here have any recommendations as to how to best use "smart" optimizers along with Backtrader?
Thanks,
Harel