Learn R Programming

TickExec (version 1.1)

PerformanceReport: Summarize Back Test Performance

Description

Give 13 basic indicators base on the simple arithmetic investments.

Usage

PerformanceReport(df, cumPnL, initCap = NA)

Arguments

df
The dataframe containing the portfolio.
cumPnL
the daily pnl series, including those days with no trades.
initCap
initial capital, if given 'NA', then use the total capital recorded on the first trading day in the trade log 'df'.

Value

A dataframe with 13 basic indicators.
DAYS
number of total trading days.
FIRSTTRD
the day when first trade happened, normally the first trading day.
LASTTRD
the day when last trade happened, normally the last trading day.
NONTRDPERC
percentage for non-trading days.
DAILYTRD
average number of trades daily.
TOTALPNL
total pnl.
RETPERTRD
average return per trade.
TRDHITRAT
trade-wise hit rate.
DLYHITRAT
daily hit rate.
ANNRET
annual return.
SHARPE
annual sharpe ratio.
DRAWDOWN
maximum draw down.
INRETURN
intrinsic return.

Examples

Run this code
## locate tick data directory ##
dir <- system.file("extdata", '', package = "TickExec")
ticker = 000001

df <- c()
pnl <- c()

for (d in 20141012:20141017) {

dfLog = LimitBuy(dir = dir, date = d, ticker = ticker, capital = 1e6, 
                 limitPrice = NA, orderFrom = 94545, orderLast = 600, 
                 costIn = 0.001, market = 'SHSZ')

dfLogSold = MarketSell(dir = dir, date = d, orderTime = 140001, 
                       dfLog = dfLog, costOut = 0.001, market = 'SHSZ')


df <- rbind(df, dfLogSold)
pnl <- c(pnl, TotalPnL(dir = dir, df = df, date = d))
}

PerformanceReport(df = df, cumPnL = pnl, initCap = 1e6)

Run the code above in your browser using DataLab