P123-to-IBKR Rebalance Execution Planner
What This Skill Does
Takes a P123 target portfolio (CSV of ticker + weight) and a portfolio YAML config (IBKR NAV, current holdings, ADV, FX rates) and generates a multi-day execution worksheet with daily trading orders, respecting liquidity constraints.
Workflow
Initial Rebalance (/rebalance)
- •Ask the user for:
- •Portfolio YAML config path (or help them create one)
- •P123 CSV file path
- •Run
scripts/ingest_p123.pyto parse the P123 CSV - •Run
scripts/compute_execution.pywith the parsed targets and YAML config - •Run
scripts/generate_report.pyto produce the pre-trade verification report (.md) - •Present the report to the user — they must review ingestion, FX rates, position sizes, and the Day 1 worksheet before proceeding
- •Save execution state for daily updates
Daily Update (/rebalance update)
- •Ask the user for:
- •Yesterday's fills (which orders executed, how many shares)
- •Updated prices (or confirm using existing)
- •Updated NAV (if changed)
- •Run
scripts/update_day.pywith fills and new prices - •Display today's revised worksheet and progress summary
Commands
code
# Initial rebalance python scripts/ingest_p123.py <p123_csv_path> --output <targets_json_path> python scripts/compute_execution.py <targets_json_path> <portfolio_yaml_path> --output-dir <output_dir> python scripts/generate_report.py <output_dir>/execution_state.json <portfolio_yaml_path> --output <output_dir>/report.md # Daily update python scripts/update_day.py <state_json_path> --fills <fills_json> --prices <prices_json> --nav <new_nav>
Key Rules
- •Sells before buys in every worksheet — frees cash for purchases.
- •Direction is locked on Day 0 — if a position is BUY, it stays BUY for the entire rebalance. Never reverse within a window.
- •If target is overshot due to favorable price movement, mark that ticker DONE. Do not reverse.
- •Liquidity caps are per-ticker:
min(abs(delta_shares), adv * adv_fraction). - •Cash reserve is deducted before computing investable NAV.
- •P123 weights are normalized to sum to 100% of investable NAV.
- •Share rounding: toward zero (floor for buys, ceil for sells).
Portfolio YAML Config Format
See references/config_format.md for the full schema. Minimal example:
yaml
portfolio: "AVCO 001"
ibkr_nav: 850000
base_currency: USD
max_execution_days: 3
default_adv_fraction: 0.05
cash_reserve_pct: 0.02
current_holdings:
ALTN:
shares: 2000
price: 19.61
currency: GBP
adv: 50000
adv_fraction: 0.10
fx_rates:
GBP: 1.27
SEK: 0.095
CAD: 0.74
USD: 1.0