Table of Contents

Class EquityCurveStats

Namespace
Balsam
Assembly
Balsam.Backtester.dll

Calculates comprehensive performance statistics on an equity curve

[ProtoContract]
[ProtoInclude(96, typeof(PerformanceStats))]
public class EquityCurveStats : TradeStats
Inheritance
EquityCurveStats
Derived
Inherited Members
Extension Methods

Properties

AnnualTurnover

Gets annual turnover as a percent of average account value.

public double AnnualTurnover { get; }

Property Value

double

ArithmeticSharpeRatio

Gets the Sharpe Ratio using an arithmetic rather than geometric annualized return.

public double ArithmeticSharpeRatio { get; }

Property Value

double

AvgAccountValue

Gets the average value of account equity.

public double AvgAccountValue { get; }

Property Value

double

AvgDrawdown

Gets the average of all drawdowns.

public double AvgDrawdown { get; }

Property Value

double

AvgMaxRetracement

Gets the average maximum retracement (see Schwager).

public double AvgMaxRetracement { get; }

Property Value

double

AvgOfTop5Drawdowns

Gets the average of the worse five percentage drawdowns.

public double AvgOfTop5Drawdowns { get; }

Property Value

double

AvgReturn

Gets the mean return.

public double AvgReturn { get; }

Property Value

double

AvgYearlyDrawdown

Gets the average yearly maximum drawdown.

public double AvgYearlyDrawdown { get; }

Property Value

double

CAGR

Gets the compound annual growth rate.

public double CAGR { get; }

Property Value

double

ConditionalSharpe

Gets a Sharpe Ratio calculated using conditional VaR (expected tail loss) in the denominator.

public double ConditionalSharpe { get; }

Property Value

double

ConditionalVaR

Gets the conditional Value-at-Risk (expected tail loss).

public double ConditionalVaR { get; }

Property Value

double

ConfidenceLevel

Gets/sets the confidence level used in the VaR calculations.

public double ConfidenceLevel { get; set; }

Property Value

double

DownsideDeviation

Gets the annualized downside or semideviation below TargetReturn.

public double DownsideDeviation { get; }

Property Value

double

Drawdowns

Gets a collection of all equity drawdowns.

public DrawdownCollection Drawdowns { get; }

Property Value

DrawdownCollection

EndDate

Gets the last date in the equity curve.

public DateTime EndDate { get; }

Property Value

DateTime

EndingAccountValue

Gets the ending account value.

public double EndingAccountValue { get; }

Property Value

double

GainToPainRatio

Gets Schwager's Gain To Pain Ratio (sum of monthly returns / abs value of monthly losses).

public double GainToPainRatio { get; }

Property Value

double

HistoricalVaR

Gets the historical Value-at-Risk.

public double HistoricalVaR { get; }

Property Value

double

Iterations

Gets/sets the number of iterations used to resample the return stream.

public int Iterations { get; set; }

Property Value

int

KRatio

Gets the Kestner Ratio, a measure of equity curve smoothness.

public double KRatio { get; }

Property Value

double

LongestDrawdownEndDate

Gets the date on which a new equity high was achieved after the longest drawdown.

public DateTime LongestDrawdownEndDate { get; }

Property Value

DateTime

LongestDrawdownPeriods

Gets the number of business days of the longest drawdown.

public int LongestDrawdownPeriods { get; }

Property Value

int

LongestDrawdownStartDate

Gets the beginning date of the longest drawdown.

public DateTime LongestDrawdownStartDate { get; }

Property Value

DateTime

LongestFlatEndDate

Gets the date on which a new equity high is made after the longest flat period in equity.

public DateTime LongestFlatEndDate { get; }

Property Value

DateTime

LongestFlatPeriods

Gets the number of business days of the longest flat period in equity.

public int LongestFlatPeriods { get; }

Property Value

int

LongestFlatStartDate

Gets the start date of the longest flat period in equity.

public DateTime LongestFlatStartDate { get; }

Property Value

DateTime

MARRatio

Gets the Managed Accounts Report ratio (CAGR / MaxDrawdownPercent).

public double MARRatio { get; }

Property Value

double

MaxAccountValue

Gets the maximum account value achieved.

public double MaxAccountValue { get; }

Property Value

double

MaxDrawdown

Gets the maximum point drawdown.

public double MaxDrawdown { get; }

Property Value

double

MaxDrawdownDate

Gets the date on which the max point drawdown was observed.

public DateTime MaxDrawdownDate { get; }

Property Value

DateTime

MaxDrawdownPercent

Gets the maximum percentage drawdown.

public double MaxDrawdownPercent { get; }

Property Value

double

MaxDrawdownPercentDate

Gets the date on which the maximum percentage drawdown was observed.

public DateTime MaxDrawdownPercentDate { get; }

Property Value

DateTime

MaxReturn

Gets the max period return.

public double MaxReturn { get; }

Property Value

double

MinAccountValue

Gets the minimum account value suffered.

public double MinAccountValue { get; }

Property Value

double

MinReturn

Gets the min period return.

public double MinReturn { get; }

Property Value

double

MonthlySharpe

Gets the Sharpe Ratio calculated on monthly data.

public double MonthlySharpe { get; }

Property Value

double

NetPnL

Gets the net P&L (ending account value - startup cash). This includes interest, dividends, commissions, etc.

public override double NetPnL { get; }

Property Value

double

NewHighs

Gets the number of new equity highs achieved.

public int NewHighs { get; }

Property Value

int

NewHighsPercent

Gets the percent of days a new equity high was achieved.

public double NewHighsPercent { get; }

Property Value

double

OmegaRatio

Gets the Omega ratio.

public double OmegaRatio { get; }

Property Value

double

PeakRatio

Gets the peak ratio (inverse of Seykota's Lake Ratio).

public double PeakRatio { get; }

Property Value

double

Periodicity

Gets/sets the periodicity of the equity curve.

public Periodicity Periodicity { get; set; }

Property Value

Periodicity

PeriodsInDrawdown

Gets the number of days spent in drawdown.

public int PeriodsInDrawdown { get; }

Property Value

int

PeriodsInDrawdownPercent

Gets the number of days in drawdown as a percent of total days.

public double PeriodsInDrawdownPercent { get; }

Property Value

double

PeriodsLosing

Gets the number of losing days.

public int PeriodsLosing { get; }

Property Value

int

PeriodsLosingPercent

Gets the percent of losing days.

public double PeriodsLosingPercent { get; }

Property Value

double

PeriodsPerYear

Used to annualize standard deviation based on number of periods per year (e.g. 12 for monthly data).

public int PeriodsPerYear { get; }

Property Value

int

PeriodsWinning

Gets the number of winning days.

public int PeriodsWinning { get; }

Property Value

int

PeriodsWinningPercent

Gets the percent of winning days.

public double PeriodsWinningPercent { get; }

Property Value

double

RAD

Gets the Returns adjusted for drawdowns aka Keller Ratio. See Breadth Momentum and Vigilant Asset Allocation (https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3002624).

public double RAD { get; }

Property Value

double

ROI

Gets the return on investment.

public double ROI { get; }

Property Value

double

RSquared

Gets the R-squared value of a linear regression on the log equity curve.

public double RSquared { get; }

Property Value

double

ResampledMAR

Gets the MAR ratio used resampled max drawdown in the denominator.

public double ResampledMAR { get; }

Property Value

double

ResampledMaxDrawdown

Gets the average max dradown from boostrapped daily return stream.

public double ResampledMaxDrawdown { get; }

Property Value

double

ReturnRetracementRatio

Gets Schwager's Return Retracement Ratio (CAGR - RiskFreeRate) / AvgMaxRetracement.

public double ReturnRetracementRatio { get; }

Property Value

double

RiskFreeRate

Gets/sets the risk free interest rate. Value should be expressed in decimal form (e.g. 5% = 0.05).

public double RiskFreeRate { get; set; }

Property Value

double

SDSharpeRatio

Gets the Symmetric Downside-Risk Sharpe Ratio. See Schwager's "Market Sense and Nonsense: How the Markets Really Work (and How They Don't)".

public double SDSharpeRatio { get; }

Property Value

double

SharpeRatio

Gets the Sharpe Ratio (CAGR - RiskFreeRate)/Annualized Std Dev.

public double SharpeRatio { get; }

Property Value

double

Skew

Gets the skew.

public double Skew { get; }

Property Value

double

SortinoRatio

Gets the Sortino ratio (CAGR - TargetReturn) / DownsideDeviation.

public double SortinoRatio { get; }

Property Value

double

StandardDeviation

Gets the standard deviation of daily returns.

public double StandardDeviation { get; }

Property Value

double

StartDate

Gets the first date in the equity curve.

public DateTime StartDate { get; }

Property Value

DateTime

StartupCash

Gets the starting cash balance.

public double StartupCash { get; }

Property Value

double

TailRatio

Gets the tail ratio [95th percentile of daily returns / Abs(5th percentile)].

public double TailRatio { get; }

Property Value

double

TargetReturn

Gets/sets the target or minimum acceptable return. Value should expressed as an annual rate in decimal form (e.g. 2% = 0.02). Used the Omega and Sortino ratio calculations.

public double TargetReturn { get; set; }

Property Value

double

TotalPeriods

Gets the total number of periods in the money management test expressed in whatever units Periodicity is in.

public int TotalPeriods { get; }

Property Value

int

UlcerIndex

Gets the Ulcer Index, a measure of drawdown severity.

public double UlcerIndex { get; }

Property Value

double

UlcerPerformanceIndex

Gets the Ulcer Performance aka Martin Index (CAGR - RiskFreeRate)/Ulcer Index * 100.

public double UlcerPerformanceIndex { get; }

Property Value

double

VaR

Gets the parametric Value-at-Risk in percentage terms.

public double VaR { get; }

Property Value

double

Volatility

Gets the annualized standard deviation (std dev * Sqrt(PeriodsPerYear))

public double Volatility { get; }

Property Value

double

Methods

Calculate(TimeSeries)

Calculates statistics using the specified equity curve. Note this uses dollar values, not returns. Convert a return series to an equity curve using Indicators.Vami before using.

public void Calculate(TimeSeries equityCurve)

Parameters

equityCurve TimeSeries

GetDailyReturns()

Returns a timeseries of the daily returns.

public TimeSeries GetDailyReturns()

Returns

TimeSeries

GetEquityCurve()

Returns a timeseries of the daily equity curve.

public TimeSeries GetEquityCurve()

Returns

TimeSeries

GetMonthlyPerformanceGrid()

Returns a matrix of monthly returns suitable for display with year in first column and annual returns in the last column.

public double[,] GetMonthlyPerformanceGrid()

Returns

double[,]

GetMonthlyReturns()

Returns a timeseries of monthly returns.

public TimeSeries GetMonthlyReturns()

Returns

TimeSeries

OnCalculate(TimeSeries)

Performs the equity curve calculations.

protected virtual void OnCalculate(TimeSeries equityCurve)

Parameters

equityCurve TimeSeries