Class variables - how to update them with optimized values and hold different values for different assets? #929
CadeHalcyon
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
For my strategy, I have approx. 10 class variables/parameters which I optimize.
I go through these one by one via optimize (there would be too many combos doing altogether), and after each one I update the class variable I just optimized with the optimized value so when testing the next variable, it incorporates the updated values for the first variable... and so on until I have done them all. I might run through again. Not perfect, but seemed to get me where I needed to get to.
This was fine with one asset (symbol), but I now want to execute over 5 to 20 assets, and furthermore, automate in order to hook into a live trading script. I am fairly new to coding, so I stick to what I know, which is using "for" loops, iterating over the symbols, and creating dictionaries for the optmized values which I can use to define a live trading strategy.
I am fine to create a dictionary of backtests for each asset applying each of the asset-specific dataframes as follows:
I can then optimize class variables/parameters for each asset and return a dictionary of the optimized values by asset using:
However, the issue is as things stand is that the "Live_Strategy" class section will still contain the original variable/parameter values, not the optimized ASSET-specific values. I don't know how to make the variables/parameters (indicator_1 through to 10) below dynamic:
Question Info
I cannot find a way of iterating over the class variables/parameters in "Live Strategy" to use the dictionaries I create for each optimized, asset-specific value. I can sort of work around this using only the optimizer to generate the dictionaries of values for each parameter for each asset - I do this by applying a range to test for ONLY the variable to be optimized, and essentially include the other 9 variables in the optimizer using their dictionary values with effectively no range to test, I will then move to the next indicator, and do the same... but this is time consuming and cumbersome - see below for illustration in case I'm hard to follow!:
The Actual Question!
So, for 20 assets, aside from creating 20 x classes of "Live Strategies" where I can assign asset-specific dictionaries for each class variable meaning they'll always pick up optimized values once those formulas have run, is there another, simpler way of incorporating the optmized values/parameters into each backtest for each asset, please?
Thanks for your patience if you have read until the end!
Beta Was this translation helpful? Give feedback.
All reactions