investos.portfolio.result package¶
Submodules¶
investos.portfolio.result.base_result module¶
- class investos.portfolio.result.base_result.BaseResult(start_date, end_date, **kwargs)¶
Bases:
SaveResult
The Result class captures portfolio data and performance for each asset and period over time.
Instances of this object are called by the
investos.portfolio.controller.Controller.generate_positions()
method.- property actual_returns: str¶
Returns a pandas DF of actual returns for assets.
- property annual_turnover¶
- property annualized_benchmark_return: float¶
Returns a float representing the annualized benchmark return of the entire period under review. Uses beginning and ending portfolio values for the calculation (value @ t[-1] and value @ t[0]), as well as the number of years in the forecast.
- property annualized_excess_return: float¶
Returns a float representing the annualized excess return of the entire period under review. Uses beginning and ending portfolio values for the calculation (value @ t[-1] and value @ t[0]), as well as the number of years in the forecast.
- property annualized_return: float¶
Returns a float representing the annualized return of the entire period under review. Uses beginning and ending portfolio values for the calculation (value @ t[-1] and value @ t[0]), as well as the number of years in the forecast.
- property annualized_return_over_cash: float¶
Returns a float representing the annualized return over cash of the entire period under review. Uses beginning and ending portfolio values for the calculation (value @ t[-1] and value @ t[0]), as well as the number of years in the forecast.
- property benchmark_returns: Series¶
- property benchmark_v: Series¶
Returns series of simulated portfolio values, if portfolio was invested 100% in benchmark at time 0
- property cash_column_name: str¶
Returns string of cash column name in holdings and trades.
- property cumulative_return: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property cumulative_return_long: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property cumulative_return_short: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property excess_returns: Series¶
Returns a pandas Series of returns in excess of the benchmark.
- property excess_risk_annualized: Series¶
Returns a pandas Series of risk in excess of the benchmark.
- property h: DataFrame¶
Returns a pandas Dataframe of asset holdings (h) at the beginning of each datetime period.
- hit_rate(scale_ignore=10000)¶
- property information_ratio: float¶
Returns a float representing the (annualized) Information Ratio of the portfolio.
Ratio is calculated as mean of
excess_returns
/ standard deviation ofexcess_returns
. Annualized by multiplying ratio by square root of periods per year (ppy
).
- information_ratio_rolling(n=252) Series ¶
- property leverage¶
Turnover ||u_t||_1/v_t
- property long_leverage¶
Turnover ||u_t||_1/v_t
- property max_drawdown¶
The maximum peak to trough drawdown in percent.
- property num_periods: int¶
Number of periods in backtest. Note that the starting position (at t=0) does not count as a period.
- property portfolio_hit_rate¶
- property ppy: float¶
Returns a float representing the number of periods per year in the backtest period. Calculated as
num_periods
/years_forecast
- property returns: Series¶
Returns a pandas Series of the returns for each datetime period (vs the previous period).
- property returns_over_cash: Series¶
Returns a pandas Series of returns in excess of risk free returns.
- property risk_free_returns: Series¶
- property risk_over_cash_annualized: Series¶
Returns a pandas Series of risk in excess of the risk free rate.
- save_data(name: str, t: datetime, entry: Series) None ¶
Save entry on Result object, a (pandas) Series of data as name for datetime t.
- Parameters:
name (str) – The name entry is saved under in this Result object.
t (datetime.datetime) – The datetime entry is saved under in this Result object.
entry (pandas.Series) – A series of values - for a collection of assets / stocks / tickers at a specific point in time.
- save_position(t: datetime, u: Series, h_next: Series) None ¶
Save data u and h_next related to position for datetime t on Result object.
- Parameters:
t (datetime.datetime) – The datetime for associated trades u and t + 1 holdings h_next.
u (pandas.Series) – Trades (as values) for period t.
h_next (pandas.Series) – Holdings at beginning of period t + 1, after trades u and returns for period t.
- property sharpe_ratio: float¶
Returns a float representing the (annualized) Sharpe Ratio of the portfolio.
Ratio is calculated as mean of
excess_returns
/ standard deviation ofexcess_returns
. Annualized by multiplying ratio by square root of periods per year (ppy
).
- sharpe_ratio_rolling(n=252) Series ¶
- property short_leverage¶
Turnover ||u_t||_1/v_t
- property starting_aum¶
- property summary: None¶
Outputs a string summary of backtest result properties and performance (e.g.
num_periods
,sharpe_ratio
,max_drawdown
, etc.).
- property total_benchmark_return: float¶
Returns a float representing the return over benchmark for the entire period under review.
- property total_excess_return: float¶
Returns a float representing the total return for the entire period under review.
- property total_return: float¶
Returns a float representing the total return for the entire period under review.
- property total_return_over_cash: float¶
Returns a float representing the total returns over cash for the entire period under review.
- property total_risk_free_return: float¶
- property trades: DataFrame¶
Returns a pandas Series of trades (u).
- property turnover¶
Turnover ||u_t||_1/v_t
- property v: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property v_created: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property v_created_long: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property v_created_short: Series¶
Returns a pandas Series for the value (v) of the portfolio for each datetime period.
- property v_with_benchmark: Series¶
Returns a pandas Dataframe with simulated portfolio and benchmark values.
- property years_forecast: float¶
Returns a float representing the number of years in the backtest period. Calculated as (datetime @ t[-1] - datetime @ t[0]) / datetime.timedelta(days=365.25)