拉取某种(中证)股票的权重

% 给定日期下从wind拉取 某类股票(沪深300)的 代码,简称,权重(300下权重),申万行业代码。
dateStr='20160912';  %日期,可随时调整
indexStr='000300.SH'; %沪深300
%'000016.SH';'000300.SH';'000905.SH';'000852.SH';'881001.WI' %上证50,沪深300,中证500,中证1000,wind全A。
dateStr1=strcat('date=',dateStr,';windcode=',indexStr);  %wind全A
w=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});
    else
        str=index_instrumentCode{i};    
    end
        instStr=strcat(instStr,str);
end

% 给定日期下从wind拉取indexStr的申万一级行业指数代码
index_SWcode=w.wsd(instStr,'indexcode_sw',dateStr,dateStr,'industryType=1'); 
index_rate=w.wsd(instStr,'pct_chg',dateStr,dateStr,'industryType=1')/100;
index_constituent=[index_constituent,index_SWcode,num2cell(index_rate)];

save('index_constituent.mat','index_constituent');
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值