## 源碼簡介

%% 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軟件如用于商業用途，請購買正版!
* 如果您發現下載鏈接錯誤，請點擊報告錯誤謝謝！
* 站內提供的所有軟件包含破解及注冊碼均是由網上搜集，若侵犯了你的版權利益，敬請來信通知我們!