I have spent many hundreds of hours now, fiddling around with Quantconnect and have nothing but praise for the effort they have made.
Debugging with the online version of Lean is far from satisfactory – I like to loop through the underlying back test code, but of course you always have the option of buying your own data and downloading Lean. My two other “complaints” are the logging allowance and the ability to run only a limited number of back tests at any one time. Both of these problems can be ameliorated by taking out a paying subscription.
Dead Quantopian was no better on the debugging front but had more generous logging capability. And you could run as many simultaneous back tests as you needed or wanted. Farcically however (if I remember correctly) , absolutely nothing was downloadable. With Quantconnect you can download trades, logs and results and work them further through a spreadsheet. Far better.
I have spent many happy hours in the futile endeavor of seeking algorithmic profitability from penny stocks. I may well be missing crucial rules – perhaps even an exploration of SEC filings would help. But currently, the prospects do not look attractive.
The answer of course is to be an illegal insider. One who organises the pump and benefits from it by shafting investors. Others profit handsomely by their marketing tactics – suckering in punters who subscribe to useless trading rooms and buy crappy videos at exorbitant prices.
The purpose of this post however is not to whine at my futile and failed efforts but to give something back to Quantconnect for the excellent free resources I have enjoyed.
I am sure there will be many things I have got wrong but if nothing else, the attached code may enlighten some on the way, or ways, to place orders for intraday trading.
I have no doubt whatsoever that changes would need making in the light of paper and live trading experience of this system, but I have not taken matters that far.
Perhaps others might like to adapt and improve my code – who knows, they may even find profit.
The system is simplicity itself. It uses raw, unadjusted price data.
You can not use split adjusted price data to test penny stocks because of the large number of reverse splits that take place. You will find historic back adjusted prices reach levels in the hundreds of thousands of dollars per share or even millions and hence any sort of position sizing becomes impossible.
The problems of using raw data include ignoring the day of a reverse split when an enormous price increase will give an erroneous signal. My code deals with this.
If the price during the trading day exceeds the previous day’s unadjusted close by a predetermined amount, a short position is taken using a limit order. Wide stop loss limit orders are immediately placed as well as a graduated series of profit taking limit orders. You can’t use market orders with these highly illiquid stocks.
Sounds simple enough but the devil is in the detail of the Quantconnect back testing engine. Working out how to put the orders on and making sure that they all cancel each other out correctly when filled. I did not find the effort a trivial task.
In any event, the work is done and as it stands the system is not profitable. Winning trades are 90% or over but in a similar fashion to selling naked options, each losing trade is vastly greater in average dollar value than each winning trade. Narrower stops do not appear to help.
Oh, and no account is taken for the availability of stock to borrow or the charges of so doing, so the system is undoubtedly worse than it looks.
If you enjoyed this article and my code, see if you can help improve it.