|
There are a variety of different ways to get the data you will need in order to backtest/optimize your strategy. The right one for you depends on what resources you have available. The following list will address the data feed issue from those with the least resources to those with the most. No Datafeed Toolbox If you don’t have the datafeed toolbox, don’t despair. You can still get plenty of good daily data for free. Yahoo! Finance (finance.yahoo.com) allows you to download loads of daily data – and – best of all adjusts for splits/dividends. Simply go to Yahoo! Finance, type in the ticker, click on Historical Prices in the left hand sidebar, then pick the days you want and frequency. From Yahoo! You can get the following columns. Date, Open, High, Low, Close, Adjusted Close. After you have selected what you want hit <<Get Price>>. Then scroll down to the bottom of the page and click on the link where it says <<Download to Spreadsheet>>. You are going to want to save this data file in your Matlab Current Directory.
Once you have the data in your current directory, you are going to need to load into your workspace so you can work with it. To do this you can use the csvread, dlmread, importdata or load functions. If you want to make your life easier (and if you are using daily data or another small dataset) you can just right click on the file in the Current Directory window and click on “import data.” This will bring up a simple GUI that will show you how to bring in the data you want to.
There also used to be this super sweet service called Opentick, which offered 10 TB of free intraday data. Although they closed their doors in March 2009, they claim that they will be launching a new product (for free I assume) in the future.
Real Time Yahoo Quotes There is also some files on the file exchange that allow you to receive real time quotes from Yahoo via the fetch command. Although the files are free, the subscription to Yahoo is 14 dollars a month. I have personally tried this out and it does work. You can’t get tick by tick data with this, so it’s not all that useful in my opinion. Below is the link to the file exchange if you want to check it out. http://www.mathworks.com/matlabcentral/fileexchange/20521
Using the Datafeed Tool Box Directly If you have the Matlab Datafeed Toolbox, then you can grab data directly for free from Yahoo! or through a paid subscription to a feed like Bloomberg. To grab data from Yahoo click on the start menu(in Matlab, not windows) then click on the toolbox menu, then datafeed, then datafeed tool. Then connect to Yahoo by selecting Yahoo as the data source and clicking the connect button. Next hit the Data tab, pick the ticker you want, and the type of data. Finally, pick the name you want the data to be saved as in the Matlab workspace and enter it into the “Matlab Variable:” box and hit “Get Data”. The data will be automatically imported into your workspace.
Connecting to Interactive Brokers TWS API It is possible to retrieve historical data (and real time data) in Matlab via Interactive Broker’s Trader Work Station API. To do this you will need an Interactive Brokers account. IB currently grants access to up to 6 months of historical intraday data. If this is an option you would like to pursue, you should watch Max Dama’s video tutorial at the link below:
http://www.maxdama.com/2008/12/interactive-brokers-via-matlab.html
If you need more help with this let me know, I have written a bunch of scripts for this purpose.
|