From Research Paper to Live Execution

Published First on Substack

Automating a Volatility Strategy With Python and Interactive Brokers was originally published on Substack. Read the full article for a complete walkthrough of building, deploying, and operating a systematic volatility strategy using Python and the Interactive Brokers API.

A few months ago, we published a research paper called The Volatility Edge: A Dual Approach For VIX ETNs Trading. It won 5th place at the Quantpedia Awards 2026. The strategy compounds at 16.3% per year over a 17-year backtest, delivers a Sharpe ratio of 1, and keeps equity market correlation near 15%.

This article shows how to build an automated VIX volatility trading strategy using Python and Interactive Brokers. Based on our award-winning research, the strategy seeks to capture the volatility risk premium through systematic exposure to VIX-linked ETNs.

The paper is public. The strategy rules are fully transparent. And we built a Python notebook that automates the entire thing through Interactive Brokers.

This article is about the process of turning a research idea into a working automated trading system. We walk through the theory behind the strategy, the signal logic, the position sizing, and the code that connects it all to a live broker API.

This is meant as an educational exercise, not a production-ready system. The notebook is a starting point. We strongly encourage anyone interested to run their own tests, validate the signals on out-of-sample data, and stress-test the execution logic before deploying any real capital. The goal here is to show what the workflow looks like, not to hand you a finished product.

Let’s start with the theory.

1. Why Volatility Is Tradable

Most investors bet on direction. They buy stocks hoping prices go up, or they short hoping prices go down. Volatility traders don’t care about direction. They bet on how much prices will move, regardless of which way.

In practice, this means buying volatility when it’s cheap (usually when the crowd is calm) or selling volatility when participants are willing to overpay for it (usually when fear dominates and everyone wants portfolio insurance).

The key insight is simple: implied volatility, what the options market thinks will happen, almost always overestimates what actually happens. The VIX Index, which represents the market’s 30-day volatility forecast for the S&P 500, has overestimated realized volatility roughly 80% of the time over the past two decades.

That gap between what the market expects and what actually unfolds is called the Volatility Risk Premium (VRP).

Why does this premium exist? Because volatility tends to spike when equities fall. Portfolio managers buy protection through options and variance swaps, and the pool of risk-averse buyers persistently exceeds the pool of sellers willing to warehouse that risk. In equilibrium, sellers demand a premium. That premium is what we’re trying to capture.

2. From Variance Swaps to VIX ETNs

For decades, the only way to trade volatility directly was through variance swaps. These are OTC contracts between institutions, requiring ISDA agreements, large notionals, and counterparty infrastructure. Not exactly accessible to individual investors.

That changed in March 2004, when VIX futures launched on the Cboe Futures Exchange. And it changed again in January 2009, when Barclays launched VXX, the first exchange-traded note linked to VIX futures.

Suddenly, anyone with a brokerage account could trade volatility.

VXX tracks a rolling position in the two nearest-month VIX futures contracts, maintaining an average maturity of about 30 days. Think of it as a daily rolling bet on short-term VIX futures.

Today, several VIX-linked products exist:

The strategy in the paper uses SVXY to go short volatility and VXX to go long volatility. That’s it. Two instruments, one brokerage account.

3. The Two Signals

The paper builds up to the final strategy through four progressive versions. Each one adds a layer of sophistication. We’ll skip straight to the logic that matters: the two signals that drive the final strategy.

Signal 1: Expected Volatility Risk Premium (eVRP)

This answers a simple question: is implied volatility currently higher or lower than what we expect realized volatility to be?

To estimate future realized volatility, we compute the standard deviation of the last 10 daily SPY returns and annualize it:

eRV30 = std(last 10 daily returns) * sqrt(252) * 100

Then we compare it to the VIX:

eVRP = VIX - eRV30

If eVRP is positive, the market is pricing in more volatility than recent history suggests. The premium looks attractive. If eVRP is negative or zero, the market might be underpricing risk, and shorting volatility becomes dangerous.

Signal 2: VIX Term Structure (Backwardation or Contango)

This answers a different question: what does the shape of the VIX curve tell us about market stress?

We compare the VIX (30-day implied volatility) to VIX3M (90-day implied volatility):

Combining these two signals gives us four regimes:

1. eVRP > 0 and VIX < VIX3M: Best case. The premium is attractive and the term structure is normal. Go short volatility at full size.

2. eVRP <= 0 and VIX < VIX3M: The premium has compressed, but the term structure is still calm. Stay short volatility, but at half size.

3. eVRP <= 0 and VIX > VIX3M: Both signals are negative. The expected premium is gone and the term structure is inverted. Flip to long volatility.

4. eVRP > 0 and VIX > VIX3M: Mixed signal. The premium looks attractive but the term structure says stress. Stay in cash.

4. Dynamic Sizing

Here’s where the strategy gets clever.

A static allocation to short volatility is dangerous because the risk of shorting volatility is not constant. When the VIX is at 12, even a modest shock can cause it to double. You collect small premiums while sitting in front of a steamroller. When the VIX is at 35, the odds of it doubling again are much lower, and the premium you’re getting paid is much richer.

The paper uses a dead-simple sizing rule: your allocation equals the VIX level divided by 100.

This naturally reduces exposure during fragile low-VIX environments and increases it when volatility is elevated and the expected payoff is higher.

The full strategy rules are:

ConditionPositionSize
eVRP > 0 and VIX < VIX3MLong SVXY (short vol)VIX% x 2
eVRP <= 0 and VIX < VIX3MLong SVXY (short vol)0.5 x VIX% x 2
eVRP <= 0 and VIX > VIX3MLong VXX (long vol)VIX%
eVRP > 0 and VIX > VIX3MCash0%

The “x 2” on SVXY is because SVXY only provides -0.5x exposure. To get the equivalent of a -1x short, you need twice the dollar amount.

The portfolio is rebalanced only when the current allocation drifts more than 2% from the target. This avoids unnecessary trading and keeps transaction costs low.

5. The Results

Over the January 2008 to May 2025 backtest period, after 5 basis points of transaction costs per trade:

MetricValue
CAGR16.3%
Sharpe Ratio1.00
Sortino Ratio1.67
Max Drawdown-31.0%
Adjusted Max Drawdown-12.4%
Alpha (vs S&P 500)15.0%
Beta (vs S&P 500)0.12
Correlation to S&P 50014.8%

The strategy was short volatility on 90% of days, in cash for 6%, and long volatility for 4%.

What makes these numbers interesting is the combination: high absolute returns, near-zero correlation to equities, and a Sharpe of 1. Blending even a 10-20% allocation of this strategy into a passive SPY portfolio boosts the combined Sharpe ratio by roughly 20%.

6. Automating It

The strategy runs once per day, near the close.

The execution method is a Market-on-Close (MOC) order. A MOC order is submitted before the exchange cutoff (typically 3:50 PM ET on the NYSE) and gets executed at the official closing auction price. You don’t control the exact price, but you get the close, which is the most liquid print of the day. This is what institutional rebalancing flows use, and it’s the execution method assumed in the paper’s backtest.

Because MOC orders must be submitted before 3:50 PM, we need the signal ready before that deadline. The system computes signals at 3:45 PM ET. More precisely, it uses the closing price of the 1-minute bar that starts at 3:44 PM, which represents the market state at 3:45. This gives enough time to fetch data, compute the signal, and submit the MOC order before the cutoff, with a few minutes of buffer.

So the daily workflow is: at 3:45 PM ET, grab three numbers (VIX, VIX3M, and the 10-day realized volatility of SPY), compute the signal, determine the position size, and submit a MOC order. That’s it.

The full automation pipeline has four steps.

Step 1: Connect and Fetch Data

The system connects to IBKR’s Trader Workstation via the ib_async Python library. It pulls 30 days of daily SPY closes and one day of minute-level data for SPY, VIX, and VIX3M.

The last daily SPY close gets replaced with the 3:44 PM intraday price, so the realized volatility estimate includes today’s move up to the signal time.

Step 2: Compute the Signal

Using the data from Step 1:

  1. Compute the 10-day standard deviation of SPY returns, annualize it
  2. Subtract it from the current VIX to get eVRP
  3. Compare VIX to VIX3M to determine contango or backwardation
  4. Map the two signals to one of the four regimes

Step 3: Size and Place Orders

Once the signal is determined:

  1. Compute the target allocation using VIX / 100
  2. Convert that to a dollar amount based on account equity
  3. Divide by the current price of SVXY or VXX to get share count
  4. Compare the target weight against the current weight
  5. If the difference exceeds the 2% rebalancing threshold, submit a MOC order

Step 4: Log and Disconnect

Every execution is logged to a CSV file with the full state: prices, signals, weights, target positions, orders placed, and timestamps. The system then disconnects from IBKR.

7. The Code

The full implementation is a Jupyter notebook with five cells. Here’s the structure:

Cell 0: Install packages. ib_async, pandas, numpy, pytz, ipywidgets.

Cell 1: Setup. Connects to IBKR, qualifies the five contracts (SPY, VIX, VIX3M, VXX, SVXY).

Cell 2: Data collection. Waits until the signal time, fetches daily and intraday data, extracts the 3:44 PM prices.

Cell 3: Signal and execution. Computes eVRP, checks term structure, determines sizing, fetches live prices for VXX/SVXY, calculates target shares, compares against current holdings, places MOC orders if the rebalancing threshold is breached, and verifies order acceptance.

Cell 4: Logging. Writes every field to a CSV and disconnects.

Cell 5: User interface. A widget-based form where you enter your account value, current positions, market close time, and rebalancing threshold. One click runs the entire pipeline.

The notebook is publicly available. You can find it in the Google Colab link referenced in the paper.

Google Colab
Interactive Brokers Automation
Open the Strategy Notebook
This Google Colab notebook contains the complete implementation of the VIX term-structure strategy described in this paper.

The notebook connects to Interactive Brokers, collects market data, computes the signal, determines portfolio sizing, submits Market-on-Close (MOC) orders, logs every execution to CSV, and provides a simple widget-based interface for daily operation.

The implementation is organized into five cells covering setup, data collection, signal generation, order execution, logging, and a user-friendly control panel for running the strategy.
Educational Example Only
This is not a production-ready trading system. The notebook is intended as an educational exercise and a starting point for further research.

Before deploying any capital, you should independently validate the signals, perform out-of-sample testing, stress-test the execution logic, verify data quality, and ensure the implementation behaves correctly under real-world market conditions.

The goal of this notebook is to demonstrate the workflow and methodology behind the strategy—not to provide a finished investment product or a turnkey trading solution.
Open Google Colab Notebook →

8. Running It in Practice

A few things to keep in mind before you run this live.

Use paper trading first. Connect to IBKR’s paper trading account (port 7497) and run the strategy for a few weeks. Watch the signals, verify the orders, check the CSV log. Make sure the numbers make sense before you risk real capital.

Update your positions honestly. The current version takes your VXX and SVXY share counts as manual input. If you enter the wrong numbers, the orders will be wrong. Double-check before every execution.

Respect the MOC deadline. Market-on-Close orders must be submitted before 3:50 PM ET on the NYSE. The strategy computes signals at 3:44 PM and submits immediately after. That gives you a comfortable window, but don’t add unnecessary delays.

Watch for early-close days. A handful of trading sessions each year close at 1:00 PM ET instead of 4:00 PM. The notebook lets you adjust the market close time via a dropdown. On those days, select the 13:00 option so the signal time shifts to 12:44 PM and the MOC order goes out before the early cutoff.

This is not a set-and-forget system. The strategy is systematic, but the execution environment needs supervision. Connections drop, data goes stale, orders get rejected. If you want to learn more about what can go wrong, we wrote a separate article on 10 operational pitfalls of algo trading.

Legal Notice
Important Disclaimer
The information presented on this website is provided for educational, informational, and research purposes only. Nothing published here should be interpreted as investment advice, a recommendation to buy or sell any security, or a solicitation to engage in any investment strategy.

All investments involve risk, including the potential loss of principal. Past performance does not guarantee future results. Readers should conduct their own due diligence and consult qualified financial, legal, or tax professionals before making investment decisions.

Any opinions expressed are those of the authors and are subject to change without notice. While we strive for accuracy, we make no representations or warranties regarding the completeness, reliability, or suitability of any information provided.

By using this website, you acknowledge and agree that any reliance on the information contained herein is solely at your own risk.

Conclusion

Volatility trading used to be the exclusive domain of institutional hedge funds with OTC infrastructure, ISDA agreements, and dedicated quant teams. That’s no longer the case.

With a standard brokerage account, two ETNs, and a few lines of Python, individual investors can now access the same volatility risk premium that institutions have harvested for decades. The strategy presented here is deliberately simple: two signals, dynamic sizing, and one daily trade. No options expertise required. No leverage. No complex hedging.

The full research paper is available publicly. The code is open source. The backtest results are transparent and reproducible.

But simplicity does not mean safety. Volatility itself is volatile. Position sizing matters. Risk management matters. And the operational details of running live automated systems matter just as much as the strategy logic.

Use the paper as a starting point. Study the signals. Run the notebook on paper trading. Understand what you’re doing before you deploy capital. And if you need help building a more robust production setup around it, reach out.

Get research like this before it’s public.

Enter your email to receive our next data-driven analysis.

Live Experiment

Can You Beat a Systematic Strategy?

We’re running a research experiment to test whether day trading skill can improve the performance of a fully systematic intraday strategy.

No trade generation. No guessing.
Just managing exposure using price action — and we are measuring the result.

Join the Experiment →