[WITH CODE] RiskOps: Exit policy and exit rules
Embrace a proactive approach to exit trades and anticipate market reversals, safeguard your investments, and convert potential pitfalls into opportunities
Table of contents:
Introduction.
What is an exit policy?
Next level of concretion, exit rule.
The exit strategy as a tactical approach.
Introduction
Entries are like fireworks that light up the sky. Everyone loves the sparkle and the thrill of those moments when you jump into a trade, expecting your portfolio to shoot to the moon. Everyone loves talking about entries—those flashy moments when you jump into a trade like a superhero.
But what about exits? Exits are like Batman—the thoughtful, well-planned decisions that prevent catastrophic losses and help secure profits. Think of exits as the afterparty cleanup crew: they ensure that all the excitement doesn't end in a financial mess.
In my view, modeling the exit of a trade is by far the most important thing to do when putting money at risk. The so vilified, forgotten, and misunderstood exits... Generally, we find two cases:
The quants focused on modeling the entry signal and finding a miracle variable that allows them to predict something and justify their salary.
The retail amateur—in the best-case scenario—setting a tight stop-loss at the entry point, basically anywhere and in any way.
Now, there are 3 fundamental levels to keep in mind: Policy → Rule → Strategy
What is an exit policy?
An exit policy is the overarching rulebook that helps you decide how much you’re willing to risk on a trade. Much like your parents set limits on your allowance or screen time, exit policies set the boundaries for how much money can be lost in any single trade. This is your risk management blueprint, designed to keep your portfolio from being devoured by the wild beasts of the market.
Basically, it is like the constitution of your trading system. It sets the overarching guidelines that govern all your trades. Think of it as the rules of the game, ensuring that no single trade can sink your entire portfolio. It is a strategic safeguard designed to:
Set strict loss limits, the policy ensures that even during adverse market conditions, your overall capital is protected.
Minimize emotional decisions, ensuring consistency and adherence to your trading plan.
Allow you to manage trades of various sizes without compromising the overall health of your portfolio.
A robust exit policy typically includes the following core components:
Risk caps: No single trade should result in a loss exceeding 2% of the entire portfolio value.
Stop-loss mandates: Every trade must have a stop-loss order.
Daily loss limits: The total daily loss per trading strategy should not exceed 5% of the allocated capital.
To illustrate why this is important, let’s consider a simple portfolio with an initial value P0. If a trade results in a loss L, then the remaining portfolio value P after the trade is given by:
To ensure no single trade exceeds 2% of the portfolio value, we set:
This ensures that even if the worst happens, your portfolio remains stable.
This is what would happen if you have a streak where you only lose and you go without the brakes of the 2%
Simply, crazy. As you can see, risk caps act as a safety net, preventing catastrophic losses.
But here the issue, how to coordinate those three? Let's develop it step by step.
Per-trade risk management with stop-loss orders:
For each trade i:
Determine the maximum allowable dollar loss:
\(R_i^{\text{max}} = 0.02 \times P\)Set the stop-loss order based on your entry price Ei and your chosen stop-loss percentage δi:
\(S_i = E_i \times (1 - \delta_i)\)Size your position—number of shares or units, Ni—so that the potential loss does not exceed the maximum allowable dollar loss:
\(N_i \leq \frac{0.02 \times P}{E_i \times \delta_i}\)
This ensures that if the trade moves against you and hits the stop-loss price, the loss will be capped at 2% of your portfolio.
Daily loss aggregation:
Even if every individual trade is capped at 2% loss, multiple trades in a single day could collectively exceed your daily risk limit. Suppose you execute nnn trades in one day, then the sum of losses must satisfy:
\(\sum_{i=1}^{n} L_i \leq 0.05 \times P\)For instance, if you take three trades in a day, even if each is allowed up to 2% loss, the maximum theoretical total loss would be:
\(3 \times 0.02 \times P\)which would exceed the 5% daily limit. Therefore, you must manage the number of trades or adjust position sizes such that the aggregated risk remains within the daily cap.
One practical approach is to set a rule like:
Only execute a new trade if the cumulative loss for the day plus the risk of the new trade is less than or equal to 5% of P:
\(\left( \sum_{i=1}^{k} L_i \right) + \left( E_{k+1} \times \delta_{k+1} \times N_{k+1} \right) \leq 0.05 \times P \)where k is the number of trades already taken that day.
Okay! Time to move to the next level.
Next level of concretion, exit rule
Now that we’ve established the big picture, let’s zoom in on the specifics. If exit policies are like your parent’s overall guidelines, then exit rules are the sharp looks your mom gives you when you’re about to sneak a cookie after bedtime.
Exit rules are the actionable instructions that tell your trading algorithm exactly when to pull the plug. These rules are precise and programmable, often based on price movements or other variables.
The most basic examples are:
Fixed percentage stop-loss: Close the position if the asset price falls by 3% from the purchase price.
Trailing stop-loss each N points: Allow the stop price to increase as the asset price increases but never decrease below a certain percentage of the peak price—N points is the part that belongs to the exit rule while the trailing stop-loss is part of the exit strategy.
Let's start with the first one, a fixed percentage. Consider you have purchased a stock at an entry price E. An exit rule might specify that if the stock price falls by 3% from the entry price, it’s time to exit. The stop-loss price S is then given by:
For an entry price of $50, this becomes:
So, if the stock price hits $48.50, you should exit the trade. The formula for the stop-loss price can be understood by considering a percentage decrease. A 3% decrease means that only 97% of the original price remains. In more general terms, if the percentage decrease is δ, then the stop-loss price S is:
For δ=0.03, we have:
This simple multiplication encapsulates the idea of preserving capital by capping losses. May this is the easiest way:
# Define the entry price and the stop-loss percentage
entry_price = 50
stop_loss_percent = 0.03
# Calculate the stop-loss price
stop_price = entry_price * (1 - stop_loss_percent)
# Let's simulate a scenario where the current price is at the stop-loss level
current_price = 48.50 # Uh-oh!
if current_price <= stop_price:
print("Abandon ship!!")
n contrast to fixed stop-losses, trailing stop-losses offer a dynamic approach that adapts as the asset’s price moves favorably. Imagine buying an asset at price Pbuy. and setting a trailing stop-loss at T%. As the asset price increases, the stop-loss price Pstop is recalculated to lock in gains, while it never moves lower than a preset percentage below the peak price: