Skip to main content

MesoSim Basics: Vertical Spreads

· 6 min read
banner

Vertical Spreads are directional options strategies that can be applied in different market conditions. In this post we are going to show four different ways to use MesoSim's Strike Selector to implement Credit and Debit spreads.

Disclaimer

This post serves as a demonstration of MesoSim's leg selection process and is not intended to be used as a standalone trading strategy.

To trade directionally, a signal - timing entries and exits - would be highly recommended. This signal can be incorporated using MesoSim's External Data feature.


Call Debit Spread

We have created a detailed, step-by-step video demonstrating how to implement and backtest the Call Debit Spread in MesoSim using a delta-based strike selector.

This will serve as the baseline for this article:

Legs The Call Debit Spread uses a Delta-based Strike Selector for the long_call leg and the Statement-based Selector to choose the short_call contract 60 points higher.

"Legs": [
{
"Name": "short_call",
"Qty": "-1",
"OptionType": "Call",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
"Delta": "60",
...
}
},
{
"Name": "long_call",
"Qty": "1",
"OptionType": "Call",
"ExpirationName": "exp1",
"StrikeSelector": {
"Statement": "leg_long_call_strike + 60",
...
}
}
]

Related run: https://mesosim.io/backtests/a23a30c9-51a7-4406-99af-705f98a07f22


Call Credit Spread

For the Call Credit Spread, we used a mid-price-based strike selector on both legs. The mid-price is calculated as the midpoint between the bid and ask prices.

note

You can only use one of the selectors (ask/bid/mid price or one of the greek/IV options). Optionally, you can specify a Min and/or Max filter along with the selector.

Short Call Leg

This Strike Selector chooses an option with a MidPrice closest to $25:

"Legs": [
{
"Name": "short_call",
"Qty": "-1",
"OptionType": "Call",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
"MidPrice": "25",
...
}
},
...
]

Long Call Leg

Using the exact credit received from the short call leg to determine the price at which the long call leg is purchased. This is calculated by subtracting $20 from the short leg's price.

"Legs": [
...
{
"Name": "long_call",
"Qty": "1",
"OptionType": "Call",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
"MidPrice": "leg_short_call_price - 20",
...
}
}
]

Risk Graph

call credit spread

Related run: https://mesosim.io/backtests/0bda379c-4f82-45f3-b3c1-d15f96c9cda7


Put Credit Spread

Here, strikes are selected using a Statement-based strike selector. The use case for this selector is to determine the strike price of an option contract based on the result of evaluating the statement.

Short Put Leg

The leg is selected such that the contract's strike price is the closest to the underlying's price plus 50 points.

"Legs": [
{
"Name": "short_put",
"Qty": "-1",
"OptionType": "Put",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
"Statement": "underlying_price + 50",
...
}
},
...
]

Long Put Leg

This leg is in the money (ITM) because the strike price is 50 points lower than the current market price.

    "Legs": [
...
{
"Name": "long_put",
"Qty": "1",
"OptionType": "Put",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
"Statement": "underlying_price - 50",
...
}
}
]

Risk Graph

put credit spread

Related run: https://mesosim.io/backtests/0b866434-33f3-4234-8b5b-9f96aeb38997


Put Debit Spread

In our implementation of the Put Debit Spread, we are using the Complex Strike Selector. This selector iterates through all the contracts within the given expiration and selects the strike that best aligns with the specified criteria.

Long Put Leg

The target strike price is set to be at least 100 points above the underlying price, ensuring the leg remains out of the money (OTM). Additionally, the strike price must be divisible by 25.

info

The Strike Selection process begins by evaluating the constraints. If all conditions evaluate to true for a given contract, the Statement is calculated and added to the inclusion list. Once all contracts are processed, the target statement is evaluated. Finally, the contract closest to the target is selected from the inclusion list.

"Legs": [
{
"Name": "long_put",
"Qty": "1",
"OptionType": "Put",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
...
"Complex": {
"Statement": "leg_long_put_strike",
"Target": "underlying_price + 100",
"Constraints": [
"leg_long_put_strike % 25 == 0"
]
}
}
},
...
]

Short Put Leg

This leg follows nearly the same logic as the long put leg, but the target strike price is set to be at least 100 points below the underlying price. This ensures that the leg is In The Money (ITM).

"Legs": [
...
{
"Name": "short_put",
"Qty": "-1",
"OptionType": "Put",
"ExpirationName": "exp1",
"StrikeSelector": {
"Min": null,
"Max": null,
...
"Complex": {
"Statement": "leg_short_put_strike",
"Target": "underlying_price - 100",
"Constraints": [
"leg_short_put_strike % 25 == 0"
]
}
}
}
]

Risk Graph

put debit spread

Related run: https://mesosim.io/backtests/fec6e48f-6fa7-4952-ab6c-e753c353e6fe

info

You can find more detailed examples of the Complex Strike Selector in these blog posts:


Performance Summary

Since vertical spreads are directional trades, we expect bullish strategies (such as Call Debit Spreads and Put Credit Spreads) to perform well in bullish market conditions, like those anticipated in 2024. On the other hand, bearish strategies (such as Call Credit Spreads and Put Debit Spreads) should perform better in bearish market environments, like the one observed in 2022.

We conducted backtests to compare the performance of these strategies under different market conditions and validate these assumptions.

StrategyMarket ConditionCAGRMax DrawdownSharpeBacktest Link
Call Debit SpreadBullish16.02%-4.33%2.11Backtest
Call Debit SpreadBearish-15.72%-16.01%-1.68Backtest
Call Credit SpreadBullish-9.76%-14.77%-0.89Backtest
Call Credit SpreadBearish6.55%-8.38%0.72Backtest
Put Credit SpreadBullish11.41%-4.63%1.6Backtest
Put Credit SpreadBearish-16.06%-17.78%-1.75Backtest
Put Debit SpreadBullish-38.86%-51.34%-1.17Backtest
Put Debit SpreadBearish63.44%-12.71%2.39Backtest