Hi all,
If an algo can survive the worst of market conditions, it is worth looking at.
Statistcal analysts will use random walks to test logic.
Professor Burton Malkial's A Random Walk Down Wall Street is a fascinating read.
I propose that QC develop a random walk and worst case algo testing system, where all algos, whose backtest results meet a minimum performance criteria, are then eligible to be tested on numerous randomly selected windows of time , for user-defined universes, random historical price data of a fictional universe, and on historical major events.
Even if QC doesn't think this would be useful, I thought the community would like having these dates to test thier algos on.
I don't know how far back QC data goes, but here ya go......
Cheers!
OLDEST STOCK SYMBOLS
BK , ED , PG, IBM , KO , PFE , AGN , JNJ , BID , CI , DD , CL , VAL, JW.A
Major Market Events
Panic of 1901 • DJIA decline: -10.8% from 5/6/1901 to 5/9/1901
Panic of 1907 • DJIA decline: -45% from 1/07/1907 to 11/15/1907
Wall Street Crash of 1929 • DJIA decline: -46.6% from 9/16/1929 to 11/13/1929
Recession of 1937-38 • DJIA decline: -42.6% from 9/4/1937 to 3/31/1938
Germany invades France • DJIA decline: -24.5% from 5/10/1940 to 6/10/1940
End of World War II • DJIA decline: -23.2% from 5/29/1946 to 10/9/1946
Kennedy Slide of 1962 • DJIA decline: -26.8% from 12/28/1961 to 6/26/1962
Tech Stock Crash of 1970 • DJIA decline: -18.7% from 4/20/1970 to 5/26/1970
1973-74 Stock Market Crash • DJIA decline: -45.1% from 1/11/1973 to 12/6/1974
Black Monday • DJIA decline: -22.6% on 10/19/1987
Friday the 13th mini-crash 13 Oct 1989
Invasion of Kuwait • DJIA decline: -18.4% from 8/2/1990 to 10/11/1990
Long-Term Capital Management Fails • DJIA decline: -19.2% from 7/19/1998 to 8/31/1998
9/11 September 2001
Dot-com Bubble • DJIA decline: -31.4% from 5/19/2002 to 10/9/2002
Lehman Brothers Collapse and the Great Financial Crisis • DJIA decline: -53.7% from 10/9/2007 to 3/9/2009
Flash Crash April - May 2010
US Debt Downgrade • April - October 2011
Chinese Stock Market Turbulence • DJIA decline: -13.6% from 6/24/2015 to 8/25/2015
2018 Global Stock Market Downturn - Sep 2018
COVID-19 Outbreak • DJIA decline: -35% from 2/12/2020 to 3/20/2020
Jack Simonson
Hi Cary,
Thank you for the input! We have data for US equities as far back as the beginning of 1998, and most of our other data stretches back to the early-to-late 2000s (options, forex, futures, CFD). We'll take this into consideration as something to implement in the future!
Miriam F.
If you are interested in random algorithms, you should look here:
https://www.quantconnect.com/forum/discussion/1234/how-to-randomly-do-1000-trades-without-losing-money-risk-control-volatility-model-framework/p1
Kevin Baker
Partial solution using some hacks in the existing Lean repo:
As a QC user I took a step back from the web-based IDE and experimented with the Lean Github repo. Found the Toolbox project withich is a CLI tool that can be used for many things but also for generating random walk data. To make it work to create 29 years of random walk data for 15 fake symbols. I ran into many issues and worked around them like this:
private List<string> tickers = new List<string> { "SJX", "SKJ" , "SKX", "SNQ", etc 15 fake symbols};
private int tickerIndex = 0;
public virtual string NextUpperCaseString(int minLength, int maxLength)
{
//hack start
if (minLength != 3 || maxLength != 3) throw new Exception("Hack can't handle anything except 3");
if (tickerIndex > tickers.Count) throw new Exception("Hack not expecting more than tickers.Count");
return tickers[tickerIndex++];
//hack end
Then I could generate random walk data with a batch file full of lines like this:
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=1991-01-02 --end=1994-03-21 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395169 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=1994-03-22 --end=1997-10-27 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395168 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=1997-10-28 --end=1998-08-13 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395167 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=1998-08-14 --end=2001-09-17 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395166 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=2001-09-18 --end=2008-10-20 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395165 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=2008-10-21 --end=2011-08-15 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395164 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=2011-08-16 --end=2015-08-31 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395163 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
echo y | QuantConnect.ToolBox.exe --app=randomdatagenerator --resolution=Minute --start=2015-09-01 --end=2020-03-20 --market=usa --data-density=Dense --include-coarse=true --symbol-count=15 --random-seed=395162 --ipo-percentage=0.0 --rename-percentage=0.0 --splits-percentage=0.0
I broke it up into time intervals between spikes of high volatility I saw in real world VIX charts because I had seen crashes and errors when trying to generate decades of random walk data. I suppress the renaming, stock splits and IPOs in a hope of reducing risk of crashes and prevent the need for additional symbols. To test my C# trading algorithm, I force Lean Launcher Debug build to run as x64, and run within the Docker container using the instructions here using VS 2019 (did not test with a Py algorithm, but I don't see why it wouldn't work unless x64 is an issue):
https://github.com/QuantConnect/Lean/blob/master/.vs/readme.md
Conclusion: I got my 29 years of random walk data with some huge jumps in the prices to simulate some sort of crisis. Its only a step towards solving the issue.
To address the original topic above, one would have to also hack the generation of price and volume data in such a way as to emulate more than a century of various depressions etc.
Derek Melchin
Hi Kevin,
Thanks for sharing your findings with the community. For anyone looking to generate random data, refer to this tutorial.
Best,
Derek Melchin
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.
Cary Cocke
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!