addTrans: Add a transaction to a series of transactions

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/addTrans.R

Description

To add a transaction to the series of transactions for an instrument.

Usage

1
 txn = addTrans(txn, date, size=100, price, fees = 0) 

Arguments

txn

the xts time series with transactions for this instrument.

date

the transaction date as ISO 8106, e.g., '2008-09-01'.

size

the size of the transaction. Positive values indicate a 'buy'; negative values indicate a 'sell'.

price

market clearing price at which the transaction was done.

fees

fees for the transaction, e.g. commissions. Fees are indicated as negative values.

Details

The addTrans function will only add the transaction to the series of transactions. No PnL calculations are done.

Value

Returns the series of transactions with the new transaction.

Author(s)

Mark Breman

See Also

addDvd, pnl

Examples

1
2
3
4
5
  ## first transaction for this instrument:  on 2009-01-02 buy 36@23.05 and pay a commission of 1.0
  txn = addTrans(NULL, date='2009-01-02', size=36, price=23.05, fees=-1.0)

  ## sell them on 2009-01-04 for 23.09, and pay a commission of 1.0 
  txn = addTrans(txn, date='2009-01-04', size=-36, price=23.09, fees=-1.0)

pnl documentation built on May 2, 2019, 5:01 p.m.

Related to addTrans in pnl...