StatisticsBuilder
QuantConnect.Statistics.StatisticsBuilder
Bases: Object
The StatisticsBuilder class creates summary and rolling statistics from trades, equity and benchmark points
create_benchmark_differences
create_benchmark_differences(
points: List[KeyValuePair[datetime, float]],
from_date: Union[datetime, date],
to_date: Union[datetime, date],
) -> Iterable[KeyValuePair[datetime, float]]
Yields pairs of date and percentage change for the period
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
List[KeyValuePair[datetime, float]]
|
The values to calculate percentage change for |
required |
from_date
|
Union[datetime, date]
|
Starting date (inclusive) |
required |
to_date
|
Union[datetime, date]
|
Ending date (inclusive) |
required |
Returns:
| Type | Description |
|---|---|
Iterable[KeyValuePair[datetime, float]]
|
Pairs of date and percentage change. |
generate
generate(
trades: List[Trade],
profit_loss: SortedDictionary[datetime, float],
points_equity: List[ISeriesPoint],
points_performance: List[ISeriesPoint],
points_benchmark: List[ISeriesPoint],
points_portfolio_turnover: List[ISeriesPoint],
starting_capital: float,
total_fees: float,
total_orders: int,
estimated_strategy_capacity: CapacityEstimate,
account_currency_symbol: str,
transactions: SecurityTransactionManager,
risk_free_interest_rate_model: IRiskFreeInterestRateModel,
trading_days_per_year: int,
) -> StatisticsResults
Generates the statistics and returns the results
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trades
|
List[Trade]
|
The list of closed trades |
required |
profit_loss
|
SortedDictionary[datetime, float]
|
Trade record of profits and losses |
required |
points_equity
|
List[ISeriesPoint]
|
The list of daily equity values |
required |
points_performance
|
List[ISeriesPoint]
|
The list of algorithm performance values |
required |
points_benchmark
|
List[ISeriesPoint]
|
The list of benchmark values |
required |
points_portfolio_turnover
|
List[ISeriesPoint]
|
The list of portfolio turnover daily samples |
required |
starting_capital
|
float
|
The algorithm starting capital |
required |
total_fees
|
float
|
The total fees |
required |
total_orders
|
int
|
The total number of transactions |
required |
estimated_strategy_capacity
|
CapacityEstimate
|
The estimated capacity of this strategy |
required |
account_currency_symbol
|
str
|
The account currency symbol |
required |
transactions
|
SecurityTransactionManager
|
The transaction manager to get number of winning and losing transactions |
required |
risk_free_interest_rate_model
|
IRiskFreeInterestRateModel
|
The risk free interest rate model to use |
required |
trading_days_per_year
|
int
|
The number of trading days per year |
required |
Returns:
| Type | Description |
|---|---|
StatisticsResults
|
Returns a StatisticsResults object. |
preprocess_performance_values
preprocess_performance_values(
points: List[KeyValuePair[datetime, float]],
) -> Iterable[KeyValuePair[datetime, float]]
Skips the first two entries from the given points and divides each entry by 100
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
List[KeyValuePair[datetime, float]]
|
The values to divide by 100 |
required |
Returns:
| Type | Description |
|---|---|
Iterable[KeyValuePair[datetime, float]]
|
Pairs of date and performance value divided by 100. |