TawnyPortfolio: Create a TawnyPortfolio object

Description Usage Arguments Details Value Author(s) Examples

Description

Represents a portfolio. Contains information about the portfolio composition, returns, window, etc.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
TawnyPortfolio(...)
BenchmarkPortfolio(...)

## S3 method for class 'TawnyPortfolio'
start(x, ...)

## S3 method for class 'TawnyPortfolio'
end(x, ...)

## S3 method for class 'TawnyPortfolio'
rollapply(x, fun, ...)

window_at(...)

Arguments

x

A TawnyPortfolio

fun

A function to apply against the TawnyPortfolio

...

Arguments to the constructor. See below for details

Details

This type is governed by futile.paradigm. Below are the supported function variants.

TawnyPortfolio(returns, window = 90)

TawnyPortfolio(symbols, window = 90, obs = 150)

Creates a benchmark portfolio to compare with the actual portfolio.

BenchmarkPortfolio(symbol, window = 90, obs = 150, end = Sys.Date(), ...)

Calculates portfolio returns based on the weights calculated.

PortfolioReturns(p, weights), p is a TawnyPortfolio

PortfolioReturns(h, weights), h is an AssetReturns object or zoo

'start' and 'end' operate on a TawnyPortfolio to return the start and end dates, respectively, of the portfolio.

'rollapply' is the implementation of the zoo function for a TawnyPortfolio. The 'window_at' function supports this by providing a window of the portfolio for the given index.

Value

The type constructor returns a TawnyPortfolio.

The 'start' and 'end' functions return dates.

'window_at' returns a modified TawnyPortfolio that only contains returns for the given window. All other data is the same, and the original object is unchanged.

Author(s)

Brian Lee Yung Rowe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  ## Not run: 
  p <- TawnyPortfolio(c('BAC','JPM','C','GS','MS'))

  start(p)
  end(p)

  window_at(p, 2)
  rollapply(p, function(x) colSums(x$returns))
  
## End(Not run)

tawny.types documentation built on May 2, 2019, 2:04 a.m.