A little while ago, I shared John Ehlers' MAMA and FRAMA indicators.
I decided to play a little with it, and show you the possibilities when you account for neutral fluctuations in the market.
So I present you the MAMA and FRAMA indicators, applied to AAPL over the period 2005-2015. Clearly, if you trade aggressively with all your funds on the very short term, your equity will increase the most. However, such strategies are not always replicable in real-life due to transaction costs and slippage/illiquidity issues. So just for the purpose of motivation/entertainment, here is an algorithm that turns 10k initial capital into more than 1 million in the course of 10 years. So really, this is a little (overexaggerated) demonstration to show you that you can improve your strategy if you take the cyclical behaviour of the markets into account. In order to view the resulting graph, clone the algorithm and run the backtest.
The number of trades is too high to generate a summary of the backtest, so you would need to perform backtests on individual years to judge its power statistically. In a more serious manner, if you plan on using (part) of this strategy, you should adjust the algorithm to trade less frequently. One simple way of doing so is changing the consolidation period. Right now, this is:
int _consolidated_minutes = 10
You can change this to a larger number of minutes, for example, 60 minutes, to decrease the trading frequency.
In any case, I hope you enjoy this little example.
Keep dreaming and relish your coffee ;)
JP B
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.
JP B
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.
JP B
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.
Michael Handschuh
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.
LukeI
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.
Michael Handschuh
if (quantity > 0) Order(_ticker, _trend_dir*quantity); _oldprice = _price;
It should look like the following to include the oldprice=price assignment in the if block:if (quantity > 0) { Order(_ticker, _trend_dir*quantity); _oldprice = _price; }
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.
JP B
// Order logic / (simple) risk management if (Portfolio[_ticker].IsShort == true) { pps = ((_oldprice - _price)/_oldprice)*100; if (pps <= -2.5M || pps >= 2.5M || _trend_dir != _old_dir) { // End position Liquidate(_ticker); } } else { pps = ((_price - _oldprice)/_oldprice)*100; if (pps <= -2.5M || _trend_dir != _old_dir) { // if direction is wrong // End position Liquidate(_ticker); } }
And this yields the profits from before (>1 million). So what do we learn from this? That it's smart to take profits early on short positions! Apparently shorts have the tendency to go from being profitable to being non-profitable; so liquidating when the position is in-the-money is a smart move. Just for consistency, I've also tested this with long positions but there it doesn't hold: it's more profitable to let the long positions 'run' instead of taking profits early. So thank you again for scrutinizing my code as we have now learned that there is a profit-taking anomaly between long and short positions. Take profits early on shorts, let long positions run! :) See my adjusted version of your code below (Sharpe of 1.45!):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.
JP B
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.
Jose Sobrinho
Hello guys, First time in here and still trying to digest a lot of data and good comments you guys put together... If someone can help with this idea... how can we buy per example, SQQQ everytime AAPL(part of this code) was supposed to be liquidated... and every time was supposed to buy AAPL as per the code, to sell the SQQQ... basically to use AAPL as the indicator but the trade the ETN SQQQ on the other direction... can someone please let me know? So, I tried to invert the operation to sell the inverse ETN (SQQQ) when was time to buy APPL and Buy this ETN when was time to sell APPL... for some reason, I am running out of the money... doing something wrong :( ... in case someone can take a look.
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.
Stephen Oehler
For what its worth, I'm having the same issue on a different algorithm. Just encountered it today. It seems that when I apply SetHoldings("SPY", 1.0m), which is a long position, it buys 1x worth of orders. However when I quickly try to go directly to a short position (SetHoldings("SPY", -1.0m), it buys -2x worth of orders (ostensibly to sell the ones I have, which is -1x, and then again to fully short it, which is another -1x). My thinking is there's a problem calculating how much the portfolio is worth at that point in time when you are requesting to short the position. Still looking into it.
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.
Jared Broad
Welcome @Jose! @Stephen, does it rejects the order to go short? Please send me your project id to support@quantconnect.com and I'll dig into it.
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.
Stephen Oehler
Ok so I found out that it was indeed rejecting orders to go short. I worked around this issue by doing the following when switching directly from a fully long to a fully short position (or vice versa): What I was doing: SetHoldings("SPY", -1.0m); // Attempt to directly take full short position from full long position (this results in many invalid orders) What I've put in place: SetHoldings("SPY", 0.0m); // Sell all first SetHoldings("SPY", -1.0m); // Then take short position In making this change, I went from having multiple invalid orders, to having every single order successfully filled. So this looks like a good workaround. Jared, attached is a project I was knocking around if you'd like to dig around it.
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.
Stephen Oehler
Can't vet for how this would affect trading fees, however. The workaround I mentioned above would effectively double the trades, right?
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.
Jose Sobrinho
Jared and Stephen, Thanks for your input.. @jared and Stephen I am still not understanding how to analize one stock and trade other. In order to keep it simple, I cloned your project Jared, that is checking the MA for the SPY and I tried to change to buy the SQQQ/QQQ ETN pair but the code is not trading... I think is related to the fact that, when adding these securities to the collection, they interfere on the numbers... So just to summarize, I was looking to keep everything as it is but just buy and sell these ETNs whenever the code was doing the same for the SPY... you will see on the code. Thanks for your help https://www.quantconnect.com/terminal/#open/206378
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.
JP B
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.
Jose Sobrinho
I will try to understand the LEAN one... but funny or strange that nobody had needed such thing yet? To use one stock and trade other... thanks
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.
Michael Handschuh
@Jose, I think you just need to uncomment the lines that subscribe to QQQ and SQQQ data. In LEAN you can't trade a security that you don't have price data for.
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.
Stephen Oehler
JP B, This is a really neat algo! Just for kicks, though, I applied it to a few other stocks and it didn't perform as well. I'm wondering if the indicators require some tuning per the underlying asset? Not to sound antagonistic, but I also wonder how much of the gain we're seeing is due to buy-and-hold-Apple having stellar performance these past few years? -Stephen
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.
JP B
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.
Stephen Oehler
Great discussion! Thanks very much for taking the time to write that. It is VERY impressive to have pulled in 11,000% total return as opposed to 840%. And with such low deviation on top of that. Does John Ehler discuss any techniques for calibrating the algorithm to the underlying asset? In particular, which parameters need to be calibrated? Thanks again, and I apologize if I'm pestering you with questions. This is fascinating stuff.
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.
.ekz. INVESTOR
Guy Fleury : Thanks! To be fair, Vladimir's version is the winning one: his original code uses price above/below kalman, and doesn't have the multiple methods. I built on his code and added multiple methods, including the Laguerre-Kalman crossover. Thanks for sharing these screenshots. I also ran comparisons of them all, using the Optimizer (and incrementing method # to 1,2,3,4,etc). Curious, which assets are you trading in these backtests, and over what time period? Please attach the winning backtest when you have a moment.
Fred Painchaud : Love this. Very informative and will help as I try this out. Not surprisingly, the KAMA indicators uses something similar. It uses the Kaufman efficiency ratio for the noise measurement, and also takes a floor period and ceiling period. It uses market noise though, and I think volatility** might be a better modifier for what we are trying to do here. I will share my results when done!
__________________
**Something I learned recently: Market Volatility ≠ Market noise. Sharing this link for the sake of others.
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.
Fred Painchaud
Yup. Short addition. TL;DR. Noise is specific to a signal/system. It's unwanted signal (disruptions) generally closely around main/wanted signal. Well, if noise is 1) frequent and 2) powerful wrt main, then, you have a problem getting ("hearing" so to speak) your main signal, you loose it in the noise, you can't filter it out. Enter signal-to-noise ratio. In trading terms, noise is retracements and big money checks, for instance. Volatility is another thing indeed. It's a rate, just like acceleration (rate of velocity change over time). It's the rate of price change over time. If you use noise to dynamize a lookback, you might end up biting to big money checks. Except maybe if you weight noise with volume. Volume will most likely attenuate noise created by checks enough so you don't signal trades. But I don't think I would bother. Well, my current opinion…
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.
Vladimir
.ekz.
Here is my solution how to calculate volatility-adaptive self.kalPeriod.
You've probably seen it in my thread Intersection of ROC comparison using OUT_DAY approach.
self.history = self.History(self.ticker, self.VolatilityPeriod, Resolution.Daily)
vola = self.history[self.ticker].pct_change().std() * np.sqrt(252)
self.kalPeriod = int ((1.0 - vola) * self.kalBasePeriod)
I'm sure you know how to find the best combination of self.kalBasePeriod and self.VolatilityPeriod.
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.
.ekz. INVESTOR
These are good analogies, especially how volatility is a rate. Simple and true.
Not sure I am following what you meant by this line though: If you use noise to dynamize a lookback, you might end up biting to big money checks. “Biting to big money checks” … is this a good thing?
Also, weighting noise with volume sounds interesting. Would the goal be to determine whether the noise is ‘real’ noise? If there is low volume vs high volume?
So as to keep this thread on-topic, we can continue this sidebar topic via chat. Are you on the Quantconnect slack or discord? I'm in both, with the same name: ‘ekz’.
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.
.ekz. INVESTOR
Vladimir: Thanks for this. I will give this a try ASAP.
Very much appreciated!
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.
Guy Fleury
.ekz.
The only changes made to your version were the start and end dates.
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.
Carsten
.ekz. valdimir
I'm trying to build a black swan hedge, running in parallel with a kind of In-Out strategy.
The idea ist to profit from the VIX spikes. If one buy very far out of the money call, like 100 Vix, they start to spike like crazy, 200-400 times the purchase price!!, please see the the link for the code.
To decide on the liquidation, I used a classic MACD, as well a MACD with a Kalman filter, like the examples in this post.
Everything much too slow response, some suggestions? Thankx
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.
Nitay Rabinovich
.ekz. First of all - Thanks for the contribution! really nice algorithm structure and I really liked the SmartRollingWindow class.
I've been playing around with taking this structure and trying to apply other indicators to it, most of them didn't come close to the performance seen here, but when I applied a rather simple EMA crossover with ETH I actually achieved a nice reduction in drawdown while maintaining the PSR and returns,
I wonder if I'm missing something in my code, or is this a valid crossover approach using simpler indicators
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.
.ekz. INVESTOR
Nitay Rabinovich: That looks great! Sometimes the simplest things work best :) It's been long suggested that 'old-school' trading strategies work great for crypto since it's a fairly nascent and inefficient market, so I'm not surprised the simple EMAs work well! Might be a good idea to try the logic in a crypto universe and see how it works. Vladimir & Fred Painchaud: I switched into holiday mode so I've been quiet, but I played around with the volatility-adjusted period in isolation and didn't see much success, unfortunately. I saw better results across assets using ATR based dynamic stops that I'm more familiar with (a multiplier of the recent ATR). Will share a universe crypto trend follower soon. I might just use a EMA version like the one Nitay Rabinovich shared.
Carsten: I played around with black swan hedges using SPY puts. Haven't tried VIX hedges, but I've heard they're generally more successful. Good luck!
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.
Nitay Rabinovich
.ekz. - Happy holidays!
I actually wanted to test if this EMA approach is only fitted to ETHUSD, so I modified the code to fit multiple assets, I manually set BNB, ETH, and SOL. And I set the benchmark to BTC (which is… questionable I guess?)
Maybe it would perform even better with dynamic universe selection, but overall seems like the concept works well with multiple assets as well, I did see some issues with orders so I think placing orders needs fixing.
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.
Nitay Rabinovich
Anton Kiselev - I'm really not that experienced with universe selection in general, but if I'll find the time I'll try to research some approaches to filter probably by volume, volatility, and liquidity (probably via https://www.bitcoinmarketjournal.com/token-velocity/). and there's also the question of the rebalancing period.
Regarding short-selling - it's an interesting idea that's definitely worth checking!
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.
.ekz. INVESTOR
Good stuff Nitay Rabinovich, applying it to a basket of cryptos. I have some crypto-universe code that may be helpful --it includes volume thresholds, rebalancing logic, and a few other handy things. Will share after cleaning up a bit.
In the meantime, one thing i recommend you do for your current system, is running it with Minute resolution --doing this will give you higher precision, using bid and ask prices, and the results will be more reflective of what to expect in "real life".
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.
Nitay Rabinovich
.ekz. - So I tried a couple of things -
1. SImply changing the resolution for all to minute data, including the consolidation handler and rolling window updating - caused way too many trades, pretty much killed the algorithm with excessive trading.
2. Tried to mitigate with consolidating on daily resolution but using minute data for the cryptos and indicators - also reduced performance massively. (tried with several different periods to see their effect, but below you can see the best case)
Still has excessive trading…
3. Lastly I changed the crypto's resolution to minute, yet kept both the indicators and the consolidation handler on a Daily resolution. And that… well created this amazing backtest.
So the question is - what's to expect in “real life" - I know for a fact I won't run an algorithm trading crypto per minute, so 1 is out of the question, but is using daily resolution for indicators and consolidation handler considered “painting a pretty picture" that only works in backtests? No matter the answer, it is a pretty 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.
.ekz. INVESTOR
Nitay Rabinovich #3 is the way to go, and I'm glad it looks good!
Over the weekend I'll take a closer look to see if any bias has been introduced that may invalidate these results. I will also share the additional universe code.
Good stuff!
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.
.ekz. INVESTOR
Hi Nitay Rabinovich, I did a more thorough walk through of your last backtest and noticed/fixed something:
TLDR:
Currently, when we look at our rolling windows for exit/entry signals, we were looking at old data (yesterday's data). Addressed this by changing where we update the rolling windows. Overall performance is impacted negatively.
Details:
In the attached backtest, I made the code change to address this. Now we are updating the rolling windows at the right time, right after indicators are updated. So at 7pm (19:00), the sequence of events is now:
Note:
I changed the name of the method from “UpdateIndicators” to “UpdateAssetWindows” to be more accurately reflect what the function is actually doing. Also, OnEndOfDay is now only used for plotting charts..
Code diffs:
https://www.diffchecker.com/O6AKaeJ9
Take-Away:
The results arent as favorable (less profit, higher drawdown), but i think this is a necessary change for more predictable behaviour. That is, unless we can rationalize why it is better to use yesterdays prices to make decisions today. Perhaps that can be part of the strategy, but it does seem that it would be arbitrary at best.
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.
.ekz. INVESTOR
FYI: I started a new thread for EMA crossovers, so we can keep this thread focused on Kalman filters
Nitay Rabinovich : let's continue the EMA conversation there, pls.
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.
.ekz. INVESTOR
Vladimir : I have a follow up question up on our earlier topic, calculating volatility-adaptive lookback period. Specifically around this code:
My question: How do you determine the best combination of self.kalBasePeriod and self.VolatilityPeriod?
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.
Ariel Nechemia
Hey! I've been following the development of this strategy and have been trying to learn from all the insight that all of you have shared, super interesting!
Just a thought. From what I understand, this is a long only strategy. For the sake of robustness, would it make sense to test the strategy's performance trading in both directions? With the cycles that any asset goes through, would we be inadvertently overoptimizing the strategy by only testing a long only strategy when the crypto market has seen an incredible bull run?
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.
.ekz. INVESTOR
Hi Ariel Nechemia, thanks for the note, and sorry for the late response.
So, going long in a bull market isn't over-optimization, it is arguably conventional wisdom. IE: it's what you do.
Similarly, systems that trade short only strategies often have a regime filter to make sure the market is in a downtrend before taking any positions. We are doing the same here --we are using these indicators to detect bullish price action, and taking long positions accordingly.
You can certainly make this bidirectional (long/short), and introduce additional conditions with the inverse logic (swap ‘<’ for ‘>’). This would effectively introduce bearish regime filters, during which you would go short.
Hope this helps!
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.
Jack Pizza
what's the point of these mental gymnastics? If you use all available data sharpe drops to a pitiful 1….. why are you over fitting by only going back to 2020?
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!