Can a class library call a method in a strategy?
Author: Panache
Creation Date: 10/26/2018 1:54 AM
profile picture

Panache

#1
In my quest for the ultimate way to use Wealth-Lab, I'd like be able to put almost all of my strategy code in a class library, and have the Strategy only contain the code that is unique to that Strategy, ie. opening and closing rules. Is it possible to have the class library call the opening and closing rule methods from my Strategy?

Here's a toy example of what I'm hoping to have for my Strategy code.
CODE:
Please log in to see this code.


I had this all coded by returning each time the opening or closing rules needed to be used, but the execution time doing it that way is much too slow.
profile picture

Eugene

#2
QUOTE:
Is it possible to have the class library call the opening and closing rule methods from my Strategy?

Probably not. It should be the other way round.
profile picture

superticker

#3
The goal should be to put everything in a custom (user component) class library that's never going to change. And that can be the bulk of the complex code including interfaces to non-native external packages like Math.NET. Then the strategy Execute() block simply calls procedures from that established class library to differentiate one strategy from another.

This way each strategy stays small, employs only WL data types (i.e. no non-native, external package calls), and contains all the differentiating code.

Many of my classes start out in a strategy, then get moved to a component class library once that code is stable. Strategy code will never be stable because you're trying to solve a fuzzy system problem, which has no final solution.
profile picture

Eugene

#4
+1
profile picture

Panache

#5
I'm getting there. I went back and optimized my previous code which returned to the strategy whenever it needed code unique to the Strategy. I now have an Execute() that is simply:
CODE:
Please log in to see this code.


I have a bit more coding to do in my class library, but as of right now, this executes slightly faster than having all the code in the Strategy.
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).