PDF下载 下载

典型应用场景

阅读 10120

使用财务接口获取指定月份的数据

参考处理代码:

  1. function data01 = date_fl (data,month)
  2. for i = 1:length(data.symbols)
  3. date = cellstr(datestr(data.EndDate{i},'mm'));
  4. ind = strcmp(date,month);
  5. data01.symbols = data.symbols;
  6. diff_f = setdiff(fieldnames(data),'symbols');
  7. for j = 1:length(diff_f)
  8. jj = diff_f{j};
  9. eval(['data01.',jj,'{i}=data.',jj,'{i}(ind);'])
  10. end
  11. end
  12. end

完整示例:

  1. [data] = get_fundamentals('cashflow_statement',{ 'SHSE.600000','SZSE.000001'}, '2016-01-01', '2018-08-01', {'ASSEIMPA','CASHFINALBALA','FINRELACASH'});
  2. data01 = date_fl(data,'09')

输出结果

  1. data01 =
  2. 包含以下字段的 struct:
  3. symbols: {'SHSE.600000' 'SZSE.000001'}
  4. ASSEIMPA: {[0 0] [0 0]}
  5. CASHFINALBALA: {[0 0] [0 0]}
  6. EndDate: {[736603 736968] [736603 736968]}
  7. FINRELACASH: {[0 0] [0 0]}
  8. PubDate: {[736632 736996] [736624 736989]}
  9. datestr([736603 736968],31)
  10. ans =
  11. 2016-09-30 00:00:00
  12. 2017-09-30 00:00:00
0 篇笔记