• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Lenskiy/Yahoo-Quandl-Market-Data-Donwloader: Matlab functions for market data do ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

Lenskiy/Yahoo-Quandl-Market-Data-Donwloader

开源软件地址(OpenSource Url):

https://github.com/Lenskiy/Yahoo-Quandl-Market-Data-Donwloader

开源编程语言(OpenSource Language):

MATLAB 100.0%

开源软件介绍(OpenSource Introduction):

Yahoo finance and Quandl data downloader

View Yahoo Finance and Quandl data downloader on File Exchange

Example 1: Download data from Yahoo

initDate = '1-Jan-2014';
symbol = 'AAPL';
aaplusd_yahoo_raw = getMarketDataViaYahoo(symbol, initDate);
aaplusd_yahoo= timeseries([aaplusd_yahoo_raw.Close, aaplusd_yahoo_raw.High, aaplusd_yahoo_raw.Low], datestr(aaplusd_yahoo_raw(:,1).Date));
aaplusd_yahoo.DataInfo.Units = 'USD';
aaplusd_yahoo.Name = symbol;
aaplusd_yahoo.TimeInfo.Format = "dd-mm-yyyy";

Example 2: Download data from Quandl

dataset = 'WIKI/AAPL';
aaplusd_quanl_raw = getMarketDataViaQuandl(dataset, initDate);
aaplusd_quanl= timeseries([aaplusd_quanl_raw.Close, aaplusd_quanl_raw.High, aaplusd_quanl_raw.Low], datestr(aaplusd_quanl_raw(:,1).Date));
aaplusd_quanl.DataInfo.Units = 'USD';
aaplusd_quanl.Name = dataset;
aaplusd_quanl.TimeInfo.Format = "dd-mm-yyyy";


figure, % note the Quandl returns inaccurate date
subplot(2,1,1), plot(aaplusd_yahoo);
legend({'Close', 'High', 'Low'},'Location', 'northwest');
subplot(2,1,2), plot(aaplusd_quanl);
legend({'Close', 'High', 'Low'},'Location', 'northeast');

Example 3: Download data OPEC Basket Price from Quandl

dataset = 'OPEC/ORB';
opec_orb_raw = getMarketDataViaQuandl(dataset, initDate, date(), 'weekly');
opec_orb_ts = timeseries(opec_orb_raw.Value, datestr(opec_orb_raw.Date));
opec_orb_ts.DataInfo.Units = 'USD';
opec_orb_ts.Name = dataset;
opec_orb_ts.TimeInfo.Format = "dd-mm-yyyy";
figure, plot(opec_orb_ts);

Example 4: Download data from Yahoo and estimate covariance matrix

clear marketData;
initDate = datetime(addtodate(datenum(today),-1,'year'),'ConvertFrom','datenum');
symbols = {'^GSPC', 'DAX',  '^N225', 'GLD', 'QQQ', '^IXIC', 'FNCL', 'BTC-USD'};

for k = 1:length(symbols)
    data = getMarketDataViaYahoo(symbols{k}, initDate);
    ts(k) = timeseries(data.Close, datestr(data(:,1).Date));
    tsout = resample(ts(k),ts(1).Time);
    marketData(:,k) = tsout.Data;
end

marketData(isnan(marketData)) = 0; % In case resample() introduced NaNs
normalizedPrice = (marketData - mean(marketData))./std(marketData);
normalizedPrice = normalizedPrice - normalizedPrice(1,:);
tscomb = timeseries(normalizedPrice);
tscomb.TimeInfo = ts(1).TimeInfo;
tscomb.Name = 'normalized';
tscomb.TimeInfo.Format = "dd-mm-yyyy";
figure, plot(tscomb);
legend(symbols, 'interpreter', 'none', 'Location', 'best');

covMat = corrcoef(marketData);
covMat(eye(8) == 1) = 0;

figure, heatmap(covMat,'Colormap', parula(3), 'ColorbarVisible', 'on');
ax = gca;
ax.XData = symbols;
ax.YData = symbols;




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap