The files are designed for walk-forward analysis of pair trading strategy using Bollinger Band as entry and exit rules. In this example, you will see 5 pair of stocks tested over the period of 3 years. Performance analytic part includes profit/loss, Sharpe ratio, and maximum drawdown. I really hope that you will find this file as a starting point for backtesting your investment ideas. Definitely, you need to customize the file if you would like to add new rules, trading strategies, or market data. I would also recommend to watch the webinar on this topic.
Kawee Numpacharoen (2019). Walk-Forward Analysis (WFA) - Files for WFA webinar (https://www.mathworks.com/matlabcentral/fileexchange/58316-walk-forward-analysis-wfa-files-for-wfa-webinar), MATLAB Central File Exchange. Retrieved .
Sorry everyone, this demo can not be run currently. At first, I developed based on Yahoo Finance. After Yahoo Finance stopped its free offering, I switched to Google Finance. Dejavu! Google Finance stoped thier free offering as well. In short, you can't run this demo. You will get an error.
Hi Thanks for sharing the great idea. I get below error on MATLAB R2019a, How do i fix this?
Total Walk is 36
=============== In-sample test ===============
walk startIST endIST startOST endOST
____ ___________ ___________ ___________ ___________
1.00 01-Apr-2013 30-Jun-2013 01-Jul-2013 31-Jul-2013
Error using tick2ret (line 81)
Expected number of observations to be a scalar with value >= 2.
Error in runIST (line 39)
portReturn = tick2ret(portValue);
Error in runWFA1 (line 13)
parfor j = 1:nParam
Grateful for this!
and modifying code in getPrices.m
The cost in updatePort function is the cost of buying or short-selling the asset. It might be a little bit confusing with transaction cost. Sorry about that.
hi, why do you set cost = TNew.execPrice in updatePort function?
i think it must be cost = TNew.cost
Sorry for the inconvenience, I am working on fixing all Yahoo-related files. This one is on my radar too. Unfortunately, I haven't had a chance to work on this yet. I would suggest to manually download the price from Yahoo in csv format as a quick fix.
Did anyone code a workaround for the yahoo problem in getPrices.m of this demo?
Change data source from Yahoo! Finance to Google Finance.
Add copyright statement
Inspired by: Download Daily Data from Google and Yahoo! Finance