greeks
npx machina-cli add skill staskh/trading_skills/greeks --openclawOption Greeks
Calculate Greeks for options using Black-Scholes model. Computes IV from market price via Newton-Raphson.
Instructions
Note: If
uvis not installed orpyproject.tomlis not found, replaceuv run pythonwithpythonin all commands below.
uv run python scripts/greeks.py --spot SPOT --strike STRIKE --type call|put [--expiry YYYY-MM-DD | --dte DTE] [--price PRICE] [--date YYYY-MM-DD] [--vol VOL] [--rate RATE]
Arguments
--spot- Underlying spot price (required)--strike- Option strike price (required)--type- Option type: call or put (required)--expiry- Expiration date YYYY-MM-DD (use this OR --dte)--dte- Days to expiration (alternative to --expiry)--date- Calculate as of this date instead of today (YYYY-MM-DD)--price- Option market price (for IV calculation)--vol- Override volatility as decimal (e.g., 0.30 for 30%)--rate- Risk-free rate (default: 0.05)
Output
Returns JSON with:
spot- Underlying spot pricestrike- Strike pricedays_to_expiry- Days until expirationiv- Implied volatility (calculated from market price)greeks- delta, gamma, theta, vega, rho
Examples
# With expiry date and market price (calculates IV)
uv run python scripts/greeks.py --spot 630 --strike 600 --expiry 2026-05-15 --type call --price 72.64
# With DTE directly
uv run python scripts/greeks.py --spot 630 --strike 600 --dte 30 --type call --price 40
# As of a future date
uv run python scripts/greeks.py --spot 630 --strike 600 --expiry 2026-05-15 --date 2026-03-01 --type call --price 50
Explain what each Greek means for the position.
Dependencies
scipy
Source
git clone https://github.com/staskh/trading_skills/blob/main/.claude/skills/greeks/SKILL.mdView on GitHub Overview
Greeks calculates delta, gamma, theta, vega, and rho using the Black-Scholes model and derives implied volatility (IV) from a market price using Newton-Raphson. It outputs spot, strike, days_to_expiry, iv, and the greeks, enabling sensitivity and risk analysis for options. This is essential for pricing insights, hedging, and comparing risk across different strikes and expiries.
How This Skill Works
The tool computes the Greeks under Black-Scholes for a given spot, strike, option type, and expiry (or days to expiry). If a market price is provided, it inverts the model with Newton-Raphson to estimate IV; otherwise you can provide a vol override with --vol. The result is a JSON containing spot, strike, days_to_expiry, iv, and the greeks (delta, gamma, theta, vega, rho).
When to Use It
- When you need delta, gamma, theta, vega, or rho for an option to assess sensitivity to price moves and time decay
- When you want to back out implied volatility (IV) from a market price for apples-to-apples comparisons
- When evaluating how greeks change as you adjust spot price or expiry across different scenarios
- When planning hedges and you need greeks to design delta-neutral or vega-neutral strategies
- When preparing risk or performance reports that require option sensitivity metrics
Quick Start
- Step 1: Gather inputs (spot, strike, type) and either expiry (YYYY-MM-DD) or dte (days to expiry)
- Step 2: Run the script with appropriate flags, e.g., --spot SPOT --strike STRIKE --type call --expiry YYYY-MM-DD --price PRICE
- Step 3: Read the JSON output for iv and greeks (delta, gamma, theta, vega, rho) and use them in your analysis
Best Practices
- Use the correct option type (call or put) and set expiry or days to expiry accurately
- Provide a market price (--price) to obtain a reliable IV via Newton-Raphson; omit if IV is known via --vol
- Verify inputs: spot, strike, rate (default 0.05) and date context to ensure correct greeks
- Cross-check greeks with alternative models or market data when near expiration or for unusual events
- Be mindful that Black-Scholes assumptions may degrade near expiry or for deep in-the-money/out-of-the-money options
Example Use Cases
- Calculate IV and Greeks for a 600 strike call on SPOT 630 with expiry 2026-05-15 and market price 72.64
- Compute DTE-based greeks for a 600 strike call with 30 days to expiry and market price 40
- As of a future date: spot 630, expiry 2026-05-15, type call, price 50 to derive IV and greeks
- Compare delta and vega for 600 strike call vs 650 strike call for the same expiry
- Back out IV and greeks to assess hedging needs for a long call position