📄 rendimenti.m
字号:
function [DX,DR,cambi,fattori,prezzi] = rendimenti(X,RF,RC,rendimento);%RENDIMENTI prices to returns.%% [DX,DR,cambi,fattori,prezzi] = rendimenti(X,RF,RC,rendimento) trasform% prices in yields and extracts current exchange rates, risk factors and% prices. X is the matrix of asset prices, RF the matrix of risk factors% prices, RC the matrix of exchange rates. Exchange rates are expressed% in defined value (1$ = 1.22 Euro, 1Yen = 0.012 Euro, ...). If the% portfolio is with only one exchange rate put RC = 0. % Rendimento = 0 aritmetic yields (p(t)-p(t-1))/p(t-1)% = 1 logarithmic yields log(p(t)/p(t-1))% % All data must be in colums.%% See SEMPLICECORR, EWMACORR%% Copyright (c) 2004 by Flavio Bazzana% Department of Computer and Management Sciences% University of Trento% 38100 - Trento ITALY% flavio.bazzana@economia.unitn.itif RC == 0 R = RF; else R = [RF RC];endm = size(X,1);% calculation of current exchange rates, risk factors, and pricesif RC == 0 cambi=0; else cambi=RC(m,:)';endfattori=RF(m,:)';prezzi=X(m,:)';% transformation of X and R matrix of data ...% ... in daily arithmetic returns if rendimento == 0 X1 = X(1:m-1,:); R1 = R(1:m-1,:); DX = diff(X)./X1; DR = diff(R)./R1;end% ... in daly logaritmic returns if rendimento == 1 X1 = X(2:m,:); R1 = R(2:m,:); DX = log(X1./X(1:m-1,:)); DR = log(R1./R(1:m-1,:));end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -