thetabook 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- thetabook-2.0.0/.claude/commands/accounts-init.md +45 -0
- thetabook-2.0.0/.claude/commands/adjust.md +84 -0
- thetabook-2.0.0/.claude/commands/chain.md +57 -0
- thetabook-2.0.0/.claude/commands/close.md +51 -0
- thetabook-2.0.0/.claude/commands/diff.md +47 -0
- thetabook-2.0.0/.claude/commands/evaluate.md +48 -0
- thetabook-2.0.0/.claude/commands/greeks.md +35 -0
- thetabook-2.0.0/.claude/commands/idea.md +48 -0
- thetabook-2.0.0/.claude/commands/ideas.md +29 -0
- thetabook-2.0.0/.claude/commands/open.md +40 -0
- thetabook-2.0.0/.claude/commands/portfolio.md +59 -0
- thetabook-2.0.0/.claude/commands/price.md +28 -0
- thetabook-2.0.0/.claude/commands/refresh.md +9 -0
- thetabook-2.0.0/.claude/commands/roll-scenarios.md +72 -0
- thetabook-2.0.0/.claude/commands/roll.md +125 -0
- thetabook-2.0.0/.claude/commands/setup.md +98 -0
- thetabook-2.0.0/.claude/commands/wiki-lint.md +77 -0
- thetabook-2.0.0/.env.example +6 -0
- thetabook-2.0.0/.github/workflows/ci.yml +31 -0
- thetabook-2.0.0/.github/workflows/publish.yml +100 -0
- thetabook-2.0.0/.gitignore +51 -0
- thetabook-2.0.0/.python-version +1 -0
- thetabook-2.0.0/CHANGELOG.md +1563 -0
- thetabook-2.0.0/CLAUDE.md +213 -0
- thetabook-2.0.0/CONTRIBUTING.md +66 -0
- thetabook-2.0.0/LICENSE +21 -0
- thetabook-2.0.0/PKG-INFO +15 -0
- thetabook-2.0.0/README.md +511 -0
- thetabook-2.0.0/ROADMAP.md +419 -0
- thetabook-2.0.0/SECURITY.md +32 -0
- thetabook-2.0.0/docs/architecture.md +406 -0
- thetabook-2.0.0/docs/behaviors.md +138 -0
- thetabook-2.0.0/docs/cli.md +136 -0
- thetabook-2.0.0/docs/hosted-service-proposal.md +113 -0
- thetabook-2.0.0/docs/skills-roadmap.md +174 -0
- thetabook-2.0.0/docs/skills.md +91 -0
- thetabook-2.0.0/pyproject.toml +134 -0
- thetabook-2.0.0/src/thetabook/__init__.py +50 -0
- thetabook-2.0.0/src/thetabook/cache.py +136 -0
- thetabook-2.0.0/src/thetabook/cli/__init__.py +99 -0
- thetabook-2.0.0/src/thetabook/cli/_shared.py +93 -0
- thetabook-2.0.0/src/thetabook/cli/accounts.py +86 -0
- thetabook-2.0.0/src/thetabook/cli/adjust.py +88 -0
- thetabook-2.0.0/src/thetabook/cli/bs.py +80 -0
- thetabook-2.0.0/src/thetabook/cli/chain.py +70 -0
- thetabook-2.0.0/src/thetabook/cli/diff.py +57 -0
- thetabook-2.0.0/src/thetabook/cli/dividends.py +64 -0
- thetabook-2.0.0/src/thetabook/cli/earnings.py +37 -0
- thetabook-2.0.0/src/thetabook/cli/evaluate.py +64 -0
- thetabook-2.0.0/src/thetabook/cli/greeks.py +46 -0
- thetabook-2.0.0/src/thetabook/cli/ideas.py +137 -0
- thetabook-2.0.0/src/thetabook/cli/import_csv.py +21 -0
- thetabook-2.0.0/src/thetabook/cli/init.py +382 -0
- thetabook-2.0.0/src/thetabook/cli/leg_mark.py +65 -0
- thetabook-2.0.0/src/thetabook/cli/migrate_home.py +116 -0
- thetabook-2.0.0/src/thetabook/cli/price.py +39 -0
- thetabook-2.0.0/src/thetabook/cli/refresh.py +25 -0
- thetabook-2.0.0/src/thetabook/cli/roll.py +60 -0
- thetabook-2.0.0/src/thetabook/cli/skills.py +461 -0
- thetabook-2.0.0/src/thetabook/cli/snapshot.py +87 -0
- thetabook-2.0.0/src/thetabook/cli/tickers.py +126 -0
- thetabook-2.0.0/src/thetabook/cli/wiki.py +178 -0
- thetabook-2.0.0/src/thetabook/config.py +42 -0
- thetabook-2.0.0/src/thetabook/ideas/__init__.py +0 -0
- thetabook-2.0.0/src/thetabook/ideas/adjust.py +1219 -0
- thetabook-2.0.0/src/thetabook/ideas/core.py +487 -0
- thetabook-2.0.0/src/thetabook/ideas/evaluate_idea.py +996 -0
- thetabook-2.0.0/src/thetabook/ideas/manage_ideas.py +550 -0
- thetabook-2.0.0/src/thetabook/ideas/roll_scenarios.py +558 -0
- thetabook-2.0.0/src/thetabook/leg_parse.py +201 -0
- thetabook-2.0.0/src/thetabook/log.py +52 -0
- thetabook-2.0.0/src/thetabook/market/__init__.py +0 -0
- thetabook-2.0.0/src/thetabook/market/_schwab.py +77 -0
- thetabook-2.0.0/src/thetabook/market/chains.py +514 -0
- thetabook-2.0.0/src/thetabook/market/dividends.py +620 -0
- thetabook-2.0.0/src/thetabook/market/earnings.py +205 -0
- thetabook-2.0.0/src/thetabook/market/leg_marks.py +205 -0
- thetabook-2.0.0/src/thetabook/market/prices.py +461 -0
- thetabook-2.0.0/src/thetabook/market/vol_lookup.py +223 -0
- thetabook-2.0.0/src/thetabook/models.py +280 -0
- thetabook-2.0.0/src/thetabook/paths.py +383 -0
- thetabook-2.0.0/src/thetabook/portfolio/__init__.py +0 -0
- thetabook-2.0.0/src/thetabook/portfolio/accounts.py +1044 -0
- thetabook-2.0.0/src/thetabook/portfolio/diff_snapshots.py +374 -0
- thetabook-2.0.0/src/thetabook/portfolio/get_positions.py +252 -0
- thetabook-2.0.0/src/thetabook/portfolio/import_csv_snapshot.py +397 -0
- thetabook-2.0.0/src/thetabook/portfolio/scaffold.py +120 -0
- thetabook-2.0.0/src/thetabook/pricing/__init__.py +0 -0
- thetabook-2.0.0/src/thetabook/pricing/bs.py +185 -0
- thetabook-2.0.0/src/thetabook/pricing/greeks.py +498 -0
- thetabook-2.0.0/src/thetabook/skills/__init__.py +54 -0
- thetabook-2.0.0/src/thetabook/skills/install.py +604 -0
- thetabook-2.0.0/src/thetabook/skills/lint.py +475 -0
- thetabook-2.0.0/src/thetabook/skills/models.py +170 -0
- thetabook-2.0.0/src/thetabook/skills/parse.py +73 -0
- thetabook-2.0.0/src/thetabook/skills/policy.py +80 -0
- thetabook-2.0.0/src/thetabook/skills/registry.py +343 -0
- thetabook-2.0.0/src/thetabook/skills/render.py +106 -0
- thetabook-2.0.0/src/thetabook/templates/README.md +39 -0
- thetabook-2.0.0/src/thetabook/templates/accounts.toml.example +98 -0
- thetabook-2.0.0/src/thetabook/templates/config.toml.example +18 -0
- thetabook-2.0.0/src/thetabook/templates/idea.md +40 -0
- thetabook-2.0.0/src/thetabook/templates/journal.md +53 -0
- thetabook-2.0.0/src/thetabook/templates/learnings.md +18 -0
- thetabook-2.0.0/src/thetabook/templates/skill.md +52 -0
- thetabook-2.0.0/src/thetabook/templates/skills/setup-thetabook.md +182 -0
- thetabook-2.0.0/src/thetabook/templates/wiki/index.md +16 -0
- thetabook-2.0.0/src/thetabook/templates/wiki/log.md +18 -0
- thetabook-2.0.0/src/thetabook/templates/wiki/overview.md +32 -0
- thetabook-2.0.0/src/thetabook/templates/wiki/strategy.md +41 -0
- thetabook-2.0.0/src/thetabook/templates/wiki/underlying.md +34 -0
- thetabook-2.0.0/src/thetabook/tickers.py +219 -0
- thetabook-2.0.0/src/thetabook/wiki/__init__.py +15 -0
- thetabook-2.0.0/src/thetabook/wiki/lint.py +813 -0
- thetabook-2.0.0/src/thetabook/wiki/render.py +423 -0
- thetabook-2.0.0/tests/cli/test_bs_cli.py +120 -0
- thetabook-2.0.0/tests/cli/test_init.py +444 -0
- thetabook-2.0.0/tests/cli/test_migrate_home.py +183 -0
- thetabook-2.0.0/tests/conftest.py +277 -0
- thetabook-2.0.0/tests/ideas/test_adjust.py +1739 -0
- thetabook-2.0.0/tests/ideas/test_core.py +288 -0
- thetabook-2.0.0/tests/ideas/test_evaluate_idea.py +1921 -0
- thetabook-2.0.0/tests/ideas/test_manage_ideas.py +759 -0
- thetabook-2.0.0/tests/ideas/test_roll_scenarios.py +729 -0
- thetabook-2.0.0/tests/market/test_chains.py +654 -0
- thetabook-2.0.0/tests/market/test_dividends.py +780 -0
- thetabook-2.0.0/tests/market/test_earnings.py +321 -0
- thetabook-2.0.0/tests/market/test_leg_marks.py +106 -0
- thetabook-2.0.0/tests/market/test_prices.py +658 -0
- thetabook-2.0.0/tests/market/test_schwab.py +106 -0
- thetabook-2.0.0/tests/market/test_vol_lookup.py +372 -0
- thetabook-2.0.0/tests/portfolio/test_accounts.py +981 -0
- thetabook-2.0.0/tests/portfolio/test_diff_snapshots.py +356 -0
- thetabook-2.0.0/tests/portfolio/test_get_positions.py +495 -0
- thetabook-2.0.0/tests/portfolio/test_import_csv_snapshot.py +375 -0
- thetabook-2.0.0/tests/portfolio/test_scaffold.py +92 -0
- thetabook-2.0.0/tests/pricing/test_bs.py +254 -0
- thetabook-2.0.0/tests/pricing/test_greeks.py +828 -0
- thetabook-2.0.0/tests/skills/__init__.py +0 -0
- thetabook-2.0.0/tests/skills/conftest.py +52 -0
- thetabook-2.0.0/tests/skills/test_install.py +598 -0
- thetabook-2.0.0/tests/skills/test_lint.py +220 -0
- thetabook-2.0.0/tests/skills/test_models.py +96 -0
- thetabook-2.0.0/tests/skills/test_parse.py +70 -0
- thetabook-2.0.0/tests/skills/test_policy.py +54 -0
- thetabook-2.0.0/tests/skills/test_registry.py +388 -0
- thetabook-2.0.0/tests/skills/test_render.py +55 -0
- thetabook-2.0.0/tests/test_cache.py +149 -0
- thetabook-2.0.0/tests/test_cli.py +800 -0
- thetabook-2.0.0/tests/test_config.py +77 -0
- thetabook-2.0.0/tests/test_factories.py +92 -0
- thetabook-2.0.0/tests/test_leg_parse.py +228 -0
- thetabook-2.0.0/tests/test_log.py +42 -0
- thetabook-2.0.0/tests/test_models.py +412 -0
- thetabook-2.0.0/tests/test_paths.py +502 -0
- thetabook-2.0.0/tests/test_tickers.py +262 -0
- thetabook-2.0.0/tests/wiki/test_lint.py +1069 -0
- thetabook-2.0.0/tests/wiki/test_render.py +442 -0
- thetabook-2.0.0/uv.lock +1441 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Scaffold personal/accounts.toml from the latest snapshot
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Scaffold `personal/accounts.toml` by reading the user's Schwab account numbers out of the latest snapshot and asking for per-account posture. Safe to re-run — new accounts are appended; existing entries are preserved unless the user asks to edit them.
|
|
6
|
+
|
|
7
|
+
## Sequence
|
|
8
|
+
|
|
9
|
+
1. **Enumerate accounts from the snapshot.** Run `~/.local/bin/uv run thetabook accounts totals` to see every Schwab account in the latest snapshot (last4 + Schwab `MARGIN`/`CASH` classification). If the command reports no snapshot, tell the user to run `/refresh` first and stop. The TOML key requires the **full** account number, not just the last4 — read those from `personal/snapshots/latest.json` (each entry's `accountNumber` field). Use `totals` for the user-facing list and the JSON for the literal keys.
|
|
10
|
+
|
|
11
|
+
2. **Load existing config.** Run `~/.local/bin/uv run thetabook accounts show`. Each row is an already-configured account; **don't** re-prompt those unless the user asks to edit them. Cross-reference against step 1 to identify which accounts need scaffolding. If `accounts.toml` is missing the command prints a hint and exits — treat that as "all accounts are new".
|
|
12
|
+
|
|
13
|
+
3. **Ask in one combined question.** For each account number that is new (not in the existing config), present a table and ask the user to fill in fields for all of them in a single reply. Don't prompt one account at a time.
|
|
14
|
+
|
|
15
|
+
Table format to show the user:
|
|
16
|
+
```
|
|
17
|
+
| Account # | Schwab type | Nickname? | Your type? | Goal? | Risk? | Rules? |
|
|
18
|
+
|---------------|-------------|-----------|---------------------|--------------------|---------------|-----------------------------------------|
|
|
19
|
+
| 98099589 | MARGIN | ? | taxable-margin | ? | ? | ? |
|
|
20
|
+
| 31426963 | CASH | ? | ira | capital-preservation | conservative | forbidden: naked-call, naked-put; dr=yes |
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Valid values:
|
|
24
|
+
- **type**: `taxable-margin`, `taxable-cash`, `ira`, `roth-ira`, `401k`, `other`. IMPORTANT: Schwab doesn't distinguish IRA from taxable — both come back as `MARGIN` or `CASH`. The user must label.
|
|
25
|
+
- **goal**: `capital-preservation`, `income`, `growth`, `speculation`
|
|
26
|
+
- **risk_profile**: `conservative`, `moderate`, `aggressive`
|
|
27
|
+
- **rules** (free-form — see `templates/accounts.toml.example`): `forbidden_strategies` (list of strategy names; special-cased: `naked-call`, `naked-put` also trigger structural leg detection), `require_defined_risk` (bool), `max_position_pct` (int percent of NLV for any single underlying), `max_options_notional_pct` (int percent of NLV for total options exposure), `min_cash_buffer_usd` (int dollars — minimum cash balance).
|
|
28
|
+
|
|
29
|
+
Sensible defaults to suggest if the user is unsure:
|
|
30
|
+
- IRA: `forbidden_strategies = ["naked-call", "naked-put", "short-strangle"]`, `require_defined_risk = true`, `max_position_pct = 15`
|
|
31
|
+
- Taxable margin: `max_position_pct = 25`, no forbidden strategies
|
|
32
|
+
- Taxable cash: `forbidden_strategies = ["naked-call"]`, `max_position_pct = 20`
|
|
33
|
+
|
|
34
|
+
4. **Write the file.** Create or append to `personal/accounts.toml` in TOML format matching `templates/accounts.toml.example`. Use the Edit/Write tools. Preserve any entries already in the file. Wrap account numbers in double quotes (TOML requires this for all-numeric keys): `[accounts."98099589"]`.
|
|
35
|
+
|
|
36
|
+
5. **Confirm.** Run `~/.local/bin/uv run thetabook accounts show` and display the output so the user can verify what was recorded. If anything looks wrong, offer to fix it immediately.
|
|
37
|
+
|
|
38
|
+
6. **(Optional) Run portfolio check.** Offer to run `~/.local/bin/uv run thetabook accounts check-portfolio` to see any immediate rule warnings against current holdings.
|
|
39
|
+
|
|
40
|
+
## Rules
|
|
41
|
+
|
|
42
|
+
- Never invent preferences. If the user doesn't give you a goal or risk profile, leave those fields empty — they are soft steering and tolerate blanks. Never guess `type` — ask explicitly, because Schwab can't tell us IRA vs. taxable.
|
|
43
|
+
- Never commit `accounts.toml`. It contains account numbers (PII) and is gitignored via `personal/`.
|
|
44
|
+
- If the user says "just do the defaults", use the sensible defaults in step 3 but still ask them to confirm the `type` for each account — that one field can't be defaulted.
|
|
45
|
+
- If re-running and the snapshot has a new account not in the file, treat this as the "add a new account" path — only prompt for the new one.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Model a what-if adjustment to an existing position (roll, add, close, assign)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Help the user model an adjustment to an existing position. Follow this sequence:
|
|
6
|
+
|
|
7
|
+
1. **Identify the position to adjust.** Ask the user which underlying and which leg(s) they want to change, if not already clear. Check `personal/snapshots/latest.json` to confirm the current position exists and read its strike, expiry, qty, and avg price.
|
|
8
|
+
|
|
9
|
+
2. **Clarify the adjustment type:**
|
|
10
|
+
- **Roll** — close one leg, open another at a different strike or expiry. Common for covering calls that have decayed or defending puts.
|
|
11
|
+
- **Add** — add a new leg to an existing position (e.g. buy a protective put against long stock).
|
|
12
|
+
- **Close** — lock in the current P&L and exit a leg.
|
|
13
|
+
- **Assign** — model what happens if a short put is assigned (results in long stock at effective cost = strike − premium received).
|
|
14
|
+
|
|
15
|
+
3. **Collect missing details.** Before running `thetabook adjust`, you need:
|
|
16
|
+
- For `--close`: expiration, strike, C/P of the leg to close. `thetabook adjust` re-marks the current value from the live option chain by default; the snapshot `market_price` is a fallback when the chain has no quote.
|
|
17
|
+
- For `--open`/`--add`: expiration, strike, C/P, qty. Premium is optional — omit it and `thetabook adjust` picks the current mark from the live chain (conservative: long→ask, short→bid), falling back to a Black-Scholes estimate if the strike isn't listed. Always prefer `premium=X.XX` when the user has a specific fill target.
|
|
18
|
+
- For `--assign`: expiration, strike of the short put.
|
|
19
|
+
|
|
20
|
+
4. **Run the analysis:**
|
|
21
|
+
```bash
|
|
22
|
+
# Roll (live chain marks on both legs; override with premium=X.XX if needed)
|
|
23
|
+
uv run thetabook adjust AAPL --close "2026-05-16 180 C" --open "2026-06-20 190 C"
|
|
24
|
+
|
|
25
|
+
# Roll with an explicit opening premium (user value wins over chain)
|
|
26
|
+
uv run thetabook adjust AAPL --close "2026-05-16 180 C" --open "2026-06-20 190 C premium=2.50"
|
|
27
|
+
|
|
28
|
+
# Add protective put
|
|
29
|
+
uv run thetabook adjust NVDA --add "2026-05-16 110 P qty=1 premium=3.50"
|
|
30
|
+
|
|
31
|
+
# Close a leg
|
|
32
|
+
uv run thetabook adjust SPY --close "2026-04-18 520 C"
|
|
33
|
+
|
|
34
|
+
# Assignment scenario
|
|
35
|
+
uv run thetabook adjust SPY --assign "2026-04-18 520 P"
|
|
36
|
+
|
|
37
|
+
# Override market data (user values always win)
|
|
38
|
+
uv run thetabook adjust AAPL --close "..." --open "..." --stock-price 185 --vol 0.28
|
|
39
|
+
|
|
40
|
+
# Reproduce the old snapshot-only behavior (useful if the chain is unreliable)
|
|
41
|
+
uv run thetabook adjust AAPL --close "..." --marks frozen
|
|
42
|
+
|
|
43
|
+
# Use mid (bid+ask)/2 instead of conservative when picking chain marks
|
|
44
|
+
uv run thetabook adjust AAPL --close "..." --mark-mode mid
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Output annotates the source of every mark so the user can tell what came
|
|
48
|
+
from the live market vs a model: `current $0.80 (chain)`, `premium $2.95
|
|
49
|
+
(chain)`, or `premium $3.10 (bs)`. An `Earnings` line above the table
|
|
50
|
+
flags any earnings date inside the trade window (⚠ in window),
|
|
51
|
+
notes an upcoming post-expiry date, or records `none found` / `lookup
|
|
52
|
+
failed` so silent negatives are visible.
|
|
53
|
+
|
|
54
|
+
5. **Interpret the output.** Walk the user through the before/after comparison:
|
|
55
|
+
- **Greeks change**: is the adjustment reducing or adding risk exposure?
|
|
56
|
+
- **Max loss**: does the adjustment improve or worsen the downside?
|
|
57
|
+
- **PoP change**: does the probability of profit shift meaningfully?
|
|
58
|
+
- **Net cost**: is this a debit or credit roll? Is the credit worth the tradeoff?
|
|
59
|
+
- **Breakeven shift**: how does the breakeven price change?
|
|
60
|
+
|
|
61
|
+
6. **Decide and optionally save.** If the user wants to track the adjustment as a trade idea, rerun with `--save`:
|
|
62
|
+
```bash
|
|
63
|
+
uv run thetabook adjust AAPL --close "..." --open "..." --save
|
|
64
|
+
```
|
|
65
|
+
This creates a new file in `personal/ideas/` with the after-scenario as the structure, pre-populated with max gain/loss. The user can then run `/evaluate` on it for a full P&L profile.
|
|
66
|
+
|
|
67
|
+
7. **Scenario grid (optional).** If timing is a factor (e.g. "should I roll now or wait?"), suggest running the scenario grid to see how the roll cost changes over time:
|
|
68
|
+
```bash
|
|
69
|
+
uv run thetabook roll <TICKER> --close <exp> <strikes> C --open <exp> <strikes> C
|
|
70
|
+
```
|
|
71
|
+
This complements `thetabook adjust` — adjust shows point-in-time Greeks, roll_scenarios shows the price × time landscape.
|
|
72
|
+
|
|
73
|
+
8. **Log in the journal.** Append the adjustment analysis to the current `personal/journal/YYYY-MM-DD.md` under the `## Discussion` section.
|
|
74
|
+
|
|
75
|
+
## Rules
|
|
76
|
+
|
|
77
|
+
- Never place or suggest placing trades. The analysis is informational only.
|
|
78
|
+
- If the snapshot is stale, `thetabook adjust` auto-fetches a live price for the underlying and re-marks legs from the live chain. Don't warn about staleness unless it falls back to snapshot values — the output will say `(snapshot)` next to a mark when that happens.
|
|
79
|
+
- Surface the earnings flag: if the `Earnings` line shows `⚠ ... in window`, call it out — IV is likely elevated and the comparison's PoP/expected-P&L are optimistic.
|
|
80
|
+
- Surface the ex-dividend flag: if the `Ex-dividend` line shows `⚠ ... in window`, call it out — short ITM calls face elevated early-assignment risk around ex-div. Especially relevant when a roll lengthens the window past an ex-div date.
|
|
81
|
+
- Surface the assignment-risk strong banner: if the `Assignment risk` line contains `⚠⚠ at risk`, this is the actually-actionable signal — extrinsic < dividend means exercise pre-ex-div is rationally optimal for the long holder. The candidate adjustment may have introduced this risk (e.g. a roll up that landed deeper ITM, an --add that stretched the window across ex-div). Call it out prominently and discuss whether the comparison's "after" is acceptable. Verify the dividend source (`announced` is high-confidence; `last_paid` / `history` are estimates — verify against Schwab / issuer IR).
|
|
82
|
+
- `adjust` auto-fetches the underlying's dividend yield from yfinance (cached 7d) so option re-marks reflect the right `q`. `--div-yield` still overrides; the header tags the source as `auto`, `override`, or `default`. For dividend-paying names, BS marks will differ noticeably from any pre-M18 cached idea-file values that assumed `q=0`.
|
|
83
|
+
- Frame the comparison as tradeoffs, not recommendations. The user decides.
|
|
84
|
+
- If the user mentions a specific target (e.g. "I want to reduce delta by 50"), help them work backwards to find the right adjustment parameters.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fetch option chain for a ticker (expirations, strikes, Greeks)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Fetch option chain data for the ticker and parameters in $ARGUMENTS.
|
|
6
|
+
|
|
7
|
+
## Parsing arguments
|
|
8
|
+
|
|
9
|
+
The user may provide arguments in several forms:
|
|
10
|
+
- `AAPL` — list available expirations
|
|
11
|
+
- `AAPL 2026-06-20` — full chain for that expiry
|
|
12
|
+
- `AAPL 2026-06-20 puts` or `AAPL puts 2026-06-20` — puts only
|
|
13
|
+
- `AAPL 2026-06-20 calls 180-220` — calls in a strike range
|
|
14
|
+
- `AAPL 45dte puts` — find the nearest expiration around 45 DTE, then fetch puts
|
|
15
|
+
- `AAPL next month` — find the monthly expiration ~30 days out
|
|
16
|
+
|
|
17
|
+
If no arguments are provided, ask the user which ticker they want.
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
### 1. List expirations (if no expiration given, or user asked for "expirations")
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
~/.local/bin/uv run thetabook chain <TICKER>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Show the expirations table. If the user said something like "45 DTE" or "next month", pick the closest match from the list and proceed to step 2.
|
|
28
|
+
|
|
29
|
+
### 2. Fetch the chain
|
|
30
|
+
|
|
31
|
+
Build the command from parsed arguments:
|
|
32
|
+
```bash
|
|
33
|
+
~/.local/bin/uv run thetabook chain <TICKER> <EXPIRATION> [--type call|put] [--strikes MIN-MAX] [--greeks]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Always include `--greeks` when the data source provides them (Schwab or Massive).
|
|
37
|
+
|
|
38
|
+
### 3. Present results
|
|
39
|
+
|
|
40
|
+
Show the table output from the CLI. Then add context if helpful:
|
|
41
|
+
- If the user has active positions in this underlying, note where current positions sit relative to the chain (e.g. "your short $250 put is 3 strikes OTM")
|
|
42
|
+
- If evaluating an idea, highlight contracts near the idea's strikes
|
|
43
|
+
- Note the bid-ask spread width for illiquid contracts
|
|
44
|
+
- Mention implied volatility skew if visible (e.g. puts trading at higher IV than calls)
|
|
45
|
+
|
|
46
|
+
### 4. Suggest next steps if appropriate
|
|
47
|
+
|
|
48
|
+
- "Want to evaluate a trade idea with one of these strikes? I can run /idea or /evaluate."
|
|
49
|
+
- "I can model a roll to one of these expirations with /adjust."
|
|
50
|
+
|
|
51
|
+
## Rules
|
|
52
|
+
|
|
53
|
+
- Keep output concise. Don't explain every column unless the user asks.
|
|
54
|
+
- If the chain is very large (>50 contracts), suggest filtering by contract type or strike range.
|
|
55
|
+
- If a source fails (e.g. Massive rate limit), the CLI automatically falls through to the next source. Mention which source was used if it's visible in stderr.
|
|
56
|
+
- Do not start a portfolio review or evaluation session — this is a quick lookup.
|
|
57
|
+
- Source cascade: Schwab → Massive → yfinance. The user may not have all sources configured.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Close a trade idea and capture the outcome
|
|
3
|
+
argument-hint: <idea-id>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The user has exited a trade and wants to close out the idea with an outcome writeup. **Closing is where learning happens — don't rush this.**
|
|
7
|
+
|
|
8
|
+
Idea ID: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
## Sequence
|
|
11
|
+
|
|
12
|
+
1. **Validate the ID.** If `$ARGUMENTS` is empty or not a number, ask which idea. Run `~/.local/bin/uv run thetabook ideas list --status opened` to show currently-open candidates.
|
|
13
|
+
|
|
14
|
+
2. **Load the full idea.** Run `~/.local/bin/uv run thetabook ideas show $ARGUMENTS` and read all sections — Thesis, Structure, Entry plan, Exit plan, Risks, and any Fill notes. You'll need this context to write a useful Outcome.
|
|
15
|
+
|
|
16
|
+
3. **Gather exit details.** Ask in **one combined question**:
|
|
17
|
+
- Exit price / debit paid (or credit received if rolling)
|
|
18
|
+
- Exit date (default: today)
|
|
19
|
+
- Final P&L (dollars, and as % of max_loss or capital at risk if known)
|
|
20
|
+
- Why exited now: hit profit target, hit stop, time-based, assignment, rolled, changed thesis, or other?
|
|
21
|
+
- Did the original thesis play out? (yes / no / partially / mixed)
|
|
22
|
+
|
|
23
|
+
4. **Draft the Outcome section.** Two-step write — the structured fields go through the CLI; the narrative bullets stay in your hands.
|
|
24
|
+
- Run `~/.local/bin/uv run thetabook ideas record-outcome $ARGUMENTS --price <exit-price> --pnl <signed-dollars> --reason "<reason>" --thesis-verdict "<verdict>" [--date YYYY-MM-DD]`. The CLI writes the structured `## Outcome` skeleton (Exited / Reason / Thesis verdict), sets `realized_pnl` + `closed_at` in frontmatter, and leaves HTML-comment placeholders for the narrative bullets.
|
|
25
|
+
- Use Edit to fill in `**What worked:**`, `**What didn't:**`, and `**Lesson:**`. Be specific. "Exited because it went down" is not a lesson. "Sold the put spread too early because I anchored on the credit, ignored that the underlying had broken support" is.
|
|
26
|
+
|
|
27
|
+
5. **Update status.** Run `~/.local/bin/uv run thetabook ideas set-status $ARGUMENTS closed`. (`record-outcome` already set `closed_at`; `set-status` is the explicit transition.)
|
|
28
|
+
|
|
29
|
+
6. **Lift the lesson.** Look at the Lesson line in the Outcome. Decide:
|
|
30
|
+
- **Durable market lesson** that should influence future decisions → ask the user to confirm, then prepend a new entry to `personal/learnings.md` (newest at top, with format: `## YYYY-MM-DD — short title` + 2-3 sentences + `Source: [personal/ideas/NNN-...md]`).
|
|
31
|
+
- **One-off / situational** → leave it in the idea file only.
|
|
32
|
+
- **About the user's preferences or process** (not market mechanics) → save to Claude's memory system instead.
|
|
33
|
+
|
|
34
|
+
When in doubt, ask the user which bucket it falls into.
|
|
35
|
+
|
|
36
|
+
7. **Update the journal.** If a journal entry exists for today, append a line under `Actions taken` and (if a lesson was lifted) under `Learnings`.
|
|
37
|
+
|
|
38
|
+
8. **Update the wiki.** This is the most important wiki operation — closed trades are where compounding happens.
|
|
39
|
+
- **Underlying page** (`personal/wiki/underlyings/<TICKER>.md`): update the position history table with close date and P&L, complete the trade arc section with outcome narrative, add any ticker-specific lessons.
|
|
40
|
+
- **Strategy page** (`personal/wiki/strategies/<strategy>.md`): update the track record table, recalculate stats (win rate, avg P&L, avg DTE), and add any observations about what worked or didn't for this strategy.
|
|
41
|
+
- **Overview** (`personal/wiki/overview.md`): update active underlyings table if position is fully closed, add any portfolio-level patterns to the Patterns & biases section.
|
|
42
|
+
- **Log** (`personal/wiki/log.md`): run `~/.local/bin/uv run thetabook wiki log "close | <TICKER> <strategy> — <result summary>"`.
|
|
43
|
+
- **Index** (`personal/wiki/index.md`): update if any new pages were created.
|
|
44
|
+
- **Ideas roll-up** (`personal/wiki/ideas.md`): run `~/.local/bin/uv run thetabook wiki render-ideas` to refresh the auto-rendered table — closed ideas migrate from the Opened to the Closed section. The command preserves the hand-written Themes section.
|
|
45
|
+
|
|
46
|
+
## Rules
|
|
47
|
+
|
|
48
|
+
- Never close an idea that isn't in `opened` status. If the user wants to mark a `proposed` or `watching` idea as `rejected`, that's a different command — tell them to use `~/.local/bin/uv run thetabook ideas set-status <id> rejected`.
|
|
49
|
+
- Never fabricate P&L numbers. Always ask.
|
|
50
|
+
- The Outcome section is mandatory — even if the user wants to "just close it quickly," push back gently. The whole point of ideas-as-files is that closed ideas become training data for future decisions.
|
|
51
|
+
- If the user closed the trade days ago and is only now logging it, ask for the actual exit date and use that, not today.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Compare two portfolio snapshots and show what changed
|
|
3
|
+
argument-hint: [date1] [date2]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Compare two portfolio snapshots to show positions added, removed, changed, and account balance moves.
|
|
7
|
+
|
|
8
|
+
## Parsing arguments
|
|
9
|
+
|
|
10
|
+
`$ARGUMENTS` may be:
|
|
11
|
+
- Empty → compare latest vs. previous snapshot
|
|
12
|
+
- One date (`2026-04-10`) → compare that date vs. latest
|
|
13
|
+
- Two dates (`2026-04-10 2026-04-13`) → compare old to new
|
|
14
|
+
- `last week`, `previous` → find the appropriate snapshot dates
|
|
15
|
+
|
|
16
|
+
If no arguments are provided, default to latest vs. previous.
|
|
17
|
+
|
|
18
|
+
## Steps
|
|
19
|
+
|
|
20
|
+
1. **Run the diff.** Use the Bash tool:
|
|
21
|
+
```bash
|
|
22
|
+
~/.local/bin/uv run thetabook diff [date1] [date2]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. **Summarize the highlights.** After showing the full diff output, call out:
|
|
26
|
+
- **Big movers** — positions with the largest absolute or percentage value changes
|
|
27
|
+
- **New/removed positions** — trades opened or closed since the last snapshot
|
|
28
|
+
- **Options approaching expiration** — any options that expired or will expire soon
|
|
29
|
+
- **Cash changes** — dividends received, premiums collected, assignments
|
|
30
|
+
- **Account value change** — overall P&L as $ and %
|
|
31
|
+
|
|
32
|
+
3. **Connect to context.** If you have wiki or journal context loaded:
|
|
33
|
+
- Mention if any removed positions correspond to `/close` events
|
|
34
|
+
- Note if new positions match ideas that were `/open`'d
|
|
35
|
+
- Flag positions that moved significantly against the thesis
|
|
36
|
+
|
|
37
|
+
4. **Suggest follow-ups** if appropriate:
|
|
38
|
+
- "Run `/portfolio` for a full review?"
|
|
39
|
+
- "AAPL moved +8% — want to re-evaluate your covered call with `/adjust`?"
|
|
40
|
+
- "3 options expire in the next 7 days — want to check `/chain` for roll candidates?"
|
|
41
|
+
|
|
42
|
+
## Rules
|
|
43
|
+
|
|
44
|
+
- This is a quick comparison — keep the summary concise.
|
|
45
|
+
- Don't editorialize on whether price moves are good or bad. Report the facts.
|
|
46
|
+
- If there are no differences, say so clearly.
|
|
47
|
+
- If a snapshot date doesn't exist, list available dates and ask the user to pick.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Evaluate a trade idea (P&L, probability of profit, Greeks)
|
|
3
|
+
argument-hint: <idea-id> [--stock-price X] [--vol X]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The user wants to evaluate a trade idea quantitatively. Run the evaluation and present results.
|
|
7
|
+
|
|
8
|
+
## Sequence
|
|
9
|
+
|
|
10
|
+
1. **Identify the idea.** If the user provided an idea ID (e.g., `/evaluate 3`), use that. If not, run `~/.local/bin/uv run thetabook ideas list` to show available ideas and ask which one to evaluate.
|
|
11
|
+
|
|
12
|
+
2. **Check the idea has legs.** Read the idea file and verify the `## Structure` section contains parseable option legs in the format `TICKER YYYY-MM-DD STRIKE C/P qty=±N premium=X.XX`. If premiums are missing, ask the user for them (or offer to look them up from a snapshot if available).
|
|
13
|
+
|
|
14
|
+
3. **Run the evaluation.** Execute via Bash:
|
|
15
|
+
```
|
|
16
|
+
~/.local/bin/uv run thetabook evaluate <id> [--stock-price X] [--vol X] [--rate X] [--div-yield X]
|
|
17
|
+
[--marks live|frozen] [--mark-mode conservative|mid]
|
|
18
|
+
[--days 0,7,14,DTE]
|
|
19
|
+
```
|
|
20
|
+
Pass any overrides the user specified. If no stock price is available (no snapshot, no override), ask the user for one.
|
|
21
|
+
|
|
22
|
+
Add `--days 0,7,14,DTE` (or any comma-separated mix of integers and the literal `DTE`) when the user asks "what does this look like in N days?" or when early-exit / management timing is the question. The evaluation appends a mid-curve P&L table after the expiry analysis. Skip the flag if the user only cares about expiry P&L — the extra table adds noise otherwise.
|
|
23
|
+
|
|
24
|
+
By default the evaluation re-marks every leg against the live chain (`--marks live`) so breakevens, max profit/loss, PoP, and the MTM-since-entry row reflect today's market. Closed ideas auto-default to `--marks frozen` (no point re-marking realized trades). Pass `--marks frozen` explicitly when the user wants to reproduce an older evaluation verbatim. Pass `--mark-mode mid` only if the user asks for it — the default `conservative` (long→ask, short→bid) matches what they'd actually transact at.
|
|
25
|
+
|
|
26
|
+
4. **Present results.** Show the evaluation output to the user. Highlight the key decision metrics:
|
|
27
|
+
- Probability of profit — is this trade more likely to win than lose?
|
|
28
|
+
- Max loss — can the user afford this?
|
|
29
|
+
- Risk/reward ratio — max loss vs. max profit
|
|
30
|
+
- Net Greeks — what directional exposure does this create?
|
|
31
|
+
- **Data quality**: scan the per-leg IV `src` column. If every leg shows `flat`, chain data is missing for this underlying/expiration — warn the user the 25% assumption is a guess, and offer to run `/chain` to check coverage. If the stderr note mentions "previous close" (Massive price), flag that the stock price is stale by up to one trading day.
|
|
32
|
+
- **Earnings in window**: if the evaluation's table shows an `Earnings in window` row (also echoed to stderr as `⚠ Earnings YYYY-MM-DD inside trade window`), flag it prominently to the user. Reported IV is elevated into an earnings print, so PoP and expected P&L are optimistic; the realized vol after the announcement almost always collapses back below pre-print levels. Ask whether they're intentionally trading the IV crush or if they'd rather pick an expiry that sits clear of the event. The check is best-effort via yfinance — absence of the row doesn't prove there's no catalyst, only that one wasn't auto-detected.
|
|
33
|
+
- **Ex-dividend in window**: if the `Ex-dividend` row says `... in window` (also echoed to stderr as `⚠ Ex-div YYYY-MM-DD inside trade window`), flag it for short ITM calls — early assignment is concentrated around ex-div, especially when the call's extrinsic value is less than the upcoming dividend. Less material for puts and OTM positions. The check shares earnings' best-effort posture; absence is not proof.
|
|
34
|
+
- **Assignment risk (⚠⚠)**: if the `Assignment risk` row contains `⚠⚠ at risk` (also echoed to stderr as `⚠⚠ Assignment risk: ... extrinsic $X.XX < $Y.YY dividend`), this is the **strong** signal — the math says exercise pre-ex-div is rationally optimal for the long holder, so the user is genuinely at risk of being assigned. Surface it prominently and ask whether they want to roll the call up/out before ex-div, close the position, or accept assignment. Note the dividend source: `announced` is high-confidence, `last_paid` / `history` are estimates that should be verified against Schwab or issuer IR (board could have raised or cut). Soft `Ex-div in window` rows without a `⚠⚠` mean the math says assignment is unlikely — call out the ex-div date is approaching but don't escalate.
|
|
35
|
+
- **Div yield source**: the `Div yield` row tags its source as `auto` (yfinance), `override` (explicit `--div-yield`), or `default` (no data + `q=0`). For dividend-paying names, an `auto` value materially shifts call/put prices vs. the old `q=0` default — call this out if the user is comparing against a prior frozen evaluation that pre-dates M18.
|
|
36
|
+
|
|
37
|
+
5. **Discuss.** After presenting, ask the user if they want to:
|
|
38
|
+
- Adjust the trade (different strikes, wider/narrower spread, different expiry)
|
|
39
|
+
- Compare with an alternative structure
|
|
40
|
+
- Proceed to `/open` if they're ready to execute in Schwab
|
|
41
|
+
- Reject the idea if the numbers don't work
|
|
42
|
+
|
|
43
|
+
## Rules
|
|
44
|
+
|
|
45
|
+
- The evaluation is written to the idea file by default. If the user is just exploring, add `--no-write`.
|
|
46
|
+
- `thetabook evaluate` now pulls per-leg IV from `thetabook chain` automatically; the output prints the IV source per leg (`chain`, `override`, `flat`). Only flag vol if sources show `flat` for legs that should have chain data — that signals missing chain coverage, not bad analysis.
|
|
47
|
+
- Never present the evaluation as a recommendation. Frame it as: "Here's what the numbers say — you decide."
|
|
48
|
+
- If the idea has already been evaluated (an `## Evaluation` section exists), the new evaluation replaces it. Mention this so the user knows.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show portfolio Greeks (delta, gamma, theta, vega) with optional price/vol overrides
|
|
3
|
+
argument-hint: [TICKER=PRICE ...] [--vol X] [--no-fetch]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Compute portfolio-level Greeks from the latest snapshot. Surfaces per-underlying delta/gamma/theta/vega, totals, concentration warnings, and SPY-equivalent delta — the same output embedded in `/portfolio`, but available on demand mid-session.
|
|
7
|
+
|
|
8
|
+
Arguments: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
|
|
12
|
+
1. **Parse arguments.** Pass them straight through to `thetabook greeks`. Recognized tokens:
|
|
13
|
+
- `TICKER=PRICE` — manual stock-price override (passed as `--prices TICKER=PRICE`); may appear multiple times
|
|
14
|
+
- `--vol X` — flat volatility override (else chain IV per leg)
|
|
15
|
+
- `--no-fetch` — skip automatic price fetching
|
|
16
|
+
- `--rate X` / `--div-yield X` — override rate / dividend yield
|
|
17
|
+
- A bare `YYYY-MM-DD` — use that snapshot instead of `latest.json`
|
|
18
|
+
Group consecutive `TICKER=PRICE` tokens under one `--prices` flag.
|
|
19
|
+
|
|
20
|
+
2. **Run.**
|
|
21
|
+
```
|
|
22
|
+
~/.local/bin/uv run thetabook greeks [<date>] [--prices T1=P1 T2=P2 ...] [--vol X] [--no-fetch]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. **Report.** Present the markdown table as-is. Briefly call out:
|
|
26
|
+
- Net delta direction (long / short / flat) and SPY-equivalent
|
|
27
|
+
- Any concentration warnings
|
|
28
|
+
- Any non-Schwab price warnings (Massive / yfinance) — Greeks on previous-close or delayed quotes can mislead
|
|
29
|
+
- Vol sources (chain / override / flat) if the mix looks unusual
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
|
|
33
|
+
- This is a quick read — do not start a `/portfolio` session or update the journal.
|
|
34
|
+
- Don't fabricate prices. If `thetabook greeks` can't resolve one, surface the warning rather than guessing.
|
|
35
|
+
- When the snapshot is stale, `thetabook greeks` auto-refreshes underlying prices via the Schwab → Massive → yfinance cascade; the table will show the source notice line.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Capture a trade idea as a file in personal/ideas/
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The user is describing a trade idea they want to record. Your job is to turn the conversation into a complete `personal/ideas/NNN-short-name.md` file.
|
|
6
|
+
|
|
7
|
+
## Sequence
|
|
8
|
+
|
|
9
|
+
1. **Gather missing info.** From the conversation, extract: name, underlying, strategy, thesis, structure (legs), entry plan, exit plan, risks, **catalysts in the trade window**. If any of {name, underlying, strategy, thesis, structure, exit plan, catalysts} are missing or vague, ask for them in **one combined question** before creating the file. Don't pepper the user with one question at a time.
|
|
10
|
+
|
|
11
|
+
The catalysts question is: *"Any earnings, ex-div, Fed/CPI/FOMC, or single-name catalysts (FDA, guidance, trials) between now and expiry?"* Fold it into the combined question when you have to ask; skip asking if the user already named catalysts or explicitly said "no catalysts." Record named catalysts as bulleted items with ISO dates in the `## Risks` section — earnings specifically should look like `- Earnings 2026-05-02 — IV likely elevated into the print`.
|
|
12
|
+
|
|
13
|
+
2. **Create the file.** Run via the Bash tool:
|
|
14
|
+
```
|
|
15
|
+
~/.local/bin/uv run thetabook ideas new "<short name>" --underlying <TICKER> --strategy <strategy>
|
|
16
|
+
```
|
|
17
|
+
This generates `personal/ideas/NNN-<slug>.md` with the next available number, prefilled frontmatter, and the section skeleton.
|
|
18
|
+
|
|
19
|
+
3. **Fill in the body.** Use the Edit tool to populate the `Thesis`, `Structure`, `Entry plan`, `Exit plan`, and `Risks` sections from the conversation. Also fill in `account`, `max_loss`, and `max_gain` in the frontmatter if known. Frontmatter dollar fields are plain numerics — `max_loss: -300.0`, not `max_loss: -$300.00`. Use the contract notation `TICKER YYYY-MM-DD STRIKE C/P` in the Structure section.
|
|
20
|
+
|
|
21
|
+
**Pull entry marks from the chain.** For each leg, run:
|
|
22
|
+
```
|
|
23
|
+
~/.local/bin/uv run thetabook leg-mark <TICKER> <YYYY-MM-DD> <STRIKE> <C|P> --qty <signed-qty> --json
|
|
24
|
+
```
|
|
25
|
+
Use the `picked` value as `premium=` and also add `entry_mark=<picked>@<today>` so future evaluations can show drift against the capture mark. A full leg line looks like:
|
|
26
|
+
```
|
|
27
|
+
AAPL 2026-05-16 180 C qty=+1 premium=2.50 entry_mark=2.50@2026-04-20
|
|
28
|
+
```
|
|
29
|
+
If `thetabook leg-mark` can't find the strike (non-zero exit, stderr says "No chain data"), ask the user for the premium they saw in Schwab rather than fabricating one.
|
|
30
|
+
|
|
31
|
+
4. **Account check.** Run `~/.local/bin/uv run thetabook accounts check-idea <id>` to surface per-account rule warnings and tax notes. If it prints warnings, show them to the user and ask whether to proceed, adjust the structure, or reject the idea. If it prints tax notes (ℹ prefix), include them in the idea's `## Risks` section verbatim so the context persists. If `accounts.toml` is not configured the command prints a hint and exits quietly — don't block on that.
|
|
32
|
+
|
|
33
|
+
5. **Confirm.** Print the resulting file path and a one-line summary back to the user. If a portfolio review session is in progress (a `personal/journal/YYYY-MM-DD.md` file was edited recently in this conversation), append a link to the new idea under that journal's `Ideas generated` section.
|
|
34
|
+
|
|
35
|
+
6. **Update the wiki.**
|
|
36
|
+
- **Underlying page** (`personal/wiki/underlyings/<TICKER>.md`): if it doesn't exist, create it from `templates/wiki/underlying.md`. Add the idea to the page as a pending trade arc. If the page already exists, add a note about the new idea.
|
|
37
|
+
- **Strategy page** (`personal/wiki/strategies/<strategy>.md`): if it doesn't exist, create it from `templates/wiki/strategy.md`.
|
|
38
|
+
- **Overview** (`personal/wiki/overview.md`): add/update the underlying in the active underlyings table if not already listed.
|
|
39
|
+
- **Log** (`personal/wiki/log.md`): run `~/.local/bin/uv run thetabook wiki log "idea | <TICKER> <strategy> (idea NNN)"`.
|
|
40
|
+
- **Index** (`personal/wiki/index.md`): update if any new pages were created.
|
|
41
|
+
- **Ideas roll-up** (`personal/wiki/ideas.md`): run `~/.local/bin/uv run thetabook wiki render-ideas` to refresh the auto-rendered table. The command preserves the hand-written Themes section.
|
|
42
|
+
|
|
43
|
+
## Rules
|
|
44
|
+
|
|
45
|
+
- **Status starts at `proposed`.** Don't set it to `opened` unless the user explicitly says they've placed the trade — and even then, remind them this repo doesn't execute trades, they need to do it manually in Schwab.
|
|
46
|
+
- **Don't fabricate numbers.** If the user hasn't given you strikes, expiries, or sizing, ask. Never invent them.
|
|
47
|
+
- **Reasoning over conclusions.** The Thesis should explain *why now* and what the edge is, not just restate the strategy.
|
|
48
|
+
- **Risks section is mandatory.** Every idea must have at least one named risk. If the user doesn't volunteer any, ask "what's the biggest thing that could go wrong here?"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: List trade ideas, filter by status, or show a single idea
|
|
3
|
+
argument-hint: [<id> | <status>]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
List or show trade ideas. The argument decides which:
|
|
7
|
+
|
|
8
|
+
- **No argument** → list all ideas
|
|
9
|
+
- **A status word** (`proposed`, `watching`, `opened`, `closed`, `rejected`) → list ideas with that status
|
|
10
|
+
- **A number** → show the full body of that idea
|
|
11
|
+
|
|
12
|
+
Argument: `$ARGUMENTS`
|
|
13
|
+
|
|
14
|
+
## Sequence
|
|
15
|
+
|
|
16
|
+
1. **Decide the mode** based on `$ARGUMENTS`:
|
|
17
|
+
- Empty → run `~/.local/bin/uv run thetabook ideas list`
|
|
18
|
+
- One of `proposed | watching | opened | closed | rejected` → run `~/.local/bin/uv run thetabook ideas list --status $ARGUMENTS`
|
|
19
|
+
- All-digit string → run `~/.local/bin/uv run thetabook ideas show $ARGUMENTS`
|
|
20
|
+
- Anything else → tell the user what's valid and stop
|
|
21
|
+
|
|
22
|
+
2. **Print the raw output** from the CLI directly to the user. `show` prepends its own staleness banner (ℹ/⚠) above the file dump — just pass it through verbatim; don't re-summarize or rephrase it. After the file, give a one-line context summary: status, days since created, days since opened (if applicable), and whether it overlaps with anything in the latest snapshot. If the staleness banner says `⚠ Stale`, suggest `/evaluate <id>` before any P&L discussion — the numbers in the file are outdated. Don't analyze or critique the idea unless the user asks.
|
|
23
|
+
|
|
24
|
+
3. **For `list` mode**, after the table, print a one-line summary: counts by status (e.g. `2 proposed, 1 watching, 3 opened, 5 closed, 1 rejected`).
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
|
|
28
|
+
- This is a read-only command. Never modify ideas, frontmatter, or status from here. Use `/open`, `/close`, or `thetabook ideas set-status` for changes.
|
|
29
|
+
- If the user wants to do something with an idea after looking at it (open, close, edit thesis), point them at the appropriate command rather than doing it inline.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Mark a trade idea as opened (after manually placing the trade in Schwab)
|
|
3
|
+
argument-hint: <idea-id>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The user has placed a trade for an existing idea and wants to mark it as opened.
|
|
7
|
+
|
|
8
|
+
Idea ID: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
## Sequence
|
|
11
|
+
|
|
12
|
+
1. **Validate the ID.** If `$ARGUMENTS` is empty or not a number, ask the user which idea they mean. You can run `~/.local/bin/uv run thetabook ideas list --status proposed` and `--status watching` to show candidates.
|
|
13
|
+
|
|
14
|
+
2. **Show the idea first.** Run `~/.local/bin/uv run thetabook ideas show $ARGUMENTS` and display its key details (name, underlying, strategy, structure, max_loss). This is a sanity check — confirm with the user that this is the right idea **and** that the actual fill matches the planned structure. If the fill differs from the plan (different strikes, different sizing, partial fill), ask whether to update the Structure section before proceeding.
|
|
15
|
+
|
|
16
|
+
3. **Check for fill details.** Ask (in one combined question if anything is missing):
|
|
17
|
+
- Actual fill price / credit received
|
|
18
|
+
- Actual quantity filled
|
|
19
|
+
- Fill date (default: today)
|
|
20
|
+
- Anything notable about the entry (slippage, IV at entry, etc.)
|
|
21
|
+
|
|
22
|
+
4. **Update status.** Run `~/.local/bin/uv run thetabook ideas set-status $ARGUMENTS opened`. This auto-fills `opened_at` with today's date. If the user gave a different fill date, pass `--date YYYY-MM-DD` to `record-fill` in the next step — it overrides `opened_at`. No need to re-edit the file by hand.
|
|
23
|
+
|
|
24
|
+
5. **Record fill details in the body.** Run `~/.local/bin/uv run thetabook ideas record-fill $ARGUMENTS --price <fill> --qty <signed-qty> [--date YYYY-MM-DD] [--notes "<note>"]`. The CLI writes the structured `## Fill` section idempotently and aligns `opened_at` with `--date` when given (otherwise leaves the existing `opened_at` from step 4 alone). Don't overwrite the original Entry plan — that's the plan; the Fill is what actually happened.
|
|
25
|
+
|
|
26
|
+
6. **Remind about journaling.** If a journal entry exists for today (`personal/journal/YYYY-MM-DD.md`), append a line under `Actions taken` noting that idea NNN was opened. If no journal entry exists for today, ask whether to create one (use `templates/journal.md` as the structure).
|
|
27
|
+
|
|
28
|
+
7. **Update the wiki.**
|
|
29
|
+
- **Underlying page** (`personal/wiki/underlyings/<TICKER>.md`): add a row to the position history table, update or create the trade arc section for this trade (thesis, entry details, exit plan). If the page doesn't exist, create it from `templates/wiki/underlying.md`.
|
|
30
|
+
- **Strategy page** (`personal/wiki/strategies/<strategy>.md`): add a row to the track record table. If the page doesn't exist, create it from `templates/wiki/strategy.md`.
|
|
31
|
+
- **Overview** (`personal/wiki/overview.md`): add/update the underlying in the active underlyings table.
|
|
32
|
+
- **Log** (`personal/wiki/log.md`): run `~/.local/bin/uv run thetabook wiki log "open | <TICKER> <strategy> (idea NNN)"`.
|
|
33
|
+
- **Index** (`personal/wiki/index.md`): update if any new pages were created.
|
|
34
|
+
- **Ideas roll-up** (`personal/wiki/ideas.md`): run `~/.local/bin/uv run thetabook wiki render-ideas` to refresh the auto-rendered table. The command preserves the hand-written Themes section.
|
|
35
|
+
|
|
36
|
+
## Rules
|
|
37
|
+
|
|
38
|
+
- **This repo does not place trades.** Only mark as opened *after* the user has manually executed in Schwab. If the user says "open this idea" without confirming they've placed the trade, ask them to place it first.
|
|
39
|
+
- Never fabricate fill prices or quantities. Always ask.
|
|
40
|
+
- If the idea's status is already `opened`, `closed`, or `rejected`, stop and tell the user — don't silently re-open.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Start a Schwab portfolio review session
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Run a portfolio review session. Follow this sequence:
|
|
6
|
+
|
|
7
|
+
1. **Check freshness.** Run `~/.local/bin/uv run thetabook snapshot` — it prints the latest snapshot's path, `fetched_at` timestamp, age, freshness flag, and an account/position count. If the output reports `stale` or there's no snapshot, ask whether to refresh by running `uv run thetabook refresh`. Do not run it without asking.
|
|
8
|
+
|
|
9
|
+
2. **Load context.** Read these files before discussing anything:
|
|
10
|
+
- `personal/snapshots/latest.json` — current positions (use the path from step 1's output)
|
|
11
|
+
- `personal/learnings.md` — durable lessons that should influence today's decisions
|
|
12
|
+
- The most recent file under `personal/journal/` (if any) — what we discussed last time. Pick the highest-dated `YYYY-MM-DD.md` filename.
|
|
13
|
+
- Active ideas: run `~/.local/bin/uv run thetabook ideas list` to see all ideas, then read the full body of any with status `proposed`, `watching`, or `opened` via `thetabook ideas show <id>`
|
|
14
|
+
|
|
15
|
+
3. **Summarize the portfolio.** Produce a concise overview:
|
|
16
|
+
- Account totals and cash — run `~/.local/bin/uv run thetabook accounts totals` instead of parsing the snapshot JSON by hand. The output is a `nickname | type | last4 | liquidation | cash | % NLV` table sorted by NLV.
|
|
17
|
+
- Equity positions (symbol, qty, market value, % of account)
|
|
18
|
+
- Options positions grouped by underlying, with strike/expiry/type/qty
|
|
19
|
+
- **Flags**: options expiring in ≤14 days, concentrated positions (>20% of account), anything unusual
|
|
20
|
+
|
|
21
|
+
3b. **Greeks summary.** Run `uv run thetabook greeks` to compute portfolio-level Greeks. Include the output in the review — it shows per-underlying and total delta, gamma, theta (daily $), and vega ($ per 1% vol), plus concentration warnings. Add the output to the journal under a `## Greeks summary` section.
|
|
22
|
+
|
|
23
|
+
3b-bis. **Account posture & risk-rule check.** Run `~/.local/bin/uv run thetabook accounts check-portfolio --show-all --top 10`. This prints each account's posture (nickname / type / goal / risk_profile), the per-account underlying ranking (top 10 by % of NLV with ⚠ on rows over `max_position_pct`), and any rule violations — oversized positions, options notional over cap, cash below buffer, cross-account wash-sale cautions, Section-1256 notes. Drop `--top 10` if you want every name; drop `--show-all` if you want only the violations. Add the full output to the journal under `## Account posture & rule checks`. When describing positions in later steps, frame analysis consistent with each account's declared goal and risk_profile. If `accounts.toml` is missing the command emits a hint — surface it and suggest running `/accounts-init`, then continue.
|
|
24
|
+
|
|
25
|
+
3c. **Earnings overlay.** Run `uv run thetabook earnings <TICKER1> <TICKER2> ...` for every underlying with a non-zero options position (not equities, not cash — only tickers that have a dated option exposure). The output is cached for 7 days so re-running mid-session is free and re-running next week is usually still a cache hit. Add `--no-cache` only when you know a date just moved. Flag every earnings date with DTE ≤ 21 (or any date inside the window of an open option position — whichever is tighter). Present the hits under `## Earnings watch` in the journal:
|
|
26
|
+
- `⚠ TICKER YYYY-MM-DD (N DTE) — <affected positions>` for hits inside any open option's DTE
|
|
27
|
+
- `TICKER YYYY-MM-DD (N DTE)` for near-term reports outside current trade windows (context only)
|
|
28
|
+
If every ticker comes back "unknown", note the empty result and move on — don't fabricate dates.
|
|
29
|
+
|
|
30
|
+
3d. **Dividends overlay.** Run `~/.local/bin/uv run thetabook dividends <TICKER1> <TICKER2> ...` for every underlying with a non-zero options position (same ticker set as 3c). Output is cached for 7 days. ETFs and some equities surface ex-div dates as `~YYYY-MM-DD (estimated)` — projected from the recent dividends history when the calendar lacks a future date; treat these as the next likely ex-div, but verify against issuer IR before acting. Flag every ex-div date inside the window of an open option position. For each in-window hit, compute per-leg early-assignment risk: `extrinsic = mark - max(0, S - K)`; when `extrinsic < dividend amount` AND a short call is ITM, surface as ⚠⚠ Assignment risk — exercise pre-ex-div is rationally optimal for the long holder. Present under `## Dividends watch` in the journal, mirroring the Earnings watch structure:
|
|
31
|
+
- `⚠⚠ TICKER YYYY-MM-DD (N DTE) — Assignment risk on <leg>: extrinsic $X.XX < dividend $Y.YY` for in-window hits where the heuristic fires
|
|
32
|
+
- `⚠ TICKER YYYY-MM-DD (N DTE) — ex-div inside <leg>'s window` for in-window hits without active assignment risk
|
|
33
|
+
- `TICKER YYYY-MM-DD (N DTE)` for near-term ex-divs outside trade windows (context only)
|
|
34
|
+
Per-trade scans still run automatically via `thetabook evaluate` and `thetabook adjust`; 3d is the portfolio-level sweep that catches ex-divs on positions you weren't actively re-evaluating. If every ticker comes back without a dividend, note the empty result and move on.
|
|
35
|
+
|
|
36
|
+
4. **Revisit active ideas.** For each `watching` or `opened` idea, assess whether it's still valid given today's positions and any new information the user shares. In the journal's `## Active ideas review` section, lead each line with `idea NNN — TICKER — short one-line description` (NOT `#NNN` — GitHub auto-links the hash form into broken issue references). Example: `idea 003 — QQQ — covered-call roll plan, terminal arc on 7/17 legs, rolls used 2 of 2`. The one-liner is what the user sees first; assessment follows on subsequent lines.
|
|
37
|
+
|
|
38
|
+
5. **Start the journal entry.** Create `personal/journal/YYYY-MM-DD.md` (today's date) using the structure in `templates/journal.md` (read directly from the repo — templates are not copied into `personal/`). Fill in the `Positions reviewed` section immediately. Add to `Discussion`, `Ideas generated`, `Actions taken`, and `Learnings` as the conversation progresses.
|
|
39
|
+
|
|
40
|
+
6. **Update the wiki.** After completing the review:
|
|
41
|
+
- Read `personal/wiki/index.md` to see existing pages.
|
|
42
|
+
- Update `personal/wiki/overview.md`: refresh the thesis, risk posture (from `thetabook greeks` output), active underlyings table, and add today to the session history table.
|
|
43
|
+
- For each underlying discussed in depth, update or create `personal/wiki/underlyings/<TICKER>.md` — add any new position info, update trade arcs, note changes in outlook.
|
|
44
|
+
- Run `~/.local/bin/uv run thetabook wiki log "review | Portfolio review session"` to append the dated entry to `personal/wiki/log.md`.
|
|
45
|
+
- Update `personal/wiki/index.md` if any new pages were created.
|
|
46
|
+
- Run `~/.local/bin/uv run thetabook wiki render-ideas` if any idea status changed during the review (open, close, reject, new). Skip if only analysis happened with no idea-state mutations. The command preserves the hand-written Themes section in `personal/wiki/ideas.md`.
|
|
47
|
+
|
|
48
|
+
7. **Wait for the user to drive.** After the summary, ask what they want to focus on: specific positions, a strategy to explore, a new idea, or rolling/closing existing trades.
|
|
49
|
+
|
|
50
|
+
## Rules for this session
|
|
51
|
+
|
|
52
|
+
- Never place trades. All execution is manual in Schwab.
|
|
53
|
+
- **Never reference ideas as `#NNN`** in the journal, wiki, or chat output — the `#` prefix gets auto-linked to GitHub issues by markdown renderers. Always use `idea NNN` (e.g. `idea 003`, not `#003`). When citing an idea, prefer the descriptive form `idea NNN — TICKER — short description` so the reader can identify it without opening the file.
|
|
54
|
+
- Frame analysis as ideas to evaluate, not recommendations. The user makes decisions.
|
|
55
|
+
- When a new trade idea emerges, capture it via the `/idea` workflow (or directly: `~/.local/bin/uv run thetabook ideas new "<name>" --underlying <TICKER> --strategy <strat>`, then Edit the resulting file to fill in Thesis/Structure/Entry/Exit/Risks). Don't write idea files by hand — use the CLI so numbering stays consistent.
|
|
56
|
+
- When the user decides to act on an idea, update its status: `~/.local/bin/uv run thetabook ideas set-status <id> opened` (or `closed`, `rejected`, etc.). The CLI auto-fills `opened_at` / `closed_at`.
|
|
57
|
+
- When the user says something worth remembering durably (a lesson, a preference), either append to `personal/learnings.md` or save it to Claude's memory system — pick whichever fits (market lesson → personal/learnings.md, personal preference → memory).
|
|
58
|
+
- At the end of the session, prompt the user to wrap up the journal: confirm the `Learnings` section and ask if anything should be lifted into `personal/learnings.md`.
|
|
59
|
+
- At the end of the session, run a lightweight wiki lint: check for opened ideas missing from wiki pages, underlyings in the snapshot without a wiki page, and stale index entries. Report issues briefly (not the full `/wiki-lint` format) and offer to fix inline. Skip this if the session was very short or no wiki pages were touched.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fetch current price for one or more tickers
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Fetch the current market price for the ticker(s) provided in $ARGUMENTS.
|
|
6
|
+
|
|
7
|
+
## Steps
|
|
8
|
+
|
|
9
|
+
1. Parse the arguments. The user may provide one or more space-separated ticker symbols (e.g. `AAPL`, `AAPL SPY CRWV`). If no arguments are provided, ask the user which ticker(s) they want.
|
|
10
|
+
|
|
11
|
+
2. Run the price fetch:
|
|
12
|
+
```
|
|
13
|
+
~/.local/bin/uv run thetabook price <TICKER1> <TICKER2> ...
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
3. Report the results in a clean format:
|
|
17
|
+
- Show each ticker with its current price
|
|
18
|
+
- If a ticker wasn't found, say so
|
|
19
|
+
- Note the data source (Schwab, Massive API, or yfinance) if visible in stderr output
|
|
20
|
+
|
|
21
|
+
4. If the user has an active portfolio session or is evaluating an idea, mention how the price compares to any relevant positions or idea entries (e.g. "AAPL is at $185.20 — your short put at $175 is $10.20 OTM"). Only do this if you have that context loaded; don't read files just for this.
|
|
22
|
+
|
|
23
|
+
## Rules
|
|
24
|
+
|
|
25
|
+
- This is a quick lookup — keep the output concise.
|
|
26
|
+
- Do not start a review or evaluation session. Just report the price.
|
|
27
|
+
- Source cascade: Schwab → Massive → yfinance. The user may not have all sources configured — missing credentials or failures fall through silently.
|
|
28
|
+
- If many tickers are requested (>10), warn that this may be slow due to rate limits on the free Massive tier.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Refresh positions snapshot from Schwab
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Run `~/.local/bin/uv run thetabook refresh` via the Bash tool to fetch the latest positions from Schwab and write a new snapshot to `personal/snapshots/YYYY-MM-DD.json` (and update `personal/snapshots/latest.json`).
|
|
6
|
+
|
|
7
|
+
The CLI already prints the snapshot path, `fetched_at` timestamp, and per-account totals (type, last 4, liquidation value, cash) to stdout. Pass that output through verbatim — don't re-derive it. If the command fails with an auth error (missing `.env`, expired token, OAuth flow needed), explain what the user needs to do — do not re-run the command automatically.
|
|
8
|
+
|
|
9
|
+
Do not start a review. This command only refreshes the data; the user will run `/portfolio` separately when ready.
|