Access to WL dll's from Excel
Author: sedelstein
Creation Date: 3/7/2012 9:20 AM
profile picture

sedelstein

#1
Hi

I have tried to access WL dll's from Excel and have used the search the forum tool to find out if this question has been asked.

I generate alerts from a combination of strategies. I then copy/paste them into excel where I have the ability to do further analysis and then "cherry pick" the alerts to get a shorter list of trades I want to take.

Is there a way (while keeping WL open and logged in to Fidelity) to take the ones I've picked and place the orders? This would be handy tool (for me at least ;->))
profile picture

Eugene

#2
Regarding WealthLab.dll's members, whatever you can't find covered in the official documentation (i.e. the QuickRef and the Wiki Development Guide) is not supported. The aforementioned applies to accessing WL's DLLs in 3rd party apps. Finding their way around is entirely up to motivated developers.
profile picture

sedelstein

#3
I'm fine with that though in Excel VBA when I try to add a reference to WL dll's the messagebox popup says "Can't add a reference to the specified file".

Is there a reason why a reference can't even be made?
profile picture

Eugene

#4
No idea. Try searching on VBA-specific resources instead.
profile picture

sedelstein

#5
Will do.

I understand what you're saying (mostly ;->)
QUOTE:

Regarding WealthLab.dll's members, whatever you can't find covered in the official documentation (i.e. the QuickRef and the Wiki Development Guide) is not supported. The aforementioned applies to accessing WL's DLLs in 3rd party apps. Finding their way around is entirely up to motivated developers.


Can I ask then before I go down some dead ends whether you think, in your professional opinion, whether it is possible to create a file of orders and get them to WL so they can be staged or placed?

profile picture

Cone

#6
Just create a Strategy that reads the file and places the orders. The only thing to be aware of is that exit orders require that you create a hypothetical position first.
profile picture

sedelstein

#7
Thanks Cone

Now I see it. That was dumb. Create a script called "GenerateOrders" which reads the symbol, shares, etc... Then BuyAtLimit etc....

Can the account be set and the order placed from within a script?

Appreciate the help. Apologies for being thick
profile picture

Eugene

#8
Not from within a script. A Strategy can be associated with the account manually.
profile picture

Cone

#9
1. In your text file of Alerts, make sure each record indicates which account the trade should go to.
2. Create a copy of the strategy for each account. The only difference is that each strategy processes only the records for the specified account.
3. Assign the strategies to accounts using the Strategy Explorer (Ctrl+O)
profile picture

Eugene

#10
Another possibility is to set the account in the Strategy's XML file, in case you prefer to generate it externally.
profile picture

sedelstein

#11
Thanks for the tips. I'll be doing some homework tonight!
profile picture

sedelstein

#12
I tried coding this but it generates alerts for every symbol in the dataset. Is there something obviously wrong here?
CODE:
Please log in to see this code.
profile picture

Eugene

#13
Unless you attempt to run this DataSetSymbols looping code in multi-symbol backtest mode, no, it doesn't.
profile picture

Cone

#14
Read: "Only click on one symbol in the DataSet to run this script, any one symbol."

You can do this at least 3 different ways. But if you're just creating an Alert, the most efficient strategy would be to process each Alert as you read the record from the file...and that way you also run the script only once, on one symbol.

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

sedelstein

#15
Thank you for the help gentlemen.

The reason I am trying to do this is part of the discussion here

It's part of a broader strategy and this makes up one part of it.

profile picture

sedelstein

#16
Thanks Cone

Works like a charm. Only thing is now that I can generate the alert, I probably have to write a position sizer to read the same file for the number of shares. Is there a way to avoid that by setting or overriding the position size normally entered in the upper right corner of the strategy screen below the Data Range field? That way I could just trick the existing position sizer into generating an alert for the size I want and not have to write a new one?
profile picture

Eugene

#17
Use SetShareSize() in your code and select the "WealthScript Override" option in the Position Sizing control.
profile picture

sedelstein

#18
Thank you Eugene. This helps a lot. You and Cone have helped me get up to speed pretty quickly.

I also now "get" DataSetSymbols-looping code versus Multi-Symbol Backtest code and see the ways to do what I need a lot quicker than my current execution and "loop" only once
profile picture

sedelstein

#19
One more question if I may,


Can "WealthScript Override" option be set in a script? (or more generally, can a position sizer be chosen on the fly, that is, there may be times when Pct Winners may be desired and other times, say, Kelly Criterion.
profile picture

Eugene

#20
Yes, see Community.Components:
CODE:
Please log in to see this code.

I am stressing that this is unsupported.
profile picture

sedelstein

#21

Thanks!


When's the next version of Community Components coming out ;->);->)
profile picture

sedelstein

#22
Hello Eugene

You mentioned above with respect to an account

QUOTE:
Not from within a script. A Strategy can be associated with the account manually.


I am trading multiple accounts and want to make order entry easier.
My strategy is not fully automated as I get results from multiple strategies, screen them, and decide which trades to take.
I do this in Excel.

From Excel, I can generate a csv full of trades with position sizes and can read them and generate the alerts in WL.
[Many thanks to Cone]

Since I want to make the same trades (though not in the same share sizes) in multiple accounts, is there something you might suggest that would help automate the process?
profile picture

Eugene

#23
Hello Steve,

Yes there is. To automate the process, get rid of Excel e.g. use Strategy Monitor.

P.S. Quoted text refers to the ability to mangle the <AccountNumber /> XML tag manually in a Strategy's XML file.
profile picture

sedelstein

#24

When you mentioned not from within a script, you never mentioned the XML tag until just now.

Actually "mangling" the <AccountNumber /> XML tag works beautifully, was trivial to implement, and easily gets what I needed done.

Thanks!

Steve
profile picture

sedelstein

#25
Eugene

I'm almost certain you are going to dislike this question but here goes ;->)

In the XML files I see the following tags

CODE:
Please log in to see this code.



How can I set it so the strategy always uses WealthScript Override (Set Share Size)?

I have a strategy I want to use this feature but when I open it, the strategy often uses the position sizer of the previously opened strategy and I want to force it not to do this.

I thought the 0 in <OverrideShareSize>0</OverrideShareSize> signaled False and tried 1 for True but that doesnt seem to be it

Thanks again
profile picture

Eugene

#26
Steve,

Wealth-Lab's ISettingsHost serializes boolean values as True and False. OverrideShareSize is the parameter (number of shares), not a boolean.

Here's how it will work:
CODE:
Please log in to see this code.

profile picture

sedelstein

#27
Thanks a lot Eugene. I appreciate your help

Is there a place to learn more? I'm not familiar with ISettingsHost and would be interested in find out more about the XML tags
profile picture

sedelstein

#28
Even though that mode is set in the XML (<Mode>ScriptOverride</Mode>)

when I open the strategy, the Position Size is still using that of the previous strategy. Is there something I am doing incorrectly?
profile picture

Eugene

#29
QUOTE:
I'm not familiar with ISettingsHost

Wiki > API > Development Guide > Custom settings.
QUOTE:
and would be interested in find out more about the XML tags

You're welcome to explore this subject. As you understand it's undocumented and thereby unsupported.
profile picture

sedelstein

#30
Hello Eugene

As you know, I'm somewhat new to C# and have never worked with interfaces so I haven't quite got things to work but I think this is very close but not quite there

Can you take a quick look and see if something is obviously wrong? Thanks!

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

Eugene

#31
Hi Steve,

By introducing the ISettingsHost interface, I just meant to clear a misconception regarding how Wealth-Lab serializes boolean values, but that's all.

I'm not sure what's the rationale behind trying to store the key/value pair for that myClass instance but you'll not get where you want with this.

If the XML hack didn't do the job, then I don't know else how to help you with this unsupported "hack". Sorry.
profile picture

sedelstein

#32
Ok I'll figure a workaround.

But let me ask this. If I save strategy1 and say, it uses positionsizer1, when I subsequently open strategy2 which was saved with a different position sizer, should the earlier open position sizer be displayed in WL? That is, strategy2 is now using the position sizer associated with strategy1 Is this normal behavior in WL?
profile picture

Eugene

#33
It depends. See the Wealth-Lab User Guide > Preferences > Advanced Options > Strategy-Dependent Preferences.
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).