API¶
This package provides functions for implementing the Almgren-Chriss model for optimal execution of portfolio transactions.
Modules¶
- cost
Provides functions for calculating the expectation, variance and value-at-risk of the cost of trading.
- decay_rate
Provides functions for calculating the trade decay rate.
- trade
Provides functions for calculating the trading trajectory and the list of trades.
Functions¶
- cost_expectation
Calculate the expected cost of trading.
- cost_variance
Calculate the variance of the cost of trading.
- value_at_risk
Calculate the value-at-risk of the cost of trading.
- decay_rate
Calculate the trade decay rate.
- trade_trajectory
Calculate the trading trajectory.
- trade_list
Calculate the list of trades.
- almgren_chriss.cost_expectation(lambda_: float, tau: float, sigma: float, gamma: float, eta: float, epsilon: float, X: float, T: float) ndarray ¶
Compute the expected cost of trading in the Almgren-Chriss model.
\[E(X) = \frac{1}{2}\gamma X^2+\epsilon X+\tilde{\eta}X^2\frac{\tanh(\frac{1}{2}\kappa\tau)\big(\tau\sinh(2\kappa T) + 2T\sinh(\kappa\tau) \big)}{2\tau^2\sinh^2(\kappa T)}\]- Parameters:
lambda (float) – Risk tolerance
tau (float) – Interval between trades
sigma (float) – Volatility
gamma (float) – Permanent impact slope
eta (float) – Temporary impact slope
epsilon (float) – Temporary impact intercept
X (float) – Total number of shares
T (float) – Trading duration
- Returns:
The expected cost of trading
- Return type:
float
- almgren_chriss.cost_variance(lambda_: float, tau: float, sigma: float, gamma: float, eta: float, X: float, T: float) ndarray ¶
Compute the variance of the cost of trading in the Almgren-Chriss model.
\[V(X) = \frac{1}{2}\sigma^2X^2\frac{\tau\sinh(\kappa T) \cosh(\kappa(T-\tau))-T\sinh(\kappa\tau)}{\sinh^2(\kappa T)\sinh(\kappa\tau)}\]- Parameters:
lambda (float) – Risk tolerance
tau (float) – Interval between trades
sigma (float) – Volatility
gamma (float) – Permanent impact slope
eta (float) – Temporary impact slope
X (float) – Total number of shares
T (float) – Trading duration
- Returns:
The variance of the cost of trading
- Return type:
float
- almgren_chriss.value_at_risk(lambda_: float, tau: float, sigma: float, gamma: float, eta: float, epsilon: float, X: float, T: float, probability: float = 0.95) ndarray ¶
Compute the value-at-risk of the cost of trading in the Almgren-Chriss model.
\[Var_p(x) = E(x) + \lambda_v \sqrt{V(x)}\]- Parameters:
lambda (float) – Risk tolerance
tau (float) – Interval between trades
sigma (float) – Volatility
gamma (float) – Permanent impact slope
eta (float) – Temporary impact slope
epsilon (float) – Temporary impact intercept
X (float) – Total number of shares
T (float) – Trading duration
probability (float) – Probability that the cost won’t exceed the value-at-risk.
- Returns:
The value-at-risk of the cost of trading
- Return type:
float
- almgren_chriss.decay_rate(lambda_: float, tau: float, sigma: float, gamma: float, eta: float) float ¶
Compute the trade decay rate in the Almgren-Chriss model.
\[\kappa = \frac{\cosh^{-1}\left( \frac{\tau^2}{2} \tilde{\kappa}^2 + 1 \right)}{\tau}\]- Parameters:
lambda (float) – Risk tolerance
tau (float) – Interval between trades
sigma (float) – Volatility
gamma (float) – Permanent impact slope
eta (float) – Temporary impact slope
- Returns:
The trade decay rate
- Return type:
float
- almgren_chriss.trade_trajectory(lambda_: float, tau: float, sigma: float, gamma: float, eta: float, X: float, T: float) ndarray ¶
Compute the trading trajectory in the Almgren-Chriss model.
\[x_j = \frac{\sinh(\kappa(T-t_j))}{\sinh(\kappa T)}X\]- Parameters:
lambda (float) – Risk tolerance
tau (float) – Interval between trades
sigma (float) – Volatility
gamma (float) – Permanent impact slope
eta (float) – Temporary impact slope
X (float) – Total number of shares
T (float) – Trading duration
- Returns:
The trading trajectory
- Return type:
np.ndarray
- almgren_chriss.trade_list(lambda_: float, tau: float, sigma: float, gamma: float, eta: float, X: float, T: float) ndarray ¶
Compute the list of trades in the Almgren-Chriss model.
\[n_j = \frac{2\sinh(\frac{1}{2}\kappa\tau)}{\sinh(\kappa T)} \cosh\left(\kappa\left(T-t_{j-\frac{1}{2}} \right) \right)X\]- Parameters:
lambda (float) – Risk tolerance
tau (float) – Interval between trades
sigma (float) – Volatility
gamma (float) – Permanent impact slope
eta (float) – Temporary impact slope
X (float) – Total number of shares
T (float) – Trading duration
- Returns:
The list of trades
- Return type:
np.ndarray