Hi,
Here's another low capacity algo for you. You'll need to find more suitable stocks to trade a larger account. I do not recommend trading stock 'Y' with it as it is likely that a number of people are going to try that where I have published this script. That will likely ruin gains for that stock. I have a screener that can find suitable stocks.
This a mean reversion variant. I take the triangular moving average of the candle averages. Each of these candle averages is calculated by summing the open, high, low, and close and dividing by four. To calculate the distance from the tma to set the buy and sell points, I use half of the full range of the rolling window and subtract or add accordingly.
I have componentized the main calculations in the TMA2 class, so you can quickly copy and paste this component into more complex algos.
Use at your own risk.
Regards,
Warren Harding
Jared Broad
We have quote data coming soon :) Hopefully, we can give you realistic spreads on some of these low capacity algorithms.Â
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.
Warren Harding
Awesome news about the quote data. I have to try out the new debugging tools too.
SLs
Hi, Warren Harding,
Thank you for this algo, this is really an example for me that quant trading is working.
Could you, please, explane how you do stocks screener , how to do search of suitable stocks for this algo, wat is important criteria to looking for ?Â
Warren Harding
To screen, I calculate the returns on a per stock basis, then rank by returns. Note that there is a survivorship bias type of problem ingrained in this approach. However, you can keep an eye on the number of trades to overcome it. The backtest above has 894 trades. That's a fair size sample set which suggests that the pattern of price action with this stock has actually been suitable for the TMA2 approach.
Quantconnect does not easily let you see the returns on a per stock basis as best I know, but it can be done. You could use the trade log and recalculate the returns from that. Or you could do as I've done, I have a minimalist backtester that I integrated right into the Quantconnect script that lets me screen to see which stocks are behaving well for whatever strategy I want. That might not be the easiest approach but I have a proprietary minimalist backtester handy that I have already written. This approach gives me a lot of power where I can see which stocks have been behaving appropriately in recent time for any given strategy.
Much of the work is in the screening. TMA2 is actually a B-grade strategy kernel. I'm not for giving my best stuff away, sorry.
Daniel Chen
It's an amazing algorithm! I would recommend combining the universe selection and the TMA2 approach to get better performance. My idea is that we could apply the TMA2 trading logic on stocks filtered by coarse and fine selection. As long as the number of filtered symbols is set to be small in the universe selection, the backtest result actually reflects the return on a per stock basis. Let me know if you have better ideas, thanks!
Aaron Tawil
Daniel Chen actually gave that a try - thinking the same thing and applying the boot camp to it. Still needs some tweaking to get right though. The algo I cam up with just seemed to buy and hold, so I am sure I am doing something wrong. But working on it. Would love to try and include an RSI alpha metric to also help make decisions.
Warren Harding
Thanks Daniel. I'll consider your advice.
Warren Harding
Hi Daniel. It sounds like you are suggesting something similar to what I have already done. I have a multi-stock version that can screen for suitable stocks as the backtest proceeds in a rolling like fashion. I could move the screening into a coarse selection function and that would eliminate the need for ticker lists. I'm using a high dollar volume ticker list right now.
Valery T
Your algorighm does not re-invest the profits. Why?
Warren Harding
Hi Valery. You can only trade so much before you'll run into problems with orders not being filled.
Valery T
Hi Warren.
From your experience, does paper trading with IB reflect the real trades (orders being filled)?
Warren Harding
I haven't used IB's paper trading platform.
Douglas Stridsberg
Valery TÂ IB paper trading is unlikely to demonstrate realistic execution of this algorithm. Toy algorithms like these (submitting arbitrarily tight limit orders and crossing your fingers they get filled) have been submitted before and should not under any circumstances be relied upon to produce profitable live trading. A simple test of robustness (change date range, tickers, fee assumptions, etc.) highlights how cherry-picked the range displayed in the original post is.
Please always do your own thorough research before committing any kind of capital to any kind of strategy, no matter how beautiful the backtest looks to be.
Warren Harding
Hi Douglas, good to see you again. Unlike Beer Money, you can increase the period so the limit orders aren't so tight. It will still profit in backtesting. I chose the last year's date range deliberately as market dynamics change, with 894 trades being put through there is a fair size sample set just trading the last year. You can't just change the ticker, many stocks simply don't revert to the mean as this one does. I use the standard fees. You are right about being careful live trading any strategy, it may simply not perform as expected due to market reaction or some other reason. I still think you should start with exceptional backtests, then see which ones perform well live. Starting with a mediocre backtest is almost certainly going to bring you mediocre results.
Ian Larson
https://www.quantconnect.com/alpha/59c617b46d2ecebdafb790c52 I've been meaning to ask @Douglas Stridsberg about that one. Obviously the equity curve was negative during backtesting so...must be some method to the madness? This one is nothing to sneeze at though: https://www.quantconnect.com/alpha/06bffa9edd7355cdaab263fb2
Â
Jared Broad
I encouraged the submission of Procyonoides. It has a solid core thesis and is mostly negative due to the retail spread of our data vs the algorithm concept itself. Institutions have a better ability to execute and access to different contracts so a consistent slope in either direction can still be a valuable signal.
The alpha stream thesis and research technique is more important than profitability. Many of the biggest funds are simply seeking predictable/reliable uncorrelated out of sample curves.
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.
Warren Harding
Now, THIS is an unrealistic backtest. 3131728331330290000% annual return! 1.3% drawdown! I was hoping to be so rich. Again. Too bad it utterly fails. When you lower the position sizing to a realistic value that considers what will actually fill, the algo fails. The fees rise relative to profits. And it suffers from slippage problems that are compounded by the high frequency (I built a limit order version, it doesn't work either). And it's showing exponential growth that isn't realistic given the fill limitations.
At 98.029% annual returns and 4.9% drawdown TMA2 isn't actually that impressive. It passes all of my reality checks though.
Valery T
Hi Jared,
What are your criterias for selecting such algo?
Hao Bin Zhang
Warren Harding does the interactivebrokermodel actively take into account slippage or model the impact of large market orders? Also, how can an algorithm achieve 16 Sharpe even if it is relatively high frequency! That is really amazing!Â
Warren Harding
I haven't used the brokerage models as much as I should. I've been using limit orders more and more as I don't trust slippage approximations. Also high frequency trading generally fails due to the slippage adding up with market orders. The default setting does not model large order impacts, I've been keeping order sizes small to stay on the safe side. High frequency algos can definitely profit well, those small gains can really add up.
Warren Harding
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!