API Docs

Manual, tutorials and complete function reference

portfolio_return

Computes cumulative return of a portfolio from the beginning of the holding period.


Usage
portfolio_return(portfolio)
portfolio
Portfolio object created using portfolio_create() function

Return Value
Numeric vector of portfolio returns.
Examples
data(aapl.data) 
data(goog.data) 
data(spy.data) 
portfolio=portfolio_create(priceDataIx=spy.data)
portfolio_settings(portfolio,windowLength = '3600s',resultsSamplingInterval='60s')
positionGOOG=position_add(portfolio,'GOOG',100,priceData=goog.data)   
positionAAPL=position_add(portfolio,'AAPL',300,priceData=aapl.data) 
result=compute(expected_downside_return(portfolio,0.05),
expected_downside_return(positionGOOG,0.05),expected_downside_return(positionAAPL,0.05)) 
plot(expected_downside_return(portfolio,0.05),expected_downside_return(positionGOOG,0.05),
expected_downside_return(positionAAPL,0.05),legend=c('Portfolio','GOOG','AAPL'),
title='Expected Downside Return')

dateStart = "2014-11-17 09:30:00"
dateEnd = "2014-11-17 16:00:00"
portfolio=portfolio_create(dateStart,dateEnd)
portfolio_settings(portfolio,portfolioMetricsMode="price",windowLength = '3600s',
resultsSamplingInterval='60s')

positionAAPL=position_add(portfolio,'AAPL',100)
positionC=position_add(portfolio,'C',300) 
positionGOOG=position_add(portfolio,'GOOG',150) 

result=compute(expected_downside_return(positionC,0.05), expected_downside_return(positionGOOG,0.05),
expected_downside_return(positionAAPL,0.05)) 

plot(expected_downside_return(positionC,0.05),expected_downside_return(positionGOOG,0.05),
expected_downside_return(positionAAPL,0.05),legend=c('C','GOOG','AAPL'),
title='Expected Downside Return')
% load data
goog.data=importdata('data_goog.mat'); 
aapl.data=importdata('data_aapl.mat');  
spy.data=importdata('data_spy.mat'); 

% create portfolio
portfolio=portfolio_create(spy.data,1); 
portfolio_settings(portfolio, 'windowLength', '1h');
portfolio_addPosition(portfolio,'GOOG',goog.data,100);
portfolio_addPosition(portfolio,'AAPL',aapl.data,300);

% plot metric
util_plot2d(portfolio_return(portfolio));