## 源码简介

%% Compute Value at Risk for a given portfolio
% This script computes the Value at Risk for a portfolio using 3 different
% techniques, historical simulation, parametric, and Monte Carlo
% simulation.

%% Import data from Excel

%% Convert price series to return series and visualize historical returns
% This step illustrates converting a price series to a return series using
% the function TICK2RET from the Financial Toolbox.  This function allows
% for calculating simple or logarithmic returns (continuous).
%
% THIS SECTION REQUIRES THE FOLLOWING MATHWORKS PRODUCTS AND THEIR
% RESPECTIVE DEPENDENCIES:
% * Financial Toolbox

clear variables

%% Visualize price series
% Normalize prices starting at \$1
normPrices = ret2tick(tick2ret(HistPrices));

% Visualize normPrices from Workspace window
mypick = strcmpi(Tickers, 'GOOG') | strcmpi(Tickers, 'IBM') ...
| strcmpi(Tickers, 'AAPL');
mypickStockPrices = HistPrices(:, mypick);
mypickNormPrices = normPrices(:, mypick);
mypickTickers = Tickers(mypick);
plot(mypickNormPrices,'DisplayName','mypickNormPrices','YDataSource','mypickNormPrices');figure(gcf)
legend(mypickTickers)

normIndexPrice = ret2tick(tick2ret(pricesIndex));
hold all
plot(normIndexPrice,'DisplayName','Index','YDataSource','normIndexPrice');figure(gcf)

%% Explain simple and logarithmic returns
AAPL = mypickStockPrices(1:11,1); % Take first 11-day prices of AAPL
retSimple = tick2ret(AAPL);
retLog = tick2ret(AAPL, [], 'Continuous');
[retLog retSimple]
[retLog log(1+retSimple)]
[exp(retLog)-1 retSimple]
[sum(retLog) prod(1+retSimple)-1] %#ok<*NOPTS>
[exp(sum(retLog))-1, prod(1+retSimple)-1]

%% Simple data analysis, mean, std, correlation, beta
mypickRet = tick2ret(mypickStockPrices, [], 'Continuous');
mean(mypickRet)
std(mypickRet)
% Max drawdown
maxdrawdown(mypickStockPrices)  % From Financial Toolboxes
% Correlation
corrcoef(mypickRet)

% Simple beta calculation
IndexRet = tick2ret(pricesIndex);
AAPLRet = tick2ret(mypickStockPrices(:,1));

% Auto-generate figure
createfigure([mypickNormPrices, normIndexPrice], IndexRet, AAPLRet, ...
[], [0 0 1])

%% Calculate return from price series
returnsSecurity = tick2ret(HistPrices,[],'Continuous');
totalReturns = sum(returnsSecurity);
numDays = size(HistPrices, 1);

% The heatmap makes use of MATLAB's graphics capabilities.  For more
% information edit the M-file "makeHeatmap.m"
makeHeatmap(totalReturns(end, :), Tickers, numDays, 'returns', 'matlab');

% [EOF]

## 本站长期招聘程序代写高手，欢迎加入华南地区matlab团队 想创业却没有经验的人 无论你是否有过网上开店的经验，都可以随时联系在线客服，建立自己独立的网站 想开网店却不知道如何入手 淘宝创业成本低而且风险小，如果想开淘宝店的朋友可以联系在线客服。 想兼职创业，却不擅长交际与服务的人 在家创业月入5000元。网站程序+百套群发工具+网赚资料+域名+空间+本站终身代理资格，这样你网赚的条件全具备了。每天3小时管理、推广、收钱。 缺乏能快速赢利型产品的人 导入多种最新流行营销软件+网赚教程，让入驻者轻松加盟、复制有效成交技巧、快速赚钱。

## 源码评论评论内容只代表网友观点，与本站立场无关！

评论摘要(共 0 条，得分 0 分，平均 0 分) 查看完整评论

## 浏览说明

* 本站所有源码全部公开，随时随地浏览!
* MATLAB软件如用于商业用途，请购买正版!
* 如果您发现下载链接错误，请点击报告错误谢谢！
* 站内提供的所有软件包含破解及注册码均是由网上搜集，若侵犯了你的版权利益，敬请来信通知我们!