Inspired by T Smith idea to implement Gary's Antonacci's dual momentum approach to ETF
selection in "IN OUT" strategy.
-The execution code has been completely changed to keep levarage under control and avoid
insufficient buying power warnings.
-To calculate returns I used widely used in industry momentum with excluding period.
-Modified components that are more in line with the strategy.
-The IN OUT part of the strategy has not changed except for some cosmetics
to make it more readable for myself.
"DUAL MOMENTUM IN OUT" nearly doubled "IN OUT" Net Profit while maintaining risk metrics at the same level.
Compounding Annual Return
30.164%
Sharpe Ratio
1.667
PSR
97.773%
Beta
0.057
Drawdown
19.300%
Annual Standard Deviation
0.154
Here is my second version of "DUAL MOMENTUM-IN OUT".
Carsten
Hi Vladimir
good to see you again here...just some off topic question...i arrived as well from quantopian and try to translate/learn porting an algo from zipline. I did the tutorial and the framework they are using looks far better than quantopian but the warming up and other stuff is a bit nerve ripping...
Do you thnik it would be difficult to move that algo aboue into the quantopian framework concept?
# Universe Model self.SetUniverseSelection(MyUniverseSelectionModel()) # Alpha Model self.SetAlpha(MOMAlphaModel()) # PortfolioConstruction Model self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) # RiskManagement Model self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(1)) # Execution Model self.SetExecution(ImmediateExecutionModel())
I translated already an algo with pre-set ticker, filtering and ranking, if you are intersted i dont mind to post it here. It still has some issus with warm up.
For me alone its quite hard, but I know that you are a very experienced programmer..
Moving to the framework it might a lot easyer to contribute as one only need to improve some modules and don't need to touch the whole code, and one can reuse a lot from other algos.
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
Hi, Carsten,
For zipline, you can skip warm-up and consolidation because they are built-in features.
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
Hi Carsten,
if you are intersted i dont mind to post it here
I have created thread Transition from Quantopian to QuantConnect.
You can post it there.
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.
T Smith
Great work. Adjusting the tradeout scheduling and using hourly rather than daily resolution for our signal instruments, I've managed to reduce drawdown.
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
T Smith
Thank for the improvement.
"Many a little makes a mickle".
There was a typo in the code on line 154.
I deleted the second "if".
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.
Vovik
In this backtest I used the original T Smith setup:
IN and OUT assets determined by momentum (IN: QQQ/IWF, OUT: TLT/IEF), 100 day simple return
Net Profit 2097.037%; Sharpe Ratio 1.743; PSR 97.247%; Drawdown 17.900%; Beta 0.026;
It also sufficiently beat the setup of Peter Guenther.
IN: QQQ:1, OUT: TLT:0.5 + IEF:0.5
Great job Vladimir and T Smith.
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.
Nathan Swenson
Hello Vovik,
Did you fix the issue with the original T.Smith algo? It has many error in the log with invalid trades due to margin violation. I believe Vladimir's has fixed those issue, but trades different instruments.
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.
T Smith
Yeah, Nathan Swenson he is using Vlads corrected trade logic to ensure sells are placed before buys and leverage doesn't go beyond 1. He is also using the updated sheduling and resolutions. This gets us out the market quicker, but avoids over trading/rebalancing whilst 'IN'.
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.
Vovik
Nathan Swenson,
In this backtest I have no margin violation warnings.
Here is the full log.
Algorithm Initializa: tion: Data for symbol DBB has been limited due to numerical precision issues in the factor file. The starting date has been set to 1/4/2007.
Algorithm Initializa: tion: Data for symbol UUP has been limited due to numerical precision issues in the factor file. The starting date has been set to 2/19/2007.
Algorithm Initializa: tion: Data for symbol DBB has been limited due to numerical precision issues in the factor file. The starting date has been set to 1/4/2007.
Algorithm Initializa: tion: Data for symbol UUP has been limited due to numerical precision issues in the factor file. The starting date has been set to 2/19/2007.
Algorithm Initializa: tion: Warning: when performing history requests, the start date will be adjusted if it is before the first known date for the symbol.
2008-01-01 00:00:00 : Launching analysis for b3e5c2897bc5099bb64e69aa0ecedcca with LEAN Engine v2.4.0.0.10016
2007-08-28 10:00:00 : Algorithm warming up...
2008-01-01 00:00:00 : Algorithm finished warming up.
2020-12-11 16:00:00 : Algorithm Id:(b3e5c2897bc5099bb64e69aa0ecedcca) completed in 631.42 seconds at 3k data points per second. Processing total of 2,197,238 data points.
Perhaps the problem is something else.
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.
T Smith
Vladimir regarding your comment on using more than one indicator to trigger the out of market. I have had a go at implementing it here:
Would appreciate your feedback!
Nathan Swenson this seems to solve the issue of SHY taking us out the market without another signal.
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.
Goldie Yalamanchi
That's really great T Smith I am not a huge fan of FDN or QQQ but this strat looks great! Quick question...
Are these the only changes to code to change if you don't want 5 signals as the IN/OUT? Say 4 or 3 for example...
pctl = np.nanpercentile(mom, 5, axis=0)
if self.no_signals > 5:
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.
EllaHamilton
a great algorithm, we will test it on a large scale, and then leave you a review.
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
This strategy, like its predecessors in the other 2 or 3 “...In Out...” threads, is totally dependent on its up/down trend declarations. And the first question to ask should be: How reliable is this trend definition?
I see the strategy as a variant to a 60-day over a 252-day moving average crossover to bond switcher, but still responding to daily price variations. The advantage goes to being long for longer periods than being in bonds. And this translates - in an upmarket - to taking a higher average percent profit than when it loses a trade (about 2:1). And there, even with a hit rate in the 50s, you are bound to make some overall profits just for playing the game.
The above chart illustrates where I'm at presently. There was some leveraging (1.4x). Not excessive when compared to the 89.86% CAGR. The strategy could more than afford to pay the leveraging fees. 3x-leveraged ETFs were used which made the strategy behave the same as if leveraged by 4.2x. The initial capital was set at 100k as most here. Increasing the initial capital to 1 million did increase performance about 10-fold since the strategy is fully scalable.
To get there, I modified a few things. One of interest might be the following section:
mom['S_G'] = (mom[self.SLV] - mom[self.GLD])*0.0 mom['I_U'] = (mom[self.XLI] - mom[self.XLU])*0.0 mom['A_F'] = (mom[self.FXA] - mom[self.FXF])*0.0
which flatlined most of the momentum signals leaving only UUP. Why do this? It resulted in higher profits. It also said that those signal components were not needed or could be considered as irrelevant to the task at hand. There is a lot that could be said about this strategy's strengths and weaknesses.
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.
Hannes R
Hello Vladimir and all,
I see your many contributions and I am still a complete newbie, thank you for sharing all these invaluable insights and your experience online for everyone to learn from and contribute too (me too hopefully, one day).
I will need to spend several hours to understand your code and the logic behind , (would be great if there were comments in the code explaining the logic =D) but have some question around lookback bias in the meantime. This strategy is almost too good to be true - what are some of the items in here that may have lead to over-optimization? I see Guy Fleury's expert critique on the MA crossover periods defined a fixed value, what are some of the other things? Would you say that the asset selection could also be biased?
Thank you for your teachings!
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
Guy Fleury,
I am aware of your incredible ability to send any profitable strategy into the sky since we
discussed Andreas Clenow's momentum in 2017.
It's no secret, but simple math, that if you use 3x tools and apply a 1.4 leverage to
a strategy with 30% CAGR you should get much more than 150% CAGR.
You got 89.86% CAGR because these 3x instruments only started trading in 2010.
The decision to use 3x tools and a leverage greater than 1.0 is usually made
at the last stage of development strategies.
Before that, we must use 1x tools and use 1.0 leverage for compatibility of results.
I can also see that you are starting to improve the strategy in the right direction by
cutting half the sources.
Hopefully I can see results where you apply pressure points and other tools from your
toolbox.
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.
T Smith
Hi Guy Fleury
Great to see you in the discussion,. I have played with using just dollar as our signal, and have decrease sharpe considerably. whilst bring beta to 0.5.
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.
T Smith
Vladimir totally agree. Best to build an algo with no leverage and just look to improving sharpe ratio. Leveraging later is then an option. Have you had much of a look into the concept of requiing more than 1 signal to exit the market?
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
T. Smith,
I don't have a solution right now, but I definitely want to either change the decision logic or reduce the number of sources.
Two months ago, this algorithm had only 4-6 sources and much fewer parameters.
I have played with using just dollar as our signal.
USD in this strategy has a negative sign.
mom[self.UUP] = mom[self.UUP] * (-1)
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
@Vladimir, your version of this trading strategy was already tested with 1.0x leverage. My task is to find out if it can scale up and do more, including to see if it can support leveraging in order to find the strategy's operational limits. Something I need to know before the end of the testing process. Otherwise, I will be wasting my time if those limits are found nearby, later, or much worse, after going live.
The way we test trading strategies, they have to generate all their profits from within, no matter what trading methods we use. There are no external funds added during a simulation. The tools we have are part of better stock selection, better timing, better gaming, better process amplification, better trade modulation, better protective measures, etc...
Leverage can be used over selected time periods where you anticipate for whatever reason that it will increase the potential return on your trade. It is like saying: you do not use it all the time, but can use it where you think it might count.
Nonetheless, it is a CAGR game, and basic math will matter. You can apply limited leveraging when your added alpha exceeds leveraging costs (here, the alpha being the excess return over the market average).
You want to know the strategy's limits before your “feasibility” simulation study ends. I have looked at many strategies that do not pass these basic tests. I usually lose interest quite rapidly and expedite their journey to file 13.
Here is a fun observation. After flatlining 3 of the signal components, we are left with a minus UUP. The thing is that if you reverse this signal to +UUP you should see the strategy lose a lot of money. But, if you do this, you get about the same profits, within 0.5% of each other on my 1 million initial capital scenario. Putting into question the “real” value of that signal? Note that you still get a little more with the negative signal (-UUP).
What kind of signal, that it be negative or its reverse, can produce about the same results? I would venture one that does not matter which side it is on.
How about flatlining UUP making the strategy having no switching signal, no trend definition? What would be the result? Such a move reduced overall profits by almost half (-49%). But still managed a +91.25% CAGR compared to the 98.73% and the 98.49% CAGR in -UUP and +UUP respectively. Therefore, UUP's presence was worthwhile, while its predictive powers were nil since you made about as much that UUP declared the trend up or down.
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
Guy Fleury,
This strategy yields good results, but I don't like just one word in the code in line 124,
and that word is any()
if (extreme[self.SIGNALS + self.PAIR_LIST]).any():
Just imagine that you are the president of the United States.
You invited the top twelve generals of the country to help you make decisions whether to start
a war with country x or not.
Eleven generals said no, but one said yes.
What will be your decisions?
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
Mark hatlan
Symbols are parameters in this strategy.
You can try whatever you want and choose the ones that suit you most.
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.
Mark hatlan
Yeah I understand that, I was just wondering if you had a specific reason for having those 2 for the stocks as opposed to any other 2, just because those 2 have behaved similarly. Thats all.
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.
Shile Wen
Hi Joao,
For personal "version control", each time a backtest is run, the code used in execution is saved in the backtest details.
For collaborative version control, one idea is to use Skylight and and turn the local Skylight folder into a Git repository so that version control can be done.
Best,
Shile Wen
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
Joao Antunes,
Thank you for sharing your great Alpha Model v2.5 Dual Momentum with Out Days.
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.
Will Berger INVESTOR
Guys,
I have been running the Model v2.5 Dual Momentum with out Days for the last month. The draw down so far is 10%+. Not insignificant.
I believe this is being caused by the rise in the 10 year treasury yield and growth stocks are feeling the impact. The 3 trade signals in the algorithm today do not take this into account and was wondering should there be a 4th and what should be the action.
In this case both equity and bonds are suffering. Would it not make sense to sell both equity and bonds when detected?
Any thoughts?
Will
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
Will Berger,
Correlation of daily returns between stock index and Treasury bonds has been negative not only
in the last 10 years.
You can find research that proves that over the past 85 years or even over the past 250 years.
But sometimes the correlation can change sign, or both go up, or both go down.
In the latter case, it makes sense to switch from Treasury bonds (TLT, TLH)
to Treasury bills (SHY, SHV).
You can try this.
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.
Will Berger INVESTOR
Ok. Will try it out.
On my first point, the algorithm in my observations from the past has done a good job of not over reacting when the market declines, but I don't think it is handling the scenario we are in today where the us yield is rising and the growth stocks like qqq are being signifcantly being effected by it. Maybe choosing a value stock as the alternative dual stock will do the trick. Will play with that as well.
Thanks for the suggestion Vladimir.
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
Will Berger,
Symbols are parameters in this strategy.
You can try whatever you want and choose the ones that suit you most.
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.
PieterStam
Neat looking code will definitely play around with this
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.
Mohamed Ajmal
Just a theoretical suggestion - our signals are almost mostly external - not of our own assets. Can we add a signal where if our asset performance is deviating from a pattern by x margin, we return to cash/bonds too.
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.
Alexandre Catarino
Hi Mohamed Ajmal ,
Your theoretical suggestion describes how we use alternative data in QuantConnect/Lean. For example, TiingoNews is an external signal. Could you please open a thread for the second question with mode details (e.g.: a practical example on how it should work, perhaps with a backtest)? I think it's out of the scope of this thread.
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.
Alan chen
Dear Vladimir,
Many thanks for sharing this strategy and I have spent some time studying it. I made some minor adjustments to the code and have it live on a paper account with IB. However, I come to cross a problem and hope you can share some insights. the backtest version stayed in Bond ETF since June 2021, but the live version got in and out of equity since June 2021 multiple times during the same period. Have your code experienced such behaviors? what could the possible causes?
Many 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.
Vladimir
Alan chen,
Can you share the code with some minor adjustments?
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.
Kamal G
I saw the same behavior on V2.5 of Dual Momentum. I haven't had a chance to troubleshoot it yet… hoping someone already has?Below is a capture of the orders on a paper trading account I ran it with for a while.
I see two issues where it quickly goes back and forth between selected equities (not altogether a problem per say but you wouldn't want it trading so often) and another where algo makes the new order before liquidating existing holdings.
2021-08-02T15:10:00.6621505Z SPY 440.31 -20 Market Filled Liquidated - Interactive Brokers Order Fill Event
2021-08-02T15:10:02.8101982Z QQQ 366.46 23 Market Filled Interactive Brokers Order Fill Event
2021-08-04T15:10:03.8015137Z SPY 0 19 Market Invalid
2021-08-04T15:10:04.8019805Z QQQ 366.93 -23 Market Filled Liquidated - Interactive Brokers Order Fill Event
2021-08-05T15:10:04.8010877Z SPY 440.89 19 Market Filled Interactive Brokers Order Fill Event
2021-08-09T15:10:05.8000722Z SPY 441.8607 -22 Market Filled Liquidated - Interactive Brokers Order Fill Event
2021-08-09T15:10:08.8963402Z QQQ 368.3075 26 Market Filled Interactive Brokers Order Fill Event
2021-08-13T15:10:14.800238Z QQQ 368.455 -26 Market Filled Liquidated - Interactive Brokers Order Fill Event
2021-08-13T15:10:15.8012856Z SHV 110.475 89 Market Filled Interactive Brokers Order Fill Event
I'd say the same problem would be happening on other versions of this algo too.
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
Kamal G,
Can you share the code with where it quickly goes back and forth between selected equities?
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.
Kamal G
Hi Vladimir,
Attaching the version in question with a backtest starting in 2020. Points below.
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
Kamal G
I see that you modified slightly my version 2.5
But this should not affect the insufficient buying power.
Here is a slightly modified version 2.51, where I switched to minute data for the traded symbols, using your setting and SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin).
I do not see any insufficient buying power order errors or orders with stale prices.
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.
Alan chen
Dear Vladimir,
sorry for the late response. Was occupied by other events and unable to log in in the past couple of days.
Here is the code i used for live paper trading. Basically, i changed the code to ONData, instead of Scheule.On and had it on paper trading since Mid July 2021. Now i have two issues with the code:
===============================================
import numpy as np
class MarketTimingRuleStrategy(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 8, 1) # Set Start Date
#self.SetEndDate(20019, 12, 31) #Set End Date
#self.SetEndDate(2021,3,7)#set end date
self.cap = 100000
# Teck Stocks: Largest 100 companies on NASDAQ
self.STK1 = self.AddEquity('SSO', Resolution.Daily).Symbol
# Tech Stock: FDN tracks a market-cap-weighted index of the largest and most liquid U.S. Internet companies.
self.STK2 = self.AddEquity('FDN', Resolution.Daily).Symbol
# US Treasury Long Term ETF: TLT tracks a market-weighted index of debt issued by the US Treasury with remaining maturities of 20 years or more.
self.BND1 = self.AddEquity('TLT', Resolution.Daily).Symbol
# US Treasury Medium Term ETF: TLH tracks a market-weighted index of debt issued by the U.S. Treasury. Remaining maturity must be between 10 and 20 years.
self.BND2 = self.AddEquity('TLH', Resolution.Daily).Symbol
self.ASSETS = [self.STK1, self.STK2, self.BND1, self.BND2]
# Overall Market
self.MKT = self.AddEquity('SPY', Resolution.Daily).Symbol
# Industrial: XLI tracks the broad US industrial sector. A 7% drop over an approx. 3-month trading period is considered a substantial drop
self.XLI = self.AddEquity('XLI', Resolution.Daily).Symbol
# Utlities: XLU tracks a market-cap-weighted index of US utilities stocks drawn exclusively from the S&P 500.
self.XLU = self.AddEquity('XLU', Resolution.Daily).Symbol
# iShares Silver Trust (NYSEArca: SLV)
self.SLV = self.AddEquity('SLV', Resolution.Daily).Symbol
# SPDR Gold Trust (NYSEArca: GLD)
self.GLD = self.AddEquity('GLD', Resolution.Daily).Symbol
# Currencies ETF: FXA tracks the changes in value of the Australian dollar relative to the US dollar.
self.FXA = self.AddEquity('FXA', Resolution.Daily).Symbol
# Currencies ETF: FXF tracks the changes in value of the Swiss Franc relative to the US dollar.
self.FXF = self.AddEquity('FXF', Resolution.Daily).Symbol
# Resources: Investco's 3 industrial metals DBB ETF. A 7% drop over an approx. 3-month trading period is considered a substantial drop
self.DBB = self.AddEquity('DBB', Resolution.Daily).Symbol
# Currencies ETF: UUP provides inverse exposure to an index of USDX futures contracts that rises in value as the dollar appreciates relative to a basket of world currencies.
self.UUP = self.AddEquity('UUP', Resolution.Daily).Symbol
# Natural Resources: IGE tracks a market-cap-weighted index of US-listed natural-resource-related companies.
self.IGE = self.AddEquity('IGE', Resolution.Daily).Symbol
# Cost of debt: The SHY ETF (iShares 1-3 Year Treasury Bond) provides the signal. SHY tracks short-term US Treasury debt (1-3 years)
# and changes in this debt’s ‘risk-free’ interest yield should be indicative of changes in firms’ cost of debt which is based on the
# risk-free rate (risk-free rate + risk premium). A 60 basis points increase (i.e., drop in the bond price) over an approx. 3-month
# trading period is considered substantial.
self.SHY = self.AddEquity('SHY', Resolution.Daily).Symbol
self.FORPAIRS = [self.XLI, self.XLU, self.SLV, self.GLD, self.FXA, self.FXF]
self.SIGNALS = [self.XLI, self.DBB, self.IGE, self.SHY, self.UUP]
self.PAIR_LIST = ['S_G', 'I_U', 'A_F'] #Silver - Gold, Industrial - Utilities, Australia - Swiss Franc
self.INI_WAIT_DAYS = 15
self.SHIFT = 55
self.MEAN = 11
self.RET = 126
self.EXCL = 5
self.leveragePercentage = 101
self.selected_bond = self.BND1
self.selected_stock = self.STK1
self.init = 0
self.bull = 1
self.exit = None
self.count = 0
self.outday = 0
self.in_stock = 0
self.spy = []
self.wait_days = self.INI_WAIT_DAYS
self.wt = {}
self.real_wt = {}
#self.SetWarmUp(timedelta(126))
#self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen('SPY', 100),
# self.calculate_signal)
#self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen('SPY', 120),
# self.trade_out)
#self.Schedule.On(self.DateRules.WeekEnd(), self.TimeRules.AfterMarketOpen('SPY', 120),
# self.trade_in)
#self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.BeforeMarketClose('SPY', 0),
# self.record_vars)
symbols = self.SIGNALS + [self.MKT] + self.FORPAIRS
for symbol in symbols:
self.consolidator = TradeBarConsolidator(timedelta(days = 1))
self.consolidator.DataConsolidated += self.consolidation_handler
self.SubscriptionManager.AddConsolidator(symbol, self.consolidator)
self.lookback = 252
self.history = self.History(symbols, self.lookback, Resolution.Daily)
if self.history.empty or 'close' not in self.history.columns:
return
self.history = self.history['close'].unstack(level=0).dropna()
self.update_history_shift()
def consolidation_handler(self, sender, consolidated):
self.history.loc[consolidated.EndTime, consolidated.Symbol] = consolidated.Close
self.history = self.history.iloc[-self.lookback:]
self.update_history_shift()
def update_history_shift(self):
self.history_shift_mean = self.history.shift(self.SHIFT).rolling(self.MEAN).mean()
def returns(self, symbol, period, excl):
prices = self.History(symbol, TimeSpan.FromDays(period + excl), Resolution.Daily).close
return prices[-excl] / prices[0]
# edit: AK 1
def OnData(self, data):
mom = (self.history / self.history_shift_mean - 1)
mom[self.UUP] = mom[self.UUP] * (-1) # measure of USD (what is the relationship?)
mom['S_G'] = mom[self.SLV] - mom[self.GLD] # momentum of silver - gold. silver has fallen more than gold in bear markets, but risen more than gold in bull markets.
mom['I_U'] = mom[self.XLI] - mom[self.XLU] # momentum of industrial minus utilities (increase of risk taking appetite as cyclical stocks outperform defensive stocks)
mom['A_F'] = mom[self.FXA] - mom[self.FXF] # momentum of australia minus swiss franc (increase of risk taking appetite as australian is commodities currency vs franc which is a saft haven currency)
# numpy.nanpercentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=<no value>)[source]
# Compute the qth percentile of the data along the specified axis, while ignoring nan values.
# Returns the qth percentile(s) of the array elements.
pctl = np.nanpercentile(mom, 1, axis=0)
# Get out (i.e. a short time out of 15 days) once there's extreme price movements in any (or some or all) of the signals, as defined by pct1,
# If this short-time out is accompanied by a clear signal from any of the 3 signal pairs, which signifies that the fundamentals have changed,
# then stay out for much longer, as the wait.days become 15*15 days.
extreme = mom.iloc[-1] < pctl
self.wait_days = int(
max(0.50 * self.wait_days,
self.INI_WAIT_DAYS * max(1,
np.where((mom[self.GLD].iloc[-1]>0) & (mom[self.SLV].iloc[-1]<0) & (mom[self.SLV].iloc[-2]>0), self.INI_WAIT_DAYS, 1),
np.where((mom[self.XLU].iloc[-1]>0) & (mom[self.XLI].iloc[-1]<0) & (mom[self.XLI].iloc[-2]>0), self.INI_WAIT_DAYS, 1),
np.where((mom[self.FXF].iloc[-1]>0) & (mom[self.FXA].iloc[-1]<0) & (mom[self.FXA].iloc[-2]>0), self.INI_WAIT_DAYS, 1)
)))
adjwaitdays = min(60, self.wait_days)
# self.Debug('{}'.format(self.wait_days))
if (extreme[self.SIGNALS + self.PAIR_LIST]).any():
#if (extreme[self.PAIR_LIST]).any():
self.exit = True
self.bull = False
self.outday = self.count
if self.count >= self.outday + adjwaitdays:
self.bull = True
self.count += 1
self.Plot("In Out", "in_market", int(self.bull))
self.Plot("In Out", "num_out_signals", extreme[self.SIGNALS + self.PAIR_LIST].sum())
self.Plot("Wait Days", "waitdays", adjwaitdays)
if self.returns(self.BND1, self.RET, self.EXCL) < self.returns(self.BND2, self.RET, self.EXCL):
self.selected_bond = self.BND2
#if self.returns(self.BND1, self.RET, self.EXCL) < self.returns(self.BND2, self.RET, self.EXCL):
# self.selected_bond = self.BND1
elif self.returns(self.BND1, self.RET, self.EXCL) > self.returns(self.BND2, self.RET, self.EXCL):
self.selected_bond = self.BND1
if self.returns(self.STK1, self.RET, self.EXCL) < self.returns(self.STK2, self.RET, self.EXCL):
self.selected_stock = self.STK2
#if self.returns(self.STK1, self.RET, self.EXCL) < self.returns(self.STK2, self.RET, self.EXCL):
# self.selected_stock = self.STK1
elif self.returns(self.STK1, self.RET, self.EXCL) > self.returns(self.STK2, self.RET, self.EXCL):
self.selected_stock = self.STK1
if not self.bull:
for sec in self.ASSETS:
self.wt[sec] = 0.99 if sec is self.selected_bond else 0
self.Debug("Exiting the market; trading BONDS")
self.Notify.Email("alan.chenhd@outlook.com", "Live Trade Executed", "Bond bought")
self.trade()
if self.bull:
for sec in self.ASSETS:
self.wt[sec] = 0.99 if sec is self.selected_stock else 0
self.Debug("Entering the market; trading STOCKS")
self.Notify.Email("alan.chenhd@outlook.com", "Live Trade Executed", "Equity bought")
self.trade()
def trade(self):
for sec, weight in self.wt.items():
if weight == 0 and self.Portfolio[sec].IsLong:
self.Liquidate(sec)
cond1 = weight == 0 and self.Portfolio[sec].IsLong
cond2 = weight > 0 and not self.Portfolio[sec].Invested
if cond1 or cond2:
self.SetHoldings(sec, weight)
if cond1:
self.Debug("Invested; selling")
elif cond2:
self.Debug("Not invested; buying")
===================
Many thanks for your help and Best wishes
Alan
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
Alan chen
You substantially changed the original code.
That may be the reason why it behaves differently.
Try the version I published above.
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.
Spacetime
Error:
ValueError : cannot convert float NaN to integer
at Update
wait_days = int(vola * self.BASE_RET)
===
at Python.Runtime.PyObject.Invoke(PyTuple args in dual_momentum_with_out_days_alpha.py: line 69
Fix:
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
Spacetime,
I was unable to reproduce the error you reported.
Have you had an error in the latest version 2.51?
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.
Spacetime
apologies… should have been more clearer…
It is the framework algorithm shared above by Joao Antunes.
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.
Kamal G
Hi Spacetime,
The cannot convert float to NAN integer occurs due to the multiple time resolutions being used for the same ticker. (Example below that will generate occasional errors). If you change all references to a given ticker to minute, hour, daily only, then the error will stop. (I got a similar error with other algorithms I have been putting together).
After you change a resolution, make sure the backtest is still the same or similar at the very least. Changing the time resolution can change an algorithm a lot!
self.STK2 = self.AddEquity('SPY', Resolution.Minute).Symbol
self.MKT = self.AddEquity('SPY', Resolution.Daily).Symbol
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
Vladimir
I was trying more pairs for the IN/Out and then giving each pair the same credit. If 80% of the total of 100% credits are reached, I would trigger the out signal. (It would be more like a voting approach)
This would be the opposite of this version were we have few pairs, but to trigger the signal all have to be satisfied. (It would be more like a veto approach)
What is you option on that, did you tried?
Second I would like to add some VIX pairs, like VIX > VIX 3M to trigger or a comparison of VIX momentum.
Did you tried something like that?
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 Rand
Joao Antunes was there a reason why the AUD (FXA) - CHF (FXF) was dropped as an out signal from the original algorithm (in favor, I assume, of UUP and DBB)? I understand that UUP/FXA and FXF/DBB probably have similar properties from a market signal perspective.
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!