Trading_skills ib-find-short-roll
Find roll options for existing short positions OR find best covered call/put to open against long stock. Use when user asks about rolling shorts, finding roll candidates, writing covered calls, or managing option positions. Requires TWS or IB Gateway running locally.
install
source · Clone the upstream repo
git clone https://github.com/staskh/trading_skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/staskh/trading_skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/ib-find-short-roll" ~/.claude/skills/staskh-trading-skills-ib-find-short-roll && rm -rf "$T"
manifest:
.claude/skills/ib-find-short-roll/SKILL.mdsource content
IB Find Short Roll
Analyze roll options for short positions or find best short options to open against long stock using real-time data from Interactive Brokers.
Prerequisites
User must have TWS or IB Gateway running locally with API enabled:
- Paper trading: port 7497
- Live trading: port 7496
Instructions
Step 1: Gather Data
Note: If
is not installed oruvis not found, replacepyproject.tomlwithuv run pythonin all commands below.python
uv run python scripts/roll.py SYMBOL [--strike STRIKE] [--expiry YYYYMMDD] [--right C|P] [--port PORT] [--account ACCOUNT]
The script returns JSON to stdout with all position and candidate data.
Step 2: Format Report
Read
templates/markdown-template.md for formatting instructions. Generate a markdown report from the JSON data and save to sandbox/.
Step 3: Report Results
Present key findings to the user: recommended position, credit/debit, and the saved report path.
Behavior
- If short option position exists (
): Analyzes roll candidates to different expirations/strikesmode: "roll" - If long option position exists (
): Finds best short call/put to create a vertical spreadmode: "spread" - If long stock exists (
): Finds best covered call (or protective put) to openmode: "new_short" - If none of the above: Returns error (use --strike/--expiry to specify manually)
Arguments
- Ticker symbol (e.g., GOOG, AAPL, TSLA)SYMBOL
- Current short strike price (optional, auto-detects from portfolio)--strike
- Current short expiration in YYYYMMDD format (optional, auto-detects)--expiry
- Option type: C for call, P for put (default: C)--right
- IB port (default: 7496 for live trading)--port
- Specific account ID (optional)--account
JSON Output
The script outputs JSON with
mode field indicating the analysis type:
Common Fields
- Booleansuccess
- Timestampgenerated
- "roll", "spread", or "new_short"mode
- Tickersymbol
- Current stock priceunderlying_price
- Next earnings date or nullearnings_date
- List of expiry dates checkedexpirations_analyzed
Mode-specific Fields
- roll:
,current_position
,buy_to_close
(dict of expiry -> candidates)roll_candidates - spread:
,long_option
,rightcandidates_by_expiry - new_short:
,long_position
,rightcandidates_by_expiry
Example Usage
# Auto-detect GOOG position (short option, long option, or long stock) uv run python scripts/roll.py GOOG --port 7496 # Specify exact short position to roll uv run python scripts/roll.py GOOG --strike 350 --expiry 20260206 --right C # Find short call to sell against long call (vertical spread) uv run python scripts/roll.py AUR --right C # Find covered put for long stock uv run python scripts/roll.py TSLA --right P
Dependencies
ib-asyncyfinance