Hello
I read documents of Portfolio Construction and Risk Managment.
My issue is Suppose I have $10000 cash in my broker account I can set cash in bascktest but for live How they manage cash ?
does it takes from broker account if Yes then Suppose I have $10000 total cash but I want to spend only $1000 for that specific strategy How can I handle this ?
is it done in Portfolio Construction or Risk management.
Let me explain my Alpha Model.
My alpha model returns Direction with weight.
Mia Alissi
In live trading, the
SetCash
method is ignored and your brokerage cash is used instead. This means that if you have $10,000 in your brokerage account, that is the amount that will be used for your algorithm. However, if you want to limit the amount of cash used by your algorithm to $1,000, you can do this programmatically by adjusting the order size in your algorithm.For example, if you want to buy a certain stock, instead of using
SetHoldings("SYMBOL", .33)
, which would use 33% of your total cash, you can useMarketOrder("SYMBOL", (int) (1000 / price))
, which would only use $1,000 of your cash.This is not done in Portfolio Construction or Risk Management, but directly in your algorithm. Your Alpha Model, which returns direction with weight, would not be affected by this.
Here is the relevant discussion from the QuantConnect forum: SetCash Method
Please note that if you want to add more cash to your live algorithm, you need to stop the algorithm, add the funds, then redeploy. There is no need to clone. Here is the relevant discussion from the QuantConnect forum: How can I add cash to my portfolio when strategy is running?
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.
Sukhvinder Pal Singh
Thanks Mia Alissi
But I'm not using SetHoldings("SYMBOL", .33) or any things like this
My stretagy flow is Alpha Model → Portfolio Construction → Execute Model
I do not do anything manually to place order So I think I have to change in Portfolio Construction like How much Quantity should I place.
Mia Alissi
In your case, you can control the quantity of orders in the Portfolio Construction Model (PCM). The PCM is responsible for determining the target quantities for each security based on the insights provided by the Alpha Model.
You can create a custom PCM that keeps track of the quantity of each security that each alpha model has opened. Here's a Python example of how you could implement this:
In this example, the PCM keeps track of the quantity of each security that each alpha model has opened. It then uses this information to create targets for each insight. If the alpha model has reached the maximum quantity for a security, it skips that insight. Otherwise, it updates the quantity of the security for the alpha model and creates a target for the insight.
This is just an example and you might need to adjust it according to your specific needs. For example, you might want to limit the total quantity of all securities to a certain amount, or you might want to adjust the maximum quantity for each security based on other factors.
Here is the relevant discussion from the QuantConnect forum: Managing multiple independent Alpha Models
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.
Sukhvinder Pal Singh
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!