[Blotter-commits] r525 - in pkg/blotter: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jan 4 17:21:18 CET 2011
Author: braverock
Date: 2011-01-04 17:21:18 +0100 (Tue, 04 Jan 2011)
New Revision: 525
Removed:
pkg/blotter/R/calcPortfAttr.R
pkg/blotter/R/calcPortfSummary.R
pkg/blotter/man/calcPortfAttr.Rd
pkg/blotter/man/calcPortfSummary.Rd
Log:
- remove obsolete calcPortf* functions and docs
Deleted: pkg/blotter/R/calcPortfAttr.R
===================================================================
--- pkg/blotter/R/calcPortfAttr.R 2011-01-04 16:16:13 UTC (rev 524)
+++ pkg/blotter/R/calcPortfAttr.R 2011-01-04 16:21:18 UTC (rev 525)
@@ -1,81 +0,0 @@
-#' calculate summary attributes for a portfolio
-#'
-#' supported values are:
-#' Gross.Trading.PL, Txn.Fee, Net.Trading.PL, Realized.PL, Unrealized.PL, Gross.Value, Long.Value, Short.Value
-#' @param Portfolio portfolio object
-#' @param Attribute attribute to calculate
-#' @param Dates date subset
-#' @param Symbols symbols to calculate for
-.calcPortfAttr <- function(Portfolio, Attribute, Dates=NULL, Symbols = NULL)
-{
- if(!inherits(Portfolio,"portfolio")) stop("Portfolio passed is not a portfolio object.")
- symbols = names(Portfolio)
- if(is.null(Dates)|is.na(Dates)) # if no date is specified, get all available dates
- Dates = time(Portfolio[[1]]$posPL)
-# else Dates = time(Portfolio[[1]]$posPL[Dates])
-
- switch(Attribute,
- Gross.Trading.PL = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Gross.Trading.PL', Dates = Dates, Symbols = Symbols)
-# result = xts(apply(table, FUN='sum', MARGIN=1), Dates)
- result = xts(rowSums(table), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Gross.Trading.PL'
- },
- Txn.Fees = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Txn.Fees', Dates = Dates, Symbols = Symbols)
- result = xts(rowSums(table), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Txn.Fees'
- },
- Net.Trading.PL = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Net.Trading.PL', Dates = Dates, Symbols = Symbols)
-# result = xts(apply(table, FUN='sum', MARGIN=1), Dates)
- result = xts(rowSums(table), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Net.Trading.PL'
- },
- Realized.PL = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Realized.PL', Dates = Dates, Symbols = Symbols)
- result = xts(rowSums(table), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Realized.PL'
- },
- Unrealized.PL = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Unrealized.PL', Dates = Dates, Symbols = Symbols)
- result = xts(rowSums(table), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Unrealized.PL'
- },
- Net.Value = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Dates = Dates, Symbols = Symbols)
- result = xts(rowSums(table), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Net.Value'
- },
- Gross.Value = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Dates = Dates, Symbols = Symbols)
- result = xts(rowSums(abs(table)), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Gross.Value'
- },
- Long.Value = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Dates = Dates, Symbols = Symbols)
- tmat = apply(table,MARGIN=c(1,2),FUN=max,0)# comes out a matrix
- result = xts(rowSums(tmat), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Long.Value'
- },
- Short.Value = {
- table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Pos.Value', Dates = Dates, Symbols = Symbols)
- tmat = apply(table,MARGIN=c(1,2),FUN=min,0) # comes out a matrix
- result = xts(rowSums(tmat), na.rm=TRUE ,order.by=index(table))
- colnames(result) = 'Short.Value'
- }
- )
- return(result)
-}
-
-###############################################################################
-# Blotter: Tools for transaction-oriented trading systems development
-# for R (see http://r-project.org/)
-# Copyright (c) 2008-2011 Peter Carl and Brian G. Peterson
-#
-# This library is distributed under the terms of the GNU Public License (GPL)
-# for full details see the file COPYING
-#
-# $Id: calcPortfAttr.R 307 2010-03-26 23:38:48Z peter_carl $
-#
-###############################################################################
Deleted: pkg/blotter/R/calcPortfSummary.R
===================================================================
--- pkg/blotter/R/calcPortfSummary.R 2011-01-04 16:16:13 UTC (rev 524)
+++ pkg/blotter/R/calcPortfSummary.R 2011-01-04 16:21:18 UTC (rev 525)
@@ -1,41 +0,0 @@
-#' Create portfolio summary
-#' @param Portfolio
-#' @param Dates
-calcPortfSummary <- function(Portfolio, Dates=NULL)
-{ # @ author Peter Carl
- if(!inherits(Portfolio,"portfolio")) stop("Portfolio passed is not a portfolio object.")
- # DESCRIPTION
- #
- # Long.Value, Short.Value, Net.Value, Trading.PL
-
- if(is.null(Dates) || is.na(Dates)) # if no date is specified, get all available dates
- Dates = time(Portfolio$symbols[[1]]$posPL )
-# else Dates = time(Portfolio$symbols[[1]]$posPL[Dates])
-
- GrossTradingPL = .calcPortfAttr(Portfolio, 'Gross.Trading.PL', Dates)
- NetTradingPL = .calcPortfAttr(Portfolio, 'Net.Trading.PL', Dates)
- RealizedPL = .calcPortfAttr(Portfolio, 'Period.Realized.PL', Dates)
- UnrealizedPL = .calcPortfAttr(Portfolio, 'Period.Unrealized.PL', Dates)
- # UnrealizedPL = TradingPL - RealizedPL
- TxnFees = .calcPortfAttr(Portfolio, 'Txn.Fees', Dates)
- NetValue = .calcPortfAttr(Portfolio, 'Net.Value', Dates)
- GrossValue = .calcPortfAttr(Portfolio, 'Gross.Value', Dates)
- LongValue = .calcPortfAttr(Portfolio, 'Long.Value', Dates)
- ShortValue = .calcPortfAttr(Portfolio, 'Short.Value', Dates)
-
- summary=merge(LongValue, ShortValue, NetValue, GrossValue, RealizedPL, UnrealizedPL, GrossTradingPL, TxnFees, NetTradingPL)
-# colnames(summary)=c('Long.Value', 'Short.Value', 'Net.Value', 'Gross.Value', 'Realized.PL', 'Unrealized.PL', 'Gross.Trading.PL','Txn.Fees','Net.Trading.PL')
- return(summary)
-}
-
-###############################################################################
-# Blotter: Tools for transaction-oriented trading systems development
-# for R (see http://r-project.org/)
-# Copyright (c) 2008-2011 Peter Carl and Brian G. Peterson
-#
-# This library is distributed under the terms of the GNU Public License (GPL)
-# for full details see the file COPYING
-#
-# $Id$
-#
-###############################################################################
Deleted: pkg/blotter/man/calcPortfAttr.Rd
===================================================================
--- pkg/blotter/man/calcPortfAttr.Rd 2011-01-04 16:16:13 UTC (rev 524)
+++ pkg/blotter/man/calcPortfAttr.Rd 2011-01-04 16:21:18 UTC (rev 525)
@@ -1,11 +0,0 @@
-\name{.calcPortfAttr}
-\alias{.calcPortfAttr}
-\title{calculate summary attributes for a portfolio...}
-\usage{.calcPortfAttr(Portfolio, Attribute, Dates, Symbols)}
-\description{calculate summary attributes for a portfolio}
-\details{supported values are:
-Gross.Trading.PL, Txn.Fee, Net.Trading.PL, Realized.PL, Unrealized.PL, Gross.Value, Long.Value, Short.Value}
-\arguments{\item{Portfolio}{portfolio object}
-\item{Attribute}{attribute to calculate}
-\item{Dates}{date subset}
-\item{Symbols}{symbols to calculate for}}
Deleted: pkg/blotter/man/calcPortfSummary.Rd
===================================================================
--- pkg/blotter/man/calcPortfSummary.Rd 2011-01-04 16:16:13 UTC (rev 524)
+++ pkg/blotter/man/calcPortfSummary.Rd 2011-01-04 16:21:18 UTC (rev 525)
@@ -1,7 +0,0 @@
-\name{calcPortfSummary}
-\alias{calcPortfSummary}
-\title{Create portfolio summary...}
-\usage{calcPortfSummary(Portfolio, Dates)}
-\description{Create portfolio summary}
-\arguments{\item{Portfolio}{}
-\item{Dates}{}}
More information about the Blotter-commits
mailing list