- ago
Hi,
My code has an enum OptionType.
To distinguish it from WL8 OptionType need to know its namespace.
Tried:
OptionSynthetic
SchwabHistorical
WealthLab.Schwab
Thanks!
0
143
Solved
3 Replies

Reply

Bookmark

Sort
- ago
#1
In WL8, OptionType is fully qualified as WealthLab.Core.OptionType. Since you're going to need WealthLab.Core in a C# strategy then one of your using statements is going to be:

CODE:
using WealthLab.Core;


So, that gets you the WealthLab.Core.OptionType enum. It also gets you all of the basic stuff you need for a strategy (like UserStrategyBase, etc.). Without it, you'd have to qualify a ton of names in your code.

Hence, you'll need to fully qualify your OptionType enum where you use it. For example, assuming your fully qualified OptionType enum is HayTac.OptionStuff.OptionType then you would use that along with the whatever enum value you want to use from that - like HayTac.OptionStuff.OptionType.Call.

Its just a namespace issue. If you're using a same-named enum from two different namespaces then you need to qualify one of them.

Another option is to rename your OptionType enum to something else so the name collision doesn't occur.
0
Best Answer
- ago
#2
QUOTE:
... you'll need to fully qualify your OptionType enum where you use it. For example, assuming your fully qualified OptionType enum is HayTac.OptionStuff.OptionType then you would use that along with the whatever enum value you want to use from that - like HayTac.OptionStuff.OptionType.Call.

There's another choice. Create a "using" statement with an abbreviation such as "HT".
CODE:
using WealthLab.Backtest; using WealthLab.Core; using HT = HayTac.OptionStuff; public override void Initialize(BarHistory bars) {    . . .    string optSym = OptionSynthetic.GetOptionsSymbol(bars, HT.OptionType.Call, price, currentDate, minDaysToExpiry, weeklies, allowExpired, closestStrike); }
0
- ago
#3
Thank you both!!
WealthLab.Core.OptionType worked.
I have my enum OptionType all over the place.
The one from WealthLab is hidden inside a function call.
This way I did not have to change my code.
2

Reply

Bookmark

Sort