This thread is meant to continue the development of the In & Out strategy started on Quantopian. The first challenge for us will probalbly be to translate our ideas to QC code.
I'll start by attaching the version Bob Bob kindly translated on Vladimir's request.
Vladimir:
About your key error, did you also initialize UUP like this?
self.UUP = self.AddEquity('UUP', res).Symbol
Jack Pizza
Vladimir Are you able to share your version? or is it private?
Jack Pizza
To play devils advocate out of sample is just as useless, we can sit around and debate in sample / out of sample and discard strategies willy nilly.
The best gauge will always be running it live. I started trading this live in my fidelity account we'll see how it performs.
https://econometrical.com/2014/06/09/is-out-of-sample-testing-of-forecasting-models-a-myth/
Vladimir
Elsid Aliaj,
It's not ready to be shared.
Vladimir
Leif Trulsson,
Here are the results of another trading strategy.
It trades QQQ and TLT without In Out, has one source,
uses a simple indicator with only one widely used parameter.
So your assumption:
The strength of the algorithm per se does not lay in the data itself, but in how the data
is handled, and in particular this part:...
is not quite right.
Leif Trulsson
Vladimir when I said "The strength of the algorithm per se does not lay in the data itself, but in how the data
is handled", I meant it literally. But I do agree with Elsid Aliaj when he says: "To play devils advocate out of sample is just as useless, we can sit around and debate in sample / out of sample and discard strategies willy nilly.".
So e.g. when working with neural networks, the data universe is very important, because you don't want to have a to high degree of correlation, because you will then have overfitting. The same goes with this strategy, but in the end it's still how we select and handle the data that's important.
@Elsid Aliaj That's not what the article states. It warns against the poor use of out-of-sample testing, such that it effectively becomes in-sample testing. However, if a strategy doesn't work out-of-sample (correctly performed), it will not work in real life either. Now market conditions change, and so a strategy that worked in the past, may end up not working in the future, but when it comes to testing the validity of your model assumptions on historical data, out-of-sample testing is the only right way to do it. Just using in-sample testing on limited data with many parameters, is inviting trouble. The real danger is in accepting strategies willy nilly, which is what happens when you acccept the results of a model at face value without doing the proper testing.
Article:
"The bottom line is that pseudo-out-of-sample tests can give valuable information, but are no panacea for data mining if misused."
The writers warn against the use of pseudo-out-of-sample testing, where parameters are continually adjusted until the "out-of-sample" test looks good to publish. In other words even if a scientist publishes out-of-sample tests, we should be cautious of accepting the results at face value, because it is fairly easy to manipulate the outcome. It is a critique of the people using the technique wrongly, not against the technique itself. As with any technique using it wrongly will (partly) negate its purpose, but this in no way invalidates the proper use of out-of-sample testing.
Finally to summarize:
Using out-of-sample testing does not guarantee a strategy will work in real life,...
but...
Failing to pass an out-of-sample test does guarantee a strategy will not work in real life.
Guy Fleury
@Menno, yes. The Numpy random-normal distribution function was used for base: N(0,1). Price series were normalized and injected with random outliers to mimic fat tails. The price series were therefore stochastic functions with random jumps. Also, historical market values for the drift and volatility were used to make the price series more realistic. It made the price series short-term quasi-unpredictable as should be expected. Nonetheless, the series were fabricated and not real-life, but still a reasonable tool to analyze general portfolio behaviors. Since no seed was used, from test to test, you would generate 20,000 portfolios having no relation to previous ones or to those that would follow. All the portfolios, as well as all the price series, always unique.
@Guy Fleury Very interesting!!!
@Ernest Shaggleford Sorry, missed your post. It can be taken into account explicitly, but of course at its simplest most people do by using some model to estimate and manage slippage, whilst simultaneously ensuring they always remain a small fraction of the available market volume.
Frank Schikarski
Hi guys, great co-creation being done here!!! Some ideas on further In-Out triggers, in case someone has some spare coding time over the long week-end:
Vladimir
Leif Trulsson,
...when working with neural networks, the data universe is very important, because you don't want
to have a to high degree of correlation, because you will then have overfitting.
This algorithm is not for curve-fitting, but for trading.
S.T.E
@Frank Schikarski Great points but I do know if it can help the algo since they move around a lot, tends to increase false signals in the algo and decrease the potential profit. Other thing worth exploring is also the volatility of bonds and FX to the VIX.
Goldie Yalamanchi
I tried another approach to using the In/Out signals. I call this sort of the Value Momentum strategy. The value momentum concept is from another strategy in the forum in terms of picking stocks that have certain EV/Ebitda but also strong dollar volume (momentum) because as you know value stocks alone don't necessarily move or that profitable.
I made the "in" signal when the portfolio gets rebalanced. Then when it is out it dumps everything but TLT.
What I like about the stock selection is that I believe QQQ is very overpriced due to tech stocks. Maybe this will provide a long term play on value momentum which is still very great returns though not QQQ/TQQQ (Amazon, Apple, Facebook, Goog) returns. About 911% from 2010 to 2020.
The code looks a bit like Frankenstein so needs to be cleaned up a bit. Just not super strong python developer yet.
Here it is 2010 - 2020 (11/27/2020) - 911%:
Goldie Yalamanchi
And actually if I run it from 2008 - it has 1130% total profit running the high value momentum stocks. Also, it seems there were many discussions in this thread if the silver/gold, dollar/risk currency and other pairs used to determine IN/OUT state were overfit, wouldn't this separate universe of value+momentum stocks prove it works with out-of-sample data in yet another way?
Yumeng
@Nathan Swenson I am wondering hows ur live result so far? I implemented the algo live but find out for some reason it won't sync with the back test result, even adding the warm up period (althouth this incurrs another problem as the memory will max out when you put into 65 days as warm up). but in short, say today the live alo will indicate "in" but if you back test after EOD today the algo actully indicate "out", which I am still scratching my head and trying to figure out.
Vladimir
Goldie Yalamanchi
I have backtested your algorithm.
On B4-12 node e0e53b43 in 3781.30 seconds at 126k data points per second aproximatly
10 times slower than in free Quantopian.
In my opinion, you chose not right code structure.
And therefore it does not control the leverage properly.
I got many of warnings like this:
2013-08-26 11:30:00 : GOOG: The security does not have an accurate price as it has not
yet received a bar of data.
Your "Value Momentum strategy" is very similar to the “Quality Companies in an Uptrend” originated
by Chris Cain and widely discussed at the Quantopian Forum.
Peter Guenther Oct 13, 2020 posted there his "Amazing returns = superior stock selection strategy +
superior in & out strategy", there was also my version with Chris Cain's original quality
definition and luc prieur Oct 16, 2020 version with a different momentum logic (the best one).
BTW Peter Guenther has already opened the thread
"Amazing returns = superior stock selection strategy + superior in & out strategy"
on QuantConnect forum.
So it makes sense to move the discussion there.
Goldie Yalamanchi
Sure not a problem to move it. But it seems the defintions and code have all been stripped out of that quantopian linking regarding Luec's defintion.
Anyways, if somebody has done the same which is to combine quality stocks and the in/out strat and has posted it, please link it. I have made a very rudimentary attempt to do so without knowing if someone has already done so. Yes, I did take pretty much the guts from Chris's strategy. Those symbol errors are in the beginning of the backtest but don't occur later in time. It needs to be fixed (the code). I am just trying to find different criteria to find stocks rather than QQQ.
Jon Quant
Here is a C# version of Tristan F python code v1.1. I just realized how powerful python is as a financial programming language. A single line in python is equivalent to a few lines of code in C#. This is 4 times the amount of code but executes 3 times faster than python (in backtests). Porting could have possibly been easier and involved less code if a C# version of pandas and numpy libraries were available in QuantConnect. It's good that Math.NET was available.
Tentor Testivis
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!