matlab code snippet #3

%%% bloomberg: intraday tick


VALUE_TRADE=1;
VALUE_BESTBID=31;
VALUE_BESTASK=32;


c=bloomberg;
% value_type,timestamp,price,size
raw=fetch(c,'NIX1 Index', 'TIMESERIES','11/15/2011');
I = (raw(:,1) == VALUE_TRADE | raw(:,1) == VALUE_BESTBID | raw(:,1) == VALUE_BESTASK);
raw(~I,:) = [];
raw(isnan(raw(:,3)),:)=[];
close(c);


x = dftool('ticktypes')
returns the list of tick types that can be converted to numeric tick type values with, for example,
find(strcmp('Trade',x))
Trade == 1, Bid Best == 31 and Ask Best == 32. 




%%% bloomberg: daily data
fmdt=datenum(2000,1,1);
todt=datenum(2011,1,1);
c=bloomberg;
d1=fetch(c, '1 HK Equity', 'HISTORY', {'OPEN','HIGH','LOW','LAST_PRICE'},fmdt,todt,'d');
close(c);


%%% bloomberg: meta information
c=bloomberg;
ret=fetch(c,'1 HK Equity','GETDATA',{'SECURITY_TYP','CUR_MKT_CAP','GICS_SECTOR_NAME'});
type=ret.SECURITY_TYP{1};
mkt_cap=ret.CUR_MKT_CAP;
sector=ret.GICS_SECTOR_NAME{1};
close(c);




%%% calc time elapsed
etime(datevec(calc_end), datevec(calc_start))




%%% show datenum in report
%data(:,1) is datenum column
[cellstr(datestr(data(:,1))) num2cell(data)]

没有更多推荐了,返回首页