Agreed. For anyone considering implementing that workaround, please keep that in mind.
Separation of Concerns is a great programming design principle for developing clean modular code that is nicely abstracted (and very reusable via a plug-and-play approach), and I highly recommend users try to adhere to it as much as possible.Â
However for financial algorithms, there does often tend to be cases where it is necessary to break this separation to some extent. For instance, an Alpha Model based on computing relative weights of asset holdings in a portfolio does not make sense with an equal weighting portfolio model. Or a trend-following strategy based on some indicator cross-overs might want to set stop losses/targets (risk management) based on values computed by the Alpha Model rather than a fixed threshold. However the abstraction into modules and keeping the coupling to a minimum is still good practice.
What are your thoughts on implementing some sort of optional "state storage" that allows for minimal communication between modules in the Framework? For instance, we define an object StateStorage() that holds certain variables.Â
Simple example:
- In Alpha Model, compute something and set the variable StateStorage.stopLossPrice = 1.3 based on confidence
- In Risk Model, we liquidate if price < StateStorage.stopLossPrice
- As new data comes in, Alpha Model updates the variable
Naturally this violates the separation of concerns to an extent, but each module is still concerned with a specific task and at least any breaking (if necessary) is more readily transparent.