How to randomly do 1000 trades without losing money: Risk Control + Volatility Model Framework


I've made a risk control framework + volatility model which proves its possible to break even with a totally random signal! The backtest enters at 9:30am each day and exits at 4:00pm. It literally chooses a random direction every day.

Through assigning a maximum risk per trade, and controlling the quantity of shares purchased, the strategy is able to trade 1000x without loosing much capital at all ($75 over 1000 trades, ignoring fees).

I think this could be used as a great starting point to build off -- adding indicators and other signal components to give the strategy more intelligence!

If anyone in the community has any suggestions for improvements or addition to this model then they are most welcomed.


Update Backtest

This is just an update to the earlier algorithm. This time, in a very structured manner where you can give it any signal and all the trading logic will be handled on its own. Saves a lot of hassle.

As you can see the curve is still very flat but is now presented in a bit more structured manner.

Would like to know what the community thinks about it :)



Hi Deval, 

Thanks for sharing!  This is very helpful.  I've been reviewing your code and learning along the way. 

If I'm not mistaken, I noticed that risk per trade is set to $10. In terms of using this to build from, it would be nice if this was set to a fraction of equity to keep risk proportional to current equity.  Is it difficult to change risk to a percentage of equity vs. a dollar amount? 


Currently, I am using a fixed value for the risk per trade to get around the fluctuating compounded return %. So, if I use a fractional risk per trade then the order in which the trades happen would matter. But, if I use a fixed value of risk then the order of the trades wouldn't matter. 


Update Backtest


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.


This discussion is closed