arbitragelab.optimal_mean_reversion.heat_potentials
Module Contents
Classes
This class implements the algorithm for finding |
- class HeatPotentials
This class implements the algorithm for finding profit-taking and stop-loss levels for p/l that follow an Ornstein-Uhlenbeck process using the heat potential method. The following implementation is based on the work of Alexandr Lipton and Marcos Lopez de Prado “A closed-form solution for optimal mean-reverting trading strategies”<https://ssrn.com/abstract=3534445>`_
- fit(ou_params: list, delta_grid: float, max_trade_duration: float = None)
Fits the steady-state distribution to the given OU model, assigns the grid density with respect to t, maximum duration of the trade. Calculates and assigns values for optimal stop-loss and profit-taking levels.
- Parameters:
ou_params – (list) Parameters of the OU model. [theta, mu, sigma]
delta_grid – (float) Grid density with respect to t.
max_trade_duration – (float) Maximum duration of the trade.
- description() pandas.Series
Returns the statistics of the model. The optimal thresholds are converted back to the terms of the original data.
- Returns:
(pd.Series) Summary data for model parameters and optimal levels.
- v(max_trade_duration: float) numpy.ndarray
Calculates the grid of v(t) functions for t in [0,max_trade_duration] (p.5 and p.8)
- Parameters:
max_trade_duration – (float) Maximum duration of the trade.
- Returns:
(np.array) Grid of v(t).
- static upsilon(max_trade_duration: float) float
Calculates the helper function that corresponds to v(0). (p.5)
- param max_trade_duration:
(float) Maximum duration of the trade.
- return:
(float) Calculated value of v(0).
- omega(max_trade_duration: float) float
Calculates helper value for a method of heat potentials. (p.5)
- Parameters:
max_trade_duration – (float) Maximum duration of the trade.
- Returns:
(float) The result of function calculation.
- sharpe_calculation(max_trade_duration: float, optimal_profit: float, optimal_stop_loss: float) float
Calculates the Sharpe ratio. (p.6 )
- Parameters:
max_trade_duration – (float) Maximum duration of the trade.
optimal_profit – (float) Optimal profit-taking threshold.
optimal_stop_loss – (float) Optimal stop-loss level.
- Returns:
(float) Sharpe ratio.
- optimal_levels() list
Calculates optimal profit-taking and stop-loss levels by maximizing the Sharpe ratio.
- Returns:
(list) The list that consists of profit-taking level, stop-loss level, max Sharpe values.