Back

How To Maintain A Rolling Account Balance

I have a strategy to divide my total portfolio into thirds and trade every single day of the week. I've been able to implement this in python on another platform but find it a little more difficult on QC.

total cash = $6000
target percent return = 3-5%
day 1 buy - $2000
day 2 buy - $2000
day 3 buy - $2000
day 4 buy - $2060 *day1 settlement*
day 5 buy - $2060 *day2 settlement*
weekend
weekend
day 1 buy - $2060 *day3 settlement*

Any ideas of how this can be done?

Update Backtest








In QC you can directly model the T+3 day equity settlement rules. Here's an example algorithm that shows how to set u the T+3 modelling. Of special note are the Portfolio.CashBook and Portfolio.UnsettledCashBook properties. These cash books contain the information on how much cash you have in a settled, ready to use state or an unsettled, pending state. Take a look at the log, where I'm dumping each cashbook on each day so you can see how funds transfer from on to the other.

In the purchasing schedule above you didn't label any 'sells' - so in the attached algorithm I just sell everything via MarketOnClose orders to fire at EOD.

0

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.


Micheal - I seriously couldn't ask for a better answer. Your code will help me reach my goals faster than ever! Did you code that whole thing yourself?

I'm having some trouble understanding the Lean engine library. When I search for a something within the help tab I dont really understand how to put it in context with my algorithm. Maybe in time ill be as good as you. :) Thank you again for helping me.
0

Happy to be of help!

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed