-
-
Notifications
You must be signed in to change notification settings - Fork 1
Utils
The utils.py module contains various utility functions for calculating technical indicators, risk metrics, and other helper functions used in the backtesting framework.
Calculates the Simple Moving Average (SMA) for the given data and period.
Calculates the Exponential Moving Average (EMA) for the given data and period.
Calculates the Relative Strength Index (RSI) for the given data and period.
calculateBollingerBands(data: pd.Series, period: int = 20, stdDev: int = 2) -> Tuple[pd.Series, pd.Series, pd.Series]
Calculates the Bollinger Bands for the given data, period, and standard deviation.
calculateMACD(data: pd.Series, fastPeriod: int = 12, slowPeriod: int = 26, signalPeriod: int = 9) -> Tuple[pd.Series, pd.Series, pd.Series]
Calculates the Moving Average Convergence Divergence (MACD) indicator for the given data and periods.
Calculates the maximum drawdown and current drawdown for the given data.
Calculates the Sharpe Ratio for the given returns and risk-free rate.
Calculates the volatility for the given returns, optionally annualized.
Calculates the beta for the given returns and market returns.
Calculates various return statistics for the given returns.
Calculates the Sortino Ratio for the given returns and risk-free rate.
calculateTreynorRatio(returns: pd.Series, marketReturns: pd.Series, riskFreeRate: float = 0.01) -> float
Calculates the Treynor Ratio for the given returns, market returns, and risk-free rate.
Calculates the Value at Risk (VaR) for the given returns and confidence level.
Gets the previous rows of data up to the specified date and number of periods.
analyzeResults(results1: BacktestResult, results2: BacktestResult, initial_investment: float = 10000) -> dict
Analyzes and compares the results of two backtests.
Compares the results of two backtests and returns a summary of the differences.
Gets the historical returns of the S&P 500 index for the specified date range.