Hello,
I am working through the algorithm framework and am looking to tag my orders so I can track what part of the framework triggered a specific order (Portfolio Rebalancing, Drawdown past the MaxDrawdown limit in Risk Management, Insight time expiration, etc.).
At first, I thought I could create limit orders in the Execution Model and then update the tags within the Alpha, Portfolio Construction, Risk Management modules however I think this violates the separation of concerns principle. I was wondering the following:
1). Does the approach I describe above work or does it violate the separation of concerns?
2). If it does violate, are there any common ways to work around the order tags while still tracking each module's effect on my overall targets?
Thank you for the help,
Jason
Shile Wen
Hi Jason,
This may be impossible to achieve since the only component of the Framework that works with Orders is the Execution Model, which does not get specific information on which component the OrderEvent is caused by. Since each component does not know which orders it will be causing, it will be difficult to try and update the tags within the component.
Best,
Shile Wen
Saravana Kumar Periyasamy
Understand this is difficult. But this will be a great feature to have. I have many signals, and like to know which one caused to trigger the order.
Jason Alborough
I have a similar itch and came acorss this post. If im reading the code coprrectly form a C# persepective...
The orders are created by the execution module. The execution module gets its instructions from the Risk [ManageRisk()] and PortfolioConstruction modules [CreateTargets()] using IPortfolioTarget. IPortfolioTarget does not currently contain any identifying information.
In order to add that info you would need to create a new class implementing IPortfolioTargets with identifying info (AlphaSignal, Rebalance, Risk, etc) and implement that class in the Portfolio and and Risk modules for setting targets.
Shile, please correct me if im wrong.
It seems like a somewhat fundemental change but may be worth implementing in the framework or on your own algos. Im not sure if i will take up the tourch myslef but I definitly understand the want,.
Shile Wen
Hi Jason,
At the moment, QuantConnect doesn't intend to modify the PortfolioTarget class to add a property/attribute to identify the PortfolioTarget source.
Best,
Shile Wen
Mislav Sagovac
Hi,
I just want to be sure>
It is not possible to change order tags if we use Algorithmic framework ?
Non Compete
I would like this feature implemented as well. I want to be able to tag if an order is coming from my alpha or risk management.
I did notice a SetHoldings function here which takes a tag as an optional param:
https://github.com/QuantConnect/Lean/blob/b54281b262c89785eb4b1dfced565d6dbafcee6c/Algorithm/QCAlgorithm.Trading.cs
With its only usage I found being:
https://github.com/QuantConnect/Lean/blob/2cb239a3301cd7bff758e3b98cce45658097eee0/Algorithm.Python/SetHoldingsMultipleTargetsRegressionAlgorithm.py
So I guess a potential workaround would be for the RiskManagment to always return an empty list of targets and use SetHoldings.
Non Compete
actually my previous idea was flawed because you need to keep track of the tags from previous steps. I think a better idea is to subclass PortfolioTarget and add a tag field to its constructor and use that new class wherever you use PortfolioTarget. Then hopefully it will be passed to your execution model and you can read from your new tag field there. I havent tried it yet but ill try it out and post if it works
Non Compete
i guess you would need to subclass Insight too , to add a tag there as well.
Non Compete
I tried subclassing PortfolioTarget and Insight and I think the python / c# translation removes the extra subclass parameter. I made this github issue:
https://github.com/QuantConnect/Lean/issues/6868
Jason
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!