http://www.matlabsky.com/thread-39817-1-1.html
===============================
中金所每日会公布结算会员(前20名)成交持仓排名,数据网址:http://www.cffex.com.cn/fzjy/ccpm/,利用MATLAB可以自动获取每日该数据,进而可以为后续的使用和挖掘做准备。
正则是个好东西!
实现核心就是urlread+正则。核心代码还在修改调整,暂未放出。
脚本代码(核心函数还未给出!)
- %% TestScript
- % by LiYang
- % Email:farutoliyang@gmail.com
- % 2014/01/10
- %% A Little Clean Work
- tic;
- clear;
- clc;
- close all;
- format compact;
- %% 获取中金所每日结算会员成交持仓排名 数据
- % 获取数据网址http://www.cffex.com.cn/fzjy/ccpm/
- datestring = '2014-01-10';
- % datestring = '2010-04-16';
- % datestring = '2013-10-17';
- [DataCell,StatusOut] = VolOIRankingGet_SD(datestring);
- StatusOut
- if 0 == StatusOut
- disp('数据获取失败!请检查!');
- return;
- end
- %%
- num = length(DataCell);
- %% 图形展示
- for i = 1:num
-
- celltemp = DataCell{i,1};
- id_day_string = celltemp{1,1};
-
- xlabel1 = celltemp(4:end,2);
- Vol = celltemp(4:end,3);
- Vol = cell2mat(Vol);
- Vol_chg = celltemp(4:end,4);
- Vol_chg = cell2mat(Vol_chg);
-
- xlabel2 = celltemp(4:end,5);
- OI_buy = celltemp(4:end,6);
- OI_buy = cell2mat(OI_buy);
- OI_buy_chg = celltemp(4:end,7);
- OI_buy_chg = cell2mat(OI_buy_chg);
-
- xlabel3 = celltemp(4:end,8);
- OI_sell = celltemp(4:end,9);
- OI_sell = cell2mat(OI_sell);
- OI_sell_chg = celltemp(4:end,10);
- OI_sell_chg = cell2mat(OI_sell_chg);
-
-
- scrsz = get(0,'ScreenSize');
- figure('Position',[scrsz(3)*1/5 scrsz(4)*1/7 scrsz(3)*6/6 scrsz(4)]*3/4);
-
- subplot(311);
- x = (1:20)';
- [AX,H1,H2] = plotyy(x,Vol,x,Vol_chg,@bar,@plot);
- set( AX(1),'XTick',[] );
- set( AX(1),'XTickLabel',[] );
- set( AX(2),'XTick',[] );
- set( AX(2),'XTickLabel',[] );
- xlim( AX(1),[0 21] );
- xlim( AX(2),[0 21] );
-
- set(H2,'Color','r');
- set(AX(2),'YColor','r');
-
- set(get(AX(1),'Ylabel'),'String','成交量','FontWeight','Bold');
- set(get(AX(2),'Ylabel'),'String','比上交易日增减');
-
- set(gca,'XTick',1:20);
- set(gca,'XTickLabel',xlabel1);
- TickLabelRotate(gca,'x',30,'right');
-
- str = ['成交量排名(',id_day_string,')'];
- title(str, 'FontWeight','Bold');
-
- for ind=1:length(Vol)
- text(ind,Vol(ind),num2str(Vol(ind)), ...
- 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom');
- end
-
- subplot(312);
- x = (1:20)';
- [AX,H1,H2] = plotyy(x,OI_buy,x,OI_buy_chg,@bar,@plot);
- set( AX(1),'XTick',[] );
- set( AX(1),'XTickLabel',[] );
- set( AX(2),'XTick',[] );
- set( AX(2),'XTickLabel',[] );
- xlim( AX(1),[0 21] );
- xlim( AX(2),[0 21] );
-
- set(H2,'Color','r');
- set(AX(2),'YColor','r');
-
- set(get(AX(1),'Ylabel'),'String','持买单量','FontWeight','Bold');
- set(get(AX(2),'Ylabel'),'String','比上交易日增减');
-
- set(gca,'XTick',1:20);
- set(gca,'XTickLabel',xlabel2);
- TickLabelRotate(gca,'x',30,'right');
-
- str = ['持买单量排名(',id_day_string,')'];
- title(str, 'FontWeight','Bold');
-
- for ind=1:length(Vol)
- text(ind,OI_buy(ind),num2str(OI_buy(ind)), ...
- 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom');
- end
-
- subplot(313);
- x = (1:20)';
- [AX,H1,H2] = plotyy(x,OI_sell,x,OI_sell_chg,@bar,@plot);
- set( AX(1),'XTick',[] );
- set( AX(1),'XTickLabel',[] );
- set( AX(2),'XTick',[] );
- set( AX(2),'XTickLabel',[] );
- xlim( AX(1),[0 21] );
- xlim( AX(2),[0 21] );
-
- set(H2,'Color','r');
- set(AX(2),'YColor','r');
-
- set(get(AX(1),'Ylabel'),'String','持卖单量','FontWeight','Bold');
- set(get(AX(2),'Ylabel'),'String','比上交易日增减');
-
- set(gca,'XTick',1:20);
- set(gca,'XTickLabel',xlabel3);
- TickLabelRotate(gca,'x',30,'right');
-
- str = ['持卖单量排名(',id_day_string,')'];
- title(str, 'FontWeight','Bold');
-
- for ind=1:length(Vol)
- text(ind,OI_sell(ind),num2str(OI_sell(ind)), ...
- 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom');
- end
-
- text( 'Units', 'normalized', 'Position', [1,-0.35], 'String', '数据来源:中金所', ...
- 'BackgroundColor', [1 0 0], 'FontAngle', 'oblique', ...
- 'HorizontalAlignment', 'right', 'VerticalAlignment', 'top');
- end
- %% Record Time
- toc;