options greeks change every second. tracking them manually is impossible. automated it.
the problem with static greeks #
most platforms show you greeks at order time. cool. but what about 2 hours later when underlying moved 2%?
delta that was -0.30 is now -0.45. gamma accelerated. theta decay hit. your position risk completely changed.
if you’re not tracking this in real-time, you’re flying blind.
what i built #
python script that:
- fetches live greeks every 5 seconds from ThetaData API
- calculates portfolio-level greeks (sum across all positions)
- stores in postgres for historical analysis
- alerts if portfolio delta >100 or gamma >50
Figure 1: Greeks evolution throughout the trading day for a short put spread position.
why this matters #
example from last week:
opened SPX put spread: delta -0.25, gamma 0.015, theta -0.08
3 hours later SPX dropped 1.5%. my greeks:
- delta: -0.48 (almost doubled)
- gamma: 0.032 (more than doubled)
- theta: -0.12
position went from small delta exposure to “holy shit if SPX drops another 1% i’m fucked”
my automated system sent alert at delta -0.40. closed half the position. saved probably $2k when SPX continued dropping.
integration with IB #
using ib_insync python library to pull greeks:
from ib_insync import *
import time
class GreeksTracker:
def __init__(self):
self.ib = IB()
self.ib.connect('127.0.0.1', 7497, clientId=1)
def get_position_greeks(self, contract):
"""Fetch current greeks for a position"""
ticker = self.ib.reqTickers(contract)[0]
greeks = {
'delta': ticker.modelGreeks.delta if ticker.modelGreeks else None,
'gamma': ticker.modelGreeks.gamma if ticker.modelGreeks else None,
'theta': ticker.modelGreeks.theta if ticker.modelGreeks else None,
'vega': ticker.modelGreeks.vega if ticker.modelGreeks else None,
'timestamp': time.time()
}
return greeks
def track_portfolio_greeks(self):
"""Calculate portfolio-level greeks"""
positions = self.ib.positions()
total_delta = 0
total_gamma = 0
total_theta = 0
total_vega = 0
for pos in positions:
if pos.contract.secType == 'OPT': # Options only
greeks = self.get_position_greeks(pos.contract)
if greeks['delta']:
total_delta += greeks['delta'] * pos.position
total_gamma += greeks['gamma'] * pos.position
total_theta += greeks['theta'] * pos.position
total_vega += greeks['vega'] * pos.position
return {
'total_delta': total_delta,
'total_gamma': total_gamma,
'total_theta': total_theta,
'total_vega': total_vega,
'timestamp': time.time()
}
the theta decay advantage #
one benefit of tracking theta: can see exactly how much i’m collecting per day from selling premium.
my current positions theta: -$180/day (negative because i’m short options)
that means if nothing moves, i collect $180 every day from time decay. $180 * 20 trading days = $3,600/month passive income.
except when SPX moves 2% and delta/gamma wipe out a week of theta gains in 10 minutes. but that’s options trading.
alert thresholds #
set up telegram alerts for:
- portfolio delta >100 (too directional)
- portfolio gamma >50 (too much convexity risk)
- theta <-$500/day (too much premium sold)
- any single position delta >30 (position too large)
been super helpful. caught myself over-leveraged twice this week based on gamma alerts.
comparing to theoretical #
also track difference between realized greeks and theoretical (black-scholes):
if realized delta differs from BS delta by >10%, usually means:
- bad data feed
- assignment risk priced in
- wide bid-ask spread affecting greeks
helps me spot when my greeks are bullshit vs when position actually changed.
2:15am. greeks tracker running smooth. now i can see exactly how fucked i am in real-time instead of guessing.
-AK