彭博检索历史数据 - API [英] Retrieve Bloomberg Historical Data - API
问题描述
从下面的code,我试图找回 250
的意见,而不是 177
。差距是由于在呼叫
只考虑个交易日
这是没什么问题。
S ='SX5E指数;
F ='LAST_PRICE
T = datestr(TODAY() - 250,MM / DD / YY');
T = datestr(TODAY(),MM / DD / YY');
[DT,〜] =历史(CON,S,F,T,T)
然而,有没有从今天取回的最后250意见()
,无论起始日期 T
是?
最佳
修改
@Daniel:根据您的建议,并与展望未来while循环
,我已经低于结束了的方式围绕
这是任何 Matlab的
默认日历
设置免费的。 感谢
而L〜= P
N = P-L;
T = T-N;
[DT,〜] =历史(CON,S,F,T,T);
L =长度(DT);
结束
也许是我的主意,用 isbusday
没有得到很好的意见解释。以下是我想尝试:
N = 250;
M = N;
而(SUM(isbusday(TODAY() - N:今日()))≤M)
缺少= M-SUM(isbusday(TODAY() - N:今日()));
N = N +丢失;
结束
计数的失踪天数,添加缺少的日子,并再次检查(如果你增加了一个节日)
您应该结束了n天的总数,你必须查询。
(缺少工具箱中,我无法测试code)
From the below code, I was attempting to retrieve 250
observations rather than 177
. The gap is due to the fact that the call
only considers trading days
which is fine to me.
s='SX5E INDEX';
f='LAST_PRICE'
t= datestr(today()-250,'mm/dd/yy');
T= datestr(today(),'mm/dd/yy');
[dt,~]=history(con,s,f,t,T)
However, is there a way of retrieving the last 250 observations from today()
, whatever the starting date t
is ?
Best
EDIT
@Daniel : Based on your suggestion, and Going forward with while loop
, I've ended up with the below way around
which is free from any Matlab
default calendar
setting. Thanks
while l~=p
n=p-l;
t=t-n;
[dt,~]=history(con,s,f,t,T);
l=length(dt);
end
Maybe my idea to use isbusday
wasn't well explained in the comments. Here is what I would try:
n=250;
m=n;
while(sum(isbusday(today()-n:today()))<m)
missing=m-sum(isbusday(today()-n:today()));
n=n+missing;
end
Count the number of missing days, add the missing days and check again (in case you added a holiday)
You should end up with n the total number of days you have to query.
(Lacking the toolbox, I was unable to test the code)
这篇关于彭博检索历史数据 - API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!