[Blotter-commits] r407 - pkg/blotter/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 6 16:26:38 CEST 2010


Author: peter_carl
Date: 2010-10-06 16:26:38 +0200 (Wed, 06 Oct 2010)
New Revision: 407

Removed:
   pkg/blotter/R/calcAcctAttr.R
   pkg/blotter/R/calcEndEq.R
   pkg/blotter/R/calcPortfAttr.R
Log:
- functions rolled up into a single parent function and no longer needed


Deleted: pkg/blotter/R/calcAcctAttr.R
===================================================================
--- pkg/blotter/R/calcAcctAttr.R	2010-10-06 14:24:26 UTC (rev 406)
+++ pkg/blotter/R/calcAcctAttr.R	2010-10-06 14:26:38 UTC (rev 407)
@@ -1,35 +0,0 @@
-calcAcctAttr <- function(Account, Attribute, Dates=NULL)
-{ # @author Peter Carl
-
-    # DESCRIPTION
-    # 
-
-    # Inputs
-    # Account: an Account object containing Portfolio summaries
-    # Attribute: column name to be assembled for each symbol, any of:
-    # 'Long.Value', 'Short.Value', 'Net.Value', 'Gross.Value', 'Txn.Fees',
-    # 'Realized.PL', 'Unrealized.PL', or 'Trading.PL'
-
-    portfolios = names(Account)[-1]
-    if(is.null(Dates)) # if no date is specified, get all available dates
-        Dates = time(Account[[2]])
-#    else
-#        Dates = time(Account[[2]][Dates])
-    
-    table = .getByPortf(Account, Attribute, Dates)
-    result = xts(rowSums(table,na.rm=TRUE),order.by=index(table))
-    colnames(result) = Attribute
-    return(result)
-}
-
-###############################################################################
-# Blotter: Tools for transaction-oriented trading systems development
-# for R (see http://r-project.org/) 
-# Copyright (c) 2008-2010 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/R/calcEndEq.R
===================================================================
--- pkg/blotter/R/calcEndEq.R	2010-10-06 14:24:26 UTC (rev 406)
+++ pkg/blotter/R/calcEndEq.R	2010-10-06 14:26:38 UTC (rev 407)
@@ -1,39 +0,0 @@
-`calcEndEq` <-
-function(Account, Date)
-{ 
-    aname<-Account
-    Account<-try(get(paste("account",aname,sep='.'), envir=.blotter))
-    if(inherits(Account,"try-error"))
-        stop(paste("Account",aname," not found, use initAcct() to create a new account"))
-    # DESCRIPTION
-    # Calculates End.Eq and Net.Performance
-
-    # Requires that updateAcct has been run and any additional functions
-    # have alread appended information into that table (e.g., additions or
-    # withdrawals, fees, interest, etc.)
-    # Dates = time(Account[[1]])
-    # PrevDate = Dates[grep(Date, Dates)-1]
-    PrevDate = time(Account[[1]][Account[[1]][Date,which.i=TRUE]-1])
-    PrevEndEq = getEndEq(aname, PrevDate)
-    Additions = as.numeric(Account[[1]][Date]$Additions)
-    Withdrawals = as.numeric(Account[[1]][Date]$Withdrawals)
-    IntIncome = as.numeric(Account[[1]][Date]$Int.Income)
-    NetTradingPL = as.numeric(Account[[1]][Date]$Net.Trading.PL)
-    AdvisoryFees = as.numeric(Account[[1]][Date]$Advisory.Fees)
-    NetPerformance = IntIncome + NetTradingPL + AdvisoryFees
-    Account[[1]][Date,'Net.Performance'] = as.numeric(NetPerformance) 
-    Account[[1]][Date,'End.Eq'] = as.numeric(PrevEndEq + Additions + Withdrawals + NetPerformance)
-    return(Account)
-}
-
-###############################################################################
-# Blotter: Tools for transaction-oriented trading systems development
-# for R (see http://r-project.org/) 
-# Copyright (c) 2008-2010 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/R/calcPortfAttr.R
===================================================================
--- pkg/blotter/R/calcPortfAttr.R	2010-10-06 14:24:26 UTC (rev 406)
+++ pkg/blotter/R/calcPortfAttr.R	2010-10-06 14:26:38 UTC (rev 407)
@@ -1,73 +0,0 @@
-calcPortfAttr <- function(Portfolio, Attribute, Dates=NULL, Symbols = NULL)
-{
-    if(!inherits(Portfolio,"portfolio")) stop("Portfolio passed is not a portfolio object.")
-    symbols = names(Portfolio$symbols)
-    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])
-
-    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'
-        },
-        Period.Realized.PL = {
-            table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Period.Realized.PL', Dates = Dates, Symbols = Symbols)
-            result = xts(rowSums(table, na.rm=TRUE), order.by=index(table))
-            colnames(result) = 'Period.Realized.PL'
-        },
-        Period.Unrealized.PL = {
-            table = .getBySymbol(Portfolio = Portfolio, Attribute = 'Period.Unrealized.PL', Dates = Dates, Symbols = Symbols)
-            result = xts(rowSums(table, na.rm=TRUE), order.by=index(table))
-            colnames(result) = 'Period.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-2010 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$
-#
-###############################################################################



More information about the Blotter-commits mailing list