TotalPnL: Calculate Total PnL for Given Protfolio

Description Usage Arguments Value Examples

View source: R/TotalPnL.R

Description

The evaluation is done at time of a given date. Length of 'TotalPnL' should be the same as number of trading days, not as 'dfLog'.

Usage

1
TotalPnL(dir = dir, df, date, time = 160000, market = 'SHSZ')

Arguments

dir

The directory containing the Tick data.

df

The dataframe containing the portfolio.

date

the date of evaluation.

time

the time of evaluation.

market

specifying the sub-function to call depending on the market.

Value

A number indicating the total pnl.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## locate tick data directory ##
dir <- system.file("extdata", '', package = "TickExec")

## establish a posiyion to sell ##
dfLog = LimitBuy(dir = dir, date = 20141013, ticker = 000001, capital = 1e6, 
                 limitPrice = NA, orderFrom = 94545, orderLast = 600, 
                 costIn = 0.001, market = 'SHSZ')

## sell ##
dfLogSold = MarketSell(dir = dir, date = 20141014, orderTime = 140001, 
                       dfLog = dfLog, costOut = 0.001, market = 'SHSZ')
                       
## market worth ##
TotalPnL(dir = dir, df = dfLogSold, date = 20141014, time = 145900, 
               market = 'SHSZ')

Example output

[1] -5940.746

TickExec documentation built on May 2, 2019, 9:58 a.m.

Related to TotalPnL in TickExec...