DrawdownCollection
QuantConnect.Report.DrawdownCollection
DrawdownCollection(strategy_series: Any, periods: int)
DrawdownCollection(periods: int)
Bases: Object
Collection of drawdowns for the given period marked by start and end date
Signature descriptions:
-
Creates an instance from the given drawdowns and the top N worst drawdowns
-
Creates an instance with a default collection (no items) and the top N worst drawdowns
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy_series
|
Optional[Any]
|
Equity curve with both live and backtesting merged |
None
|
periods
|
int
|
Periods this collection contains |
required |
start
start: datetime
Starting time of the drawdown collection
end
end: datetime
Ending time of the drawdown collection
periods
periods: int
Number of periods to take into consideration for the top N drawdown periods. This will be the number of items contained in the drawdowns collection.
from_result
from_result(
backtest_result: BacktestResult = None,
live_result: LiveResult = None,
periods: int = 5,
) -> DrawdownCollection
Generate a new instance of DrawdownCollection from backtest and live Result derived instances
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backtest_result
|
BacktestResult
|
Backtest result packet |
None
|
live_result
|
LiveResult
|
Live result packet |
None
|
periods
|
int
|
Top N drawdown periods to get |
5
|
Returns:
| Type | Description |
|---|---|
DrawdownCollection
|
DrawdownCollection instance. |
get_drawdown_periods
get_drawdown_periods(
curve: Any, periods: int = 5
) -> Iterable[DrawdownPeriod]
Gets the given drawdown periods from the equity curve and the set periods
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve
|
Any
|
Equity curve |
required |
periods
|
int
|
Top N drawdown periods to get |
5
|
Returns:
| Type | Description |
|---|---|
Iterable[DrawdownPeriod]
|
Enumerable of DrawdownPeriod. |
get_top_worst_drawdowns
get_top_worst_drawdowns(curve: Any, periods: int) -> Any
Gets the top N worst drawdowns and associated statistics. Returns a Frame with the following keys: "duration", "cumulativeMax", "drawdown"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve
|
Any
|
Equity curve |
required |
periods
|
int
|
Top N worst periods. If this is greater than the results, we retrieve all the items instead |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Frame with the following keys: "duration", "cumulativeMax", "drawdown". |
get_underwater
get_underwater(curve: Any) -> Any
Gets the underwater plot for the provided curve. Data is expected to be the concatenated output of ResultsUtil.equity_points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve
|
Any
|
Equity curve |
required |
get_underwater_frame
get_underwater_frame(curve: Any) -> Any
Gets all the data associated with the underwater plot and everything used to generate it. Note that you should instead use get_underwater(Series{DateTime, double}) if you want to just generate an underwater plot. This is internally used to get the top N worst drawdown periods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve
|
Any
|
Equity curve |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Frame containing the following keys: "returns", "cumulativeMax", "drawdown". |
normalize_results
normalize_results(
backtest_result: BacktestResult, live_result: LiveResult
) -> Any
Normalizes the Series used to calculate the drawdown plots and charts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backtest_result
|
BacktestResult
|
Backtest result packet |
required |
live_result
|
LiveResult
|
Live result packet |
required |