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
Current
Gets the current open drawdown if any.
public Drawdown Current { get; }
Property Value
this[int]
Gets a drawdown from the collection using the specified index.
public Drawdown this[int index] { get; }
Parameters
index
int
Property Value
LongestDrawdown
Gets the longest drawdown in terms of time.
public Drawdown LongestDrawdown { get; }
Property Value
LongestFlatPeriod
Gets the drawdown with the longest flat period (drawdown + recovery time).
public Drawdown LongestFlatPeriod { get; }
Property Value
MaxPercent
Gets the drawdown with the maximum percentage decline.
public Drawdown MaxPercent { get; }
Property Value
MaxPoints
Gets the drawdown with the maximum point decline.
public Drawdown MaxPoints { get; }
Property Value
UlcerIndex
Gets the Ulcer Index, a measure of drawdown length and severity.
public double UlcerIndex { get; }
Property Value
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
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
TimeSeriessort
DrawdownCollection.DrawdownSort
Returns
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
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
intThe number of drawdowns to average.
Returns
GetAvgYearlyDrawdown()
Gets the average yearly maximum drawdown (where drawdown is reset at the beginning of each calendar year).
public double GetAvgYearlyDrawdown()
Returns
GetEnumerator()
Returns an enumerator that iterates through the drawdown collection.
public IEnumerator<Drawdown> GetEnumerator()
Returns
GetWeightedAvgDrawdown()
Returns the sum of the percent drawdown * bars in drawdown divided by total bars in all drawdowns.
public double GetWeightedAvgDrawdown()
Returns
GetYearlyDrawdowns()
Returns yearly drawdowns.
public IEnumerable<KeyValuePair<int, double>> GetYearlyDrawdowns()
Returns
Remove(Drawdown)
Removes the specified drawdown from the collection.
public bool Remove(Drawdown drawdown)
Parameters
drawdown
Drawdown
Returns
Sort(DrawdownSort)
Sort the drawdowns.
public void Sort(DrawdownCollection.DrawdownSort sortType)
Parameters
sortType
DrawdownCollection.DrawdownSortThe drawdown property to compare.
ToString()
Returns a string representation of the current drawdown collection.
public override string ToString()