I am having trouble with what I think should be a simple C# / .NET technique that I'd like to apply to my strategies (using the built in editor).
Generally what I'd like to do is be able to refer to external data tables (like a lookup table) within the runtime of the script. A simple example could be if I wanted to specify pairs of stocks that should be pair-traded together, and wanted to have the script refer off to a lookup table, find the listing for the Bars symbol, and return back the string of the symbol that I pre-designated as the hedging pair.
That's a very generic use of an external data table, but there are many others I can think of. Any suggestions on how others have approached this?
Size:
Color:
There are probably a dozen or more methods to do that depending on the application. How are the pairs specified?
If you're manually specifying the pairs, then I'd suggest hardcoding the list. After all, there's not much difference typing the pairs into your code compared with typing them into a text file.
Size:
Color:
Yes, they're manually specified. Let's say I had 100 pairs that I wanted to test. I could put one each of the 100 pairs into a symbol list, but would still face the problem of getting the proper pair selected for each symbol as it ran thru the code. How would you suggest I structure this into the code?
Would this be any different if I used Sharp Developer or Visual Studio Express? I've steered away from complicating things by moving out of the WLP editor, but would give it a try if that made it easier to create some sort of matrix or table object that would allow the strategy to "look up" the proper pair for whatever the target symbol happened to be.
Size:
Color:
I'm not sure why'd you need VS or SD for this task, if only to make things more complex? What about serializing your pairs in an XML file for lookup?
Size:
Color:
I'd prefer not to use VS or SD, just asking to see if there were limitations placed on things by use of the integrated editor. I'm not familiar with XML, could the same be done in a CSV format? I'll do my homework on C# syntax etc... but any point in the right direction would be great (or better, any past threads that had code examples referencing a lookup table)
As always, thanks for the help
Size:
Color:
That's what I'm talking about, VS or SD would only complicate a simple task like this one. The built-in editor is just fine.
I suggest creating a Dictionary<string,string> that will hold the names of your stock and its vis-a-vis. It can be done either in a Wealth-Lab Strategy or right in Notepad, it doesn't actually matter. With the help of the class below, you can both serialize (save the updated list to file from a Strategy) and deserialize (read and convert the CSV file holding your pairs back into a Dictionary type). After getting the Dictionary object back from disk, you'd perform lookup in it for symbol (
string Bars.Symbol) that is currently being executed. So, your homework is to find out how to lookup in C# collections i.e. Dictionary.
C# Convert Dictionary to String
Size:
Color: