- Published on
Investing Smartly - How to Evaluate Your Investment Strategy's Vulnerability
The Essentials
Investment strategies usually involve making bets with an exit plan based on two conditions: achieving a profit or stopping losses. The interaction between these factors is best understood as a binomial process that evaluates the strategy's resilience against minor changes. In a nutshell, you want a strategy with frequent bets and high precision to increase your Sharpe ratio, a measure of risk-adjusted returns.
The formula for the annualized Sharpe ratio with symmetric payouts is given by:
This shows the trade-off between precision and frequency for a given Sharpe ratio . For instance, to achieve an annualized Sharpe ratio of 2 with weekly bets, you would need a precision of .
For non-symmetric payouts, the annualized Sharpe ratio is:
Calculating Sharpe Ratio
import numpy as np
def sharpe_ratio_trials(
p: float,
n_run: int
) -> tuple[float, float, float]:
outcomes = np.random.binomial(n=1, p=p, size=n_run) * 2 - 1
mean_outcome = np.mean(outcomes)
std_outcome = np.std(outcomes)
sharpe_ratio = mean_outcome / std_outcome
return mean_outcome, std_outcome, sharpe_ratio
This functionality is available in both Python and Julia in the RiskLabAI library.
Advanced Calculations: Symbolic Operations
For those interested in deeper analysis, the equation for in terms of various parameters can be computed symbolically.
Where:
from sympy import symbols, factor
def target_sharpe_ratio_symbolic() -> sympy.Add:
p, u, d = symbols("p u d")
m2 = p * u**2 + (1 - p) * d**2
m1 = p * u + (1 - p) * d
v = m2 - m1**2
return factor(v)
Understanding Implied Precision
The impliedPrecision
function in both Python and Julia computes the implied betting frequency, denoted as . It takes four parameters:
stopLoss
: The stop loss thresholdprofitTaking
: The profit taking thresholdfrequency
: Number of bets per yeartargetSharpeRatio
: The target annual Sharpe ratio
The function deals with how varying the precision rate and profit/loss ratio affects the required betting frequency to achieve a given target Sharpe ratio .
Calculating Bin Frequency
The binFrequency
function calculates the annual frequency of bets, denoted as , required to achieve a target Sharpe ratio . The parameters are similar to those of impliedPrecision
.
Strategy Risk
Unlike portfolio risk, which is usually well-monitored, strategy risk often goes under the radar. Strategy risk is the risk that the investment strategy will fail to meet its objective over time. The question "What is the probability that this strategy will fail?" can be represented mathematically as .
To compute this, we:
- Estimate the profit/loss ratios and from a time series of bet outcomes.
- Calculate the annual frequency .
- Bootstrap the distribution of .
- Find , the value of below which the strategy will fail to achieve .
- Finally, compute the strategy risk as .
When is a Strategy too Risky?
Strategies with are usually considered too risky, irrespective of the underlying assets' volatility. This means that even if the strategy doesn't lose much money, the probability that it will fail to achieve its target is too high.
For code implementations of these algorithms, you can refer to the RiskLabAI library. The functionalities are available in both Python and Julia.
def implied_precision(
stop_loss: float,
profit_taking: float,
frequency: float,
target_sharpe_ratio: float
) -> float:
a = (frequency + target_sharpe_ratio**2) * (profit_taking - stop_loss)**2
b = (2 * frequency * stop_loss - target_sharpe_ratio**2 * (profit_taking - stop_loss)) * (profit_taking - stop_loss)
c = frequency * stop_loss**2
precision = (-b + (b**2 - 4 * a * c)**0.5) / (2 * a)
return precision
References
- De Prado, M. L. (2018). Advances in financial machine learning. John Wiley & Sons.
- De Prado, M. M. L. (2020). Machine learning for asset managers. Cambridge University Press.