Best Structure for a Trading Model based on Stock Indices
4 次查看(过去 30 天)
显示 更早的评论
Apologies if this sounds very basic but I am completely new to Matlab and would greatly appreciate if someone could let me know if I am on the right track with regard to the data structure I plan to use for my project:
- I plan to generate a model for buying/selling stock indices and tracking the return vs a simple buy and hold strategy. - Inputs are excel sheets with historic end-of-day data (Open, High, Low, Close, Volume) for Dow Jones Industrial Average and Nasdaq Composite. I have also another sheet which contains daily market breadth data such as Advancing issues, Declining issues, etc. - I then plan to calculate several indicators such as MACD, RSI, Moving Averages, On-Balance-Volume (OBV), etc. for every index and day - Based on the above price data and the calculated indicators I want to create specific buy and sell rules. There will be SEVERAL different buy and sell rules and in addition to an overall buy/sell performance for the model I would also like to measure the return of each individual buy or sell rule, max drawdown, etc. For your information, a "sell" would be closed out once any of the "buy" rules gets triggered and vice versa.
Once it's up and running I would like to do statistical testing and be able to play around with adding/removing individual rules or varying certain parameters.
So far I believe the best modeling option would be using the DATASET format (Statistics Toolbox) with the date as the key variable to link the individual sheets. Would you agree or is there a better way to implement the model? How would you create the buy and sell rules? Would you use a separate DATASET for this or just program code?
If anyone has a simple template file for this to learn about the structure or knows where to find one, this would be much appreciated!
Thanks a lot!
0 个评论
采纳的回答
Leah
2012-2-13
I prefer to use datasets for all of my data, especially if it is coming from Excel. http://www.mathworks.com/help/toolbox/stats/dataset.html
to bring in the file use
data=dataset('xlsfile',filename.xlsx, 'sheet',sheetname);
It sounds like your sheet name is different for everyday? How is it formatted? Do you then want to join all those individual days into a time series?
2 个评论
Leah
2012-2-14
that should be no problem
use join to combine the sheets, you can also specify a join type (full,outer, left, right,inner) since it sounds like they start a
sheet1=dataset('xlsfile',filename.xlsx, 'sheet','sheet1');
sheet2=dataset('xlsfile',filename.xlsx, 'sheet','sheet2');
Data=join(sheet1,sheet2,'type','inner','key','date','mergekeys',true);
you can then add calculated columns like this
Data.HML=Data.high-Data.Low;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transaction Cost Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!