某(中证 上证)类股票的全部收益
来源:互联网 发布:中关村软件下载 编辑:程序博客网 时间:2024/06/10 06:27
% 20160913 得到母基金的股票和股指期货持仓的交易日收益率clear;clctic%% 母基金名称ProName=['("母基金二期")'];%['("母基金二期","母基金三期","母基金四期")']%% 连接数据库conn=database('report','uxmc','uxmc-123', 'com.mysql.jdbc.Driver',... 'jdbc:mysql://report001.mysql.rds.aliyuncs.com/report');ping(conn);%% 提取母基金代码sql=sprintf('select productCode from product where productName in %s order by productCode',ProName);cursorA=exec(conn,sql);cursorA=fetch(cursorA);FOFCode=cursorA.Data;close(cursorA);%% 提取母基金所有股票和期货信息FundCodeValue=eval(FOFCode{1});%cell转数值为母基金的代码 Index=['tradingDay,instType,instrumentCode,productCode,marketValue'];sql=sprintf('select %s from positions_history where left(productCode,5)=%d order by tradingDay',Index,FundCodeValue);cursorA=exec(conn,sql);cursorA=fetch(cursorA);allInst=cursorA.Data;close(cursorA);%% 保留‘600’、‘601’、‘603’、‘000’、‘002’和‘300’打头的股票部分instType=allInst(:,2); instrumentCodeAll=allInst(:,3); x=find(strncmp(instrumentCodeAll,'600',3)|strncmp(instrumentCodeAll,'601',3)... |strncmp(instrumentCodeAll,'603',3)|strncmp(instrumentCodeAll,'000',3)... |strncmp(instrumentCodeAll,'002',3)|strncmp(instrumentCodeAll,'300',3)... |strcmp(instType,'期货'));allInst=allInst(x,:); %% 排除商品期货部分instType=allInst(:,2); instrumentCodeAll=allInst(:,3); x=find(strncmp(instrumentCodeAll,'IC',2)|strncmp(instrumentCodeAll,'IF',2)... |strncmp(instrumentCodeAll,'IH',2)|strcmp(instType,'股票'));allInst=allInst(x,:); allInst(:,3)=strrep(allInst(:,3),'CFFEX','CFE');%'CFFEX'替换为'CFE',便于wind查询%% 提取股票、股指期货的日收益率instrumentCodeUni=unique(allInst(:,3)); %存储所有不重复的股票代码 dayAll=[];for i=1:1:length(allInst(:,1)) tempday= allInst{i,1}; % 日期在第一列 dayAll(i,1)= str2double(tempday); enddayUni=unique(dayAll);%% 从wind拉取 全部或部分股票代码 上证50,沪深300,中证500,中证1000,wind全A。% 给定日期下从wind拉取指数的成分股及权重 2908只股票,在某日下 20160825 股票dateStr='20160825'; % 20160825日期,可随时调整 更多是当日的信息indexStr='881001.WI'; %wind全A stockName=[];%'000016.SH';'000300.SH';'000905.SH';'000852.SH';'881001.WI' %上证50,沪深300,中证500,中证1000,wind全A。dateStr1=strcat('date=',dateStr,';windcode=',indexStr); %wind全Aw=windmatlab;index_constituent=w.wset('indexconstituent',dateStr1,'showblank=0');%4列分别为日期/代码/名称/权重index_instrumentCode=index_constituent(:,2); %存储所有股票代码 %% 根据拉取的代码获得最终收益率instStr='';for i=1:1:length(index_instrumentCode) if i~=length(index_instrumentCode) str=sprintf('%s,',index_instrumentCode{i}); stockName{i}=index_instrumentCode{i}; else str=index_instrumentCode{i}; stockName{i}=index_instrumentCode{i}; end instStr=strcat(instStr,str);end[w_wsd_data,w_wsd_codes,w_wsd_fields,w_wsd_times]... =w.wsd(instStr,'pct_chg',num2str(dayUni(1)),num2str(dayUni(end)));%不用收盘价close,用涨跌幅'pct_chg'stockRate=w_wsd_data/100; %获得申万一级行业的收益率序列save('stockInfo.mat','stockRate','stockName','dayUni');
0 0
- 某(中证 上证)类股票的全部收益
- Android实现平板的类股票列表联动
- Android实现平板的类股票列表联动
- 敏锐的分析,你的详细分析企业,收益全部心动扣环对于购物者。
- 敏锐的分析,你的详细分析企业,收益全部心动扣环对于购物者
- 【C#】29. VIX指数的实现(使用上证50ETF为原始数据)
- 六类股票让你一旦沾上就"欲罢不能"(名单)
- 一些收益的帖子
- 收益曲线的构造
- 稳定的收益预期
- 股市的平均收益
- 优矿-python计算上证50之间的相关系数
- Perl 中输出 hash 的全部內容 (转载)
- Android Studio中svn的使用(全部在这里)
- Android Studio中svn的使用(全部在这里)
- 收益
- 银行业的长期估值(7)发起人股东收益
- 【zzuliOJ】1907 - 小火山的宝藏收益(dfs)
- 随机数
- 正则表达式
- JAVA中事物以及连接池
- 欢迎使用CSDN-markdown编辑器
- 气象色标标准链接
- 某(中证 上证)类股票的全部收益
- 对http的理解
- Oracle查看和删除database link
- d.linkedhashMap源码解析(1.7)
- 友盟分享集成问题
- 变分推断
- 教你阅读Python开源项目代码
- 【程序3】有1、2、3、4四个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
- SwapBuffers glutSwapBuffer glFlush glFinish