Dynamically expose strategy parameters
Author: kazuna
Creation Date: 1/30/2014 3:59 AM
profile picture

kazuna

#1
I have a strategy which has multiple group of parameters.
I would like to optimize each group individually without modifying the code.

I have tried a code like this:
CODE:
Please log in to see this code.

This doesn't work because GetDataSetName() doesn't work within the constructor.
Is there a way to do like this?

Also I'm wondering if there is a way to initialize StrategyParameter without invoking CreateParameter() because it exposes the parameter to optimizer.
profile picture

Cone

#2
I could be wrong, but it doesn't seem like there's going to be a way to instantiate a class before its constructor. For the DataSetName method, you need a WealthScript object, from which the Strategy class derives.
profile picture

kazuna

#3
Yes, it makes sense the DataSetName method requiring a WealthScript object.
It's not necessary a dataset name but anything which can differentiate the group at the constructor in which creates the parameter for the group specified.

Currently I modify the const value of the code without saving and execute the optimization. Like this:
CODE:
Please log in to see this code.

I would like to get rid of OptimizeParamA and OptimizeParamB so that the strategy needs to differentiate it based on something.
Also I would like to get rid of the condition whether paramA and paramB initialized by CreateParameter.
profile picture

Eugene

#4
QUOTE:
Also I'm wondering if there is a way to initialize StrategyParameter without invoking CreateParameter() because it exposes the parameter to optimizer.

You can get rid of CreateParameter by using undocumented properties this.Parameters.Add or this.Parameters.Insert. However, this will inevitably expose the parameter to the Optimizer. That's how it works.

CODE:
Please log in to see this code.



You can do that outside of constructor, but this implies no Straps and no Optimizer:

CODE:
Please log in to see this code.
profile picture

kazuna

#5
Thank you for the information.
However, unfortunately Optimizer is my primary purpose of this and so your solution doesn't fit into my goal.

Is there any information in constructor which I can differentiate in creating parameters?
profile picture

Eugene

#6
Like Cone already said, a class is not instantiated at this point, so there's nothing to differentiate. A WealthScript constructor is a C# constructor, so whatever you know about C# constructors applies to WealthScript Strategies too.
profile picture

Eugene

#7
gbullr asked:

Help with the following porblem please.

I have run a multiparameter optimization and there are 2 results that I want to use and therefore I want to store them w/in the strategy file itself.


One solution that I have is to:

param1 = CreateParameter("BOutLen",val1,val1,val2,val2-val1);

while this solution works it is not great because if I want to re-run the optimizatoin I would have to change the potential parameters.

The second solution that I thought of was this (only partial solution) assume that scenario 1 and scenario 2 are "stored"

CODE:
Please log in to see this code.



The above does not work, but is there a away to make it work?

Thanks a lot in advance.






I can in theory use this?

CODE:
Please log in to see this code.


Still confused.

profile picture

Eugene

#8
QUOTE:
The above does not work, but is there a away to make it work?

Creating an intentionally duplicate thread for the same question, basically copying the code from this thread, will not change our answer. See Cone's post above with explanation of why this won't work.

QUOTE:
I can in theory use this?

Whatever works for you is fine with me.

QUOTE:
I have run a multiparameter optimization and there are 2 results that I want to use and therefore I want to store them w/in the strategy file itself.

To keep non-default values with the Strategy, simply click Save parameters in the Strategy Parameters box.
profile picture

gbullr

#9
Sorry about copying..

So what I get is that it can't be done.

I guess I can do the brute force method which is what I call:
CODE:
Please log in to see this code.


but this just stores 2 cases

(Better than noffin)

Thanks.

This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).