PortfolioMarginUsageAnalysis
QuantConnect.Lean.Engine.Results.Analysis.Analyses.PortfolioMarginUsageAnalysis
Bases: BaseResultsAnalysis
Detects periods where the portfolio under-utilises available margin (3-day SMA of margin usage drops below 50 %).
issue
issue: str
Gets the description of the detected margin under-utilisation issue.
weight
weight: int
Gets the severity weight for this margin usage analysis.
run
run(
parameters: ResultsAnalysisRunParameters,
) -> Sequence[Analysis]
Signature descriptions:
-
Runs the portfolio margin usage analysis against the provided backtest parameters.
-
Reads the "Portfolio Margin" chart from the backtest result and counts trading days where the 3-day SMA of total margin usage drops below 50%.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backtest_result
|
Optional[Result]
|
The backtest result whose charts are inspected. |
None
|
Returns:
| Type | Description |
|---|---|
Sequence[Analysis]
|
Analysis results when any such days are detected. |
single_response
single_response(
sample: Any, solutions: Sequence[str] = None
) -> Sequence[Analysis]
single_response(
sample: Any,
count: Optional[int],
solutions: Sequence[str] = None,
) -> Sequence[Analysis]
Wraps a single QuantConnect.Analysis in a one-element read-only list.
create_aggregated_response
Filters responses to those with solutions, prefixes the class name, and returns a flat list.
This codeEntityType is protected.
format_code
format_code(code: str, language: Language) -> str
Formats the specified code string according to the conventions of the given programming language.
This codeEntityType is protected.