Table of Contents

Class DrawdownCollection

Namespace
Balsam
Assembly
Balsam.Backtester.dll

A collection of drawdowns.

[ProtoContract]
public class DrawdownCollection : ICollection<Drawdown>, IEnumerable<Drawdown>, IEnumerable
Inheritance
DrawdownCollection
Implements
Inherited Members
Extension Methods

Properties

Count

Gets the number of drawdowns in the collection.

public int Count { get; }

Property Value

int

Current

Gets the current open drawdown if any.

public Drawdown Current { get; }

Property Value

Drawdown

this[int]

Gets a drawdown from the collection using the specified index.

public Drawdown this[int index] { get; }

Parameters

index int

Property Value

Drawdown

LongestDrawdown

Gets the longest drawdown in terms of time.

public Drawdown LongestDrawdown { get; }

Property Value

Drawdown

LongestFlatPeriod

Gets the drawdown with the longest flat period (drawdown + recovery time).

public Drawdown LongestFlatPeriod { get; }

Property Value

Drawdown

MaxPercent

Gets the drawdown with the maximum percentage decline.

public Drawdown MaxPercent { get; }

Property Value

Drawdown

MaxPoints

Gets the drawdown with the maximum point decline.

public Drawdown MaxPoints { get; }

Property Value

Drawdown

UlcerIndex

Gets the Ulcer Index, a measure of drawdown length and severity.

public double UlcerIndex { get; }

Property Value

double

Methods

Add(Drawdown)

Adds a drawdown to the collection.

public void Add(Drawdown drawdown)

Parameters

drawdown Drawdown

Calculate(TimeSeries)

Returns a drawdown collection for the specified series with the default sort of max percent drawdown.

public static DrawdownCollection Calculate(TimeSeries equityCurve)

Parameters

equityCurve TimeSeries

Returns

DrawdownCollection

Calculate(TimeSeries, DrawdownSort)

Returns drawdown collection for the specified series using the specifed sorting.

public static DrawdownCollection Calculate(TimeSeries equityCurve, DrawdownCollection.DrawdownSort sort)

Parameters

equityCurve TimeSeries
sort DrawdownCollection.DrawdownSort

Returns

DrawdownCollection

Clear()

Removes all items from the collection.

public void Clear()

Contains(Drawdown)

Determines whether the specified drawdown is contained in the collection.

public bool Contains(Drawdown drawdown)

Parameters

drawdown Drawdown

Returns

bool

ExportToFile(string)

Export drawdowns to a csv file.

public void ExportToFile(string fileName)

Parameters

fileName string

GetAvgOfTopNDrawdowns(int)

Returns the average of the worst n percentage drawdowns.

public double GetAvgOfTopNDrawdowns(int n)

Parameters

n int

The number of drawdowns to average.

Returns

double

GetAvgYearlyDrawdown()

Gets the average yearly maximum drawdown (where drawdown is reset at the beginning of each calendar year).

public double GetAvgYearlyDrawdown()

Returns

double

GetEnumerator()

Returns an enumerator that iterates through the drawdown collection.

public IEnumerator<Drawdown> GetEnumerator()

Returns

IEnumerator<Drawdown>

GetWeightedAvgDrawdown()

Returns the sum of the percent drawdown * bars in drawdown divided by total bars in all drawdowns.

public double GetWeightedAvgDrawdown()

Returns

double

GetYearlyDrawdowns()

Returns yearly drawdowns.

public IEnumerable<KeyValuePair<int, double>> GetYearlyDrawdowns()

Returns

IEnumerable<KeyValuePair<int, double>>

Remove(Drawdown)

Removes the specified drawdown from the collection.

public bool Remove(Drawdown drawdown)

Parameters

drawdown Drawdown

Returns

bool

Sort(DrawdownSort)

Sort the drawdowns.

public void Sort(DrawdownCollection.DrawdownSort sortType)

Parameters

sortType DrawdownCollection.DrawdownSort

The drawdown property to compare.

ToString()

Returns a string representation of the current drawdown collection.

public override string ToString()

Returns

string