# Best Ideas + IBKR Command Center

Single dashboard for **live IBKR account state**, **VRP tickets**, and **Best Ideas fund sleeves** (sector momentum, tactical AW, macro options, equity dip rules).

## 1. Build snapshot (data layer)

With TWS or IB Gateway running (paper default port **7497**):

**IBKR end-to-end signals** (historical bars + tactical/sector targets + VRP recommend):

```bash
cd /Users/robzingale/trading_bot
PYTHONUNBUFFERED=1 .venv/bin/python -m RenTech.live.run_live_fund_signals
PYTHONUNBUFFERED=1 .venv/bin/python -m RenTech.monitor.build_command_center_snapshot --ibkr --live-signals
```

Or one step (refreshes `live_fund_signals.json` and merges into the snapshot):

```bash
PYTHONUNBUFFERED=1 .venv/bin/python -m RenTech.monitor.build_command_center_snapshot --ibkr --live-signals
```

**IB account only** (model tactical/sector from backtest CSVs):

```bash
PYTHONUNBUFFERED=1 .venv/bin/python -m RenTech.monitor.build_command_center_snapshot --ibkr
```

Without IB (model signals + recommendations only):

```bash
PYTHONUNBUFFERED=1 .venv/bin/python -m RenTech.monitor.build_command_center_snapshot
```

**Output:** `RenTech/data/logs/command_center_snapshot.json`

Refresh after:

- `combine_best_ideas_stack.py --mtm --fund-mode --fund-scale 2.2 …` (default quarterly sized)
- `python -m RenTech.monitor.build_command_center_snapshot [--ibkr]`
- `live_ibkr_trader.py --recommend-only` or `RenTech/live/run_live_platform.py`
- `run_tactical_all_weather_standard.py` / `run_tsmom_managed_futures.py`

## 2. Open the website

```bash
cd /Users/robzingale/trading_bot
.venv/bin/python -m http.server 8080
```

Browse: [http://localhost:8080/command_center.html](http://localhost:8080/command_center.html)

## 3. What you see

| Panel | Source |
|-------|--------|
| KPIs | IB account summary + latest fund NAV from fund daily CSV |
| **Strategy summary** | Per-sleeve cards: rules, standalone backtest, fund weight/PnL (`fund.portfolio.strategies_summary`) |
| **Signal logic & criteria** | Per-sleeve ✓/✗ gates, sizing, DTE/risk reminders (`signal_explain` in snapshot JSON) |
| **Best Ideas portfolio** | Headline metrics, yearly returns, sleeve attribution from `fund.portfolio` |
| Action queue | VRP recommendations + ETF target diff (tactical) vs IB stocks |
| Fund sleeves | Target weights + today's notional / PnL |
| IBKR positions | Live `ib.positions()` when `--ibkr` |
| Signals | With `--live-signals`: tactical + sector from **IB daily bars**; VRP from live recommend cycle. Without: backtest allocation CSVs |
| VRP tickets | `ibkr_trade_recommendation*.json` |

**Action types:** `ADD` · `REMOVE` · `HOLD` · `WATCH`

## 4. Suggested daily workflow

1. Start TWS / IB Gateway (paper or live per your config in `RenTech/live/config/live_platform_default.json`).
2. Run live recommend:  
   `PYTHONUNBUFFERED=1 .venv/bin/python RenTech/live/run_live_platform.py`
3. Rebuild snapshot:  
   `PYTHONUNBUFFERED=1 .venv/bin/python -m RenTech.monitor.build_command_center_snapshot --ibkr`
4. Keep `http.server` open; click **Refresh UI** or wait for 60s auto-refresh.

Optional cron (every 15 min during market hours):

```bash
*/15 9-16 * * 1-5 cd /Users/robzingale/trading_bot && .venv/bin/python -m RenTech.monitor.build_command_center_snapshot --ibkr
```

## 5. Broker config

| Setting | Default | File |
|---------|---------|------|
| Host | 127.0.0.1 | `live_platform_default.json` |
| Port | 7497 (paper) | same |
| Client ID | 2 | same |

Live port is often **7496**. Edit JSON or duplicate config for live.

## 6. Live fund signals (`RenTech/live/`)

| Module | Role |
|--------|------|
| `ibkr_market_data.py` | `reqHistoricalDataAsync` → `close` / `sma_200` / `aqr_mom` |
| `fund_signals.py` | Sector rotation + tactical AW (`bond70_sma200`) + VRP `VrpIbkrStrategy` |
| `run_live_fund_signals.py` | CLI → `RenTech/data/logs/live_fund_signals.json` |

**Still backtest-reference in v1:** VXX regime stack, macro AW options, VXX long call, TSMOM (WATCH rows in action queue). Fund return/Sharpe KPIs remain from `best_ideas_stack_*` daily CSV.

## 7. Limitations (v1)

- ETF sleeves compare **IB stock market value** to model **weights**, not share counts.
- Equity dip is **event-driven** (no calendar); shown as `WATCH`.
- Macro AW open structures listed from backtest trade CSV, not live Theta.
- Options books (VRP, macro) need manual leg check vs recommendation JSON.
