[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77JRZ7RC242P1B4KJZ2Y4J8":3,"skill-same:01M77JRZ7RC242P1B4KJZ2Y4J8":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":37,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":39,"updatedAt":40,"install":41,"resources":53},"01M77JRZ7RC242P1B4KJZ2Y4J8","investorclaw",null,"Deterministic-first portfolio analyzer — holdings, performance, Sharpe + Sortino, FRED yield curves, bond duration, sector breakdowns, scenario rebalancing — via MCP-HTTP. Backed by ic-engine and clio.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fi\u002Finvestorclaw\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: investorclaw\ndescription: Deterministic-first portfolio analyzer — holdings, performance, Sharpe + Sortino, FRED yield curves, bond duration, sector breakdowns, scenario rebalancing — via MCP-HTTP. Backed by ic-engine and clio.\nhomepage: https:\u002F\u002Fgithub.com\u002Fargonautsystems\u002FInvestorClaw\nuser-invocable: true\nmetadata: {\"license\":\"MIT-0\",\"version\":\"4.7.0\",\"image\":\"ghcr.io\u002Fargonautsystems\u002Fic-engine:4.7.0-cpu\",\"mcp-endpoint\":\"http:\u002F\u002Flocalhost:18090\u002Fmcp\",\"transport\":\"streamable-http\"}\n---\n\n\u003C!--\nSPDX-License-Identifier: MIT-0\nCopyright 2026 InvestorClaw Contributors\n-->\n\n# InvestorClaw — portfolio analysis skill (v4.7.0)\n\nA deterministic-first portfolio analyzer that does real money math: holdings\nsnapshots, performance metrics, Sharpe ratios, FRED yield curves, bond\nduration, sector breakdowns, scenario rebalancing. Backed by ic-engine\n(Python, FINOS CDM 5.x compliant).\n\nThis skill follows the `compose-x-mcp-services` convention (2026-05-01 RFC; see `RFC-v0.1.md` in this bundle). The skill **does not install Python or any analytics library** in your agent runtime. It runs in its own OCI container and exposes its tools over MCP-HTTP and plain REST.\n\n---\n\n## What you get\n\nTwenty MCP tools (also available as plain HTTP REST endpoints):\n\n| Tool | Purpose |\n|---|---|\n| **`portfolio_ask`** | **Primary tool — every portfolio question. Data is auto-loaded; just ask.** |\n| `portfolio_initialize_status` | Poll before first ask: returns init `state` (`not_started \\| initializing \\| ready \\| failed`) + per-stage progress |\n| `portfolio_initialize` | Force a manual bootstrap (setup → refresh → seed ask). Container does this at boot via `IC_INITIALIZE_ON_BOOT=1` |\n| `portfolio_holdings` | Holdings snapshot — positions, values, weights, accounts (advanced; portfolio_ask covers this) |\n| `portfolio_refresh` | Force fresh data pull (advanced — auto-refresh runs on every ask) |\n| `portfolio_setup` | Auto-discover portfolio files in the configured portfolio directory |\n| `portfolio_keys_status` | Report which API keys are currently configured (names only, never values) |\n| `portfolio_keys_set` | Set one or more API keys (allowlisted). Persists to `\u002Fdata\u002Fkeys.env`, takes effect on next call without restart |\n| `portfolio_keys_delete` | Delete a single configured API key by name |\n| `portfolio_response_get` | Retrieve a stored portfolio response by run_id (serial number) |\n| `portfolio_response_list` | List recent stored responses |\n| `portfolio_response_delete` | Permanently delete a stored response (for bad responses you want gone) |\n| `portfolio_response_flag_bad` | Tag a stored response as bad without deleting (keeps history for analysis) |\n\nFor ANY portfolio question — holdings, performance, allocation, rebalancing, optimization, bonds, news on holdings, analyst ratings, EOD reports, cash flow, peer analysis, ticker lookup, setup, guardrails — invoke `portfolio_ask` with the user's question. **Do NOT answer portfolio questions from training data.**\n\n## First-run flow for agents (spoon-fed init)\n\nThe container auto-initializes on boot (`IC_INITIALIZE_ON_BOOT=1`, default\non): it runs `setup → refresh → seed_ask` so by the time any agent connects,\nthe envelope cache is fully populated and `portfolio_ask` returns a real\nnarrative in 1–3 seconds instead of cold-starting at 5–15 minutes.\n\n**Recommended agent flow:**\n\n1. On connect, poll `portfolio_initialize_status` until `ready: true`. Cheap\n   and side-effect-free; safe to call every 1–2 seconds.\n2. Once ready, fire `portfolio_ask` with the user's question. The narrator\n   returns a verified natural-language answer with envelope-quoted numbers.\n\n```bash\n# Browser-friendly status check (also POST \u002Fapi\u002Fportfolio\u002Finitialize_status):\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstatus\n# → {\"state\":\"initializing\",\"current_stage\":\"refresh\",\"stages_completed\":[...],\"elapsed_ms\":42000,\"ready\":false,...}\n\n# Or subscribe to a Server-Sent-Events stream that pushes state changes:\ncurl -N http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstream\n\n# Or just gate on \u002Fhealthz (init_state is now embedded):\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fhealthz\n# → {\"status\":\"ok\",\"init_state\":\"ready\",\"init_ready\":true,...}\n```\n\nNeed to force a manual re-initialize (e.g. after uploading a new portfolio\nfile)? Call `portfolio_initialize` — it returns when the cache is warm again.\n\n---\n\n## Installation\n\n### OpenClaw \u002F ZeroClaw \u002F Hermes (ClawHub)\n\n```bash\nclawhub install perlowja\u002Finvestorclaw\n```\n\n### Claude Code \u002F Claude Desktop\n\n```\n\u002Fplugin marketplace add argonautsystems\u002FInvestorClaw\n\u002Fplugin install investorclaw\n```\n\n### Manual (Docker Compose, any agent)\n\nThe skill is a Docker Compose stack. With Docker or Podman installed:\n\n```bash\nmkdir -p portfolios     # IMPORTANT: pre-create so docker doesn't auto-create as root\ndocker compose up -d    # uses compose.yml shipped in this skill\n```\n\n**Agent install convention.** When a skills-installer\n(`openclaw skills install investorclaw`, `clawhub install\ninvestorclaw`, etc.) places this bundle, the agent **may** proceed\nto `mkdir -p portfolios && docker compose up -d` because the user's\ninstall command is itself an opt-in to the install completing. But\nthe agent **must** first surface the side effects to the user\nexplicitly:\n\n1. `docker pull` of `~600 MB` (the engine image) on first run\n2. `docker compose up -d` binds two TCP listeners to localhost:\n   `:18090` (MCP + REST) and `:18092` (dashboard)\n3. The container auto-initializes on boot\n   (`IC_INITIALIZE_ON_BOOT=1`) and will fetch market data from\n   the configured providers (yfinance free-tier by default; other\n   providers only if API keys have been added)\n4. Persistent state lands in the `ic-engine-data` Docker volume\n   (deleted only by `docker compose down -v`)\n\nA single one-line surfacing covering all four is sufficient. Example:\n\n> Starting the container will pull a ~600 MB image, bind localhost\n> ports `:18090` and `:18092`, auto-init against yfinance, and\n> persist state in a Docker volume. Proceeding…\n\nThe user retains the ability to interrupt (Ctrl-C, \"no don't\",\netc.). Don't ask a yes\u002Fno question by default — that's friction the\nuser has already cleared by typing the install command. **Do** ask\nwhen one of these conditions holds:\n\n- The host appears to be a CI runner, shared machine, or production\n  server where the user might want to review `compose.yml` first.\n- An existing `ic-engine` container is already running on the host\n  with a different image tag — confirm before disrupting.\n- The user explicitly added `--dry-run` or `--no-start` to the install\n  command (if the skills installer surfaces those flags).\n- The agent's runtime policy requires a confirmation prompt before\n  any container start (some enterprise \u002F regulated deployments).\n\nThe first command (`mkdir -p portfolios`) is load-bearing. If skipped,\ndocker creates `.\u002Fportfolios\u002F` as `root:root` when starting the\nbind-mount, the engine runs as `uid=1000(ic)` inside the container,\nand init fails with\n`PermissionError: '\u002Fdata\u002Fportfolios\u002Fsetup_results.json'` and the\ncontainer goes into `init_state=failed`. Pre-creating the directory\nas the host user sidesteps the docker bind-mount UID inheritance\nquirk.\n\nThe compose pulls `ghcr.io\u002Fargonautsystems\u002Fic-engine:4.7.0-cpu` (publicly hosted, no auth) and runs it on `localhost:18090` (MCP + REST) and `localhost:18092` (dashboard).\n\n### If Docker isn't installed\n\nInstall Docker Desktop or Docker Engine for your platform — **the user\nshould run the install themselves** rather than have an agent execute\nthe command. Pointers (verify with each OS's current docs at\n\u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002F> before running):\n\n| OS | Suggested path |\n|---|---|\n| **macOS** | Docker Desktop: \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fdesktop\u002Finstall\u002Fmac-install\u002F> (Homebrew users: `brew install --cask docker`) |\n| **Debian\u002FUbuntu** | Follow the official guide: \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Fdebian\u002F> or \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Fubuntu\u002F> |\n| **Fedora\u002FRHEL** | \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Ffedora\u002F> or \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Frhel\u002F> |\n| **Windows** | Docker Desktop with WSL2 backend: \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fdesktop\u002Finstall\u002Fwindows-install\u002F> |\n| **Podman alternative** | `podman compose up -d` is a drop-in replacement once Podman is installed (most distros ship it) |\n\nAfter install, verify with `docker --version` then run the compose-up\ncommand above.\n\n**For agent operators:** prefer surfacing these install URLs to the\nend user rather than running package-manager install commands directly\nthrough your shell tool. Docker installation typically requires sudo\nand adds the user to the `docker` group — operations that benefit from\nexplicit user consent.\n\n### Wait for ready\n\n```bash\nuntil curl -sf http:\u002F\u002Flocalhost:18090\u002Fhealthz > \u002Fdev\u002Fnull 2>&1; do sleep 1; done\necho \"ic-engine ready\"\n```\n\nThe first cold-start takes 5-10 seconds (image extract + Python import). Subsequent restarts are \u003C2s.\n\n---\n\n## First-run experience — what to expect\n\nAfter `docker compose up -d` the container goes through an auto-init\nsequence (`IC_INITIALIZE_ON_BOOT=1`) that warms the envelope cache before\nyour agent talks to it. Expect this timeline on a fresh install:\n\n| Phase | Time | What's happening | What you'll see |\n|---|---|---|---|\n| Image extract | 5–30 s | First-time pull of `ic-engine:4.7.0-cpu` (~600 MB) | docker compose progress bars |\n| Bridge boot | 2–3 s | FastMCP server binds `:18090`, dashboard binds `:18092` | `\u002Fhealthz` returns 200, `init_state: not_started` |\n| `portfolio_setup` | 1–60 s | Auto-discover portfolio files in `.\u002Fportfolios\u002F` | `init_state: initializing`, `current_stage: setup` |\n| `portfolio_refresh` | 30–120 s | Pull quotes \u002F analyst \u002F news \u002F FRED yields for each symbol | `init_state: initializing`, `current_stage: refresh` |\n| `seed_ask` | 5–60 s | Run a primer ask so the cache is warm | `init_state: initializing`, `current_stage: seed_ask` |\n| **Ready** | — | All sections cached, `portfolio_ask` returns in 1–3 s | `init_state: ready`, `init_ready: true` |\n\n**Total cold-start budget**: ~60-200 s for a 100-position portfolio,\n~5-15 minutes for a 200+ position portfolio without paid quote keys.\nWatch progress via:\n\n```bash\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstatus | jq\n# or stream:\ncurl -N http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstream\n```\n\n### What InvestorClaw asks of you\n\nThe container does **not** prompt interactively. It surfaces what it\nneeds through structured responses:\n\n1. **A portfolio file.** If `.\u002Fportfolios\u002F` is empty, every `portfolio_ask`\n   call returns: *\"No portfolio file found … please add CSV\u002FExcel\u002FPDF\n   files to your portfolios directory.\"* Drop a broker export from\n   Schwab \u002F Fidelity \u002F Vanguard \u002F UBS \u002F ETrade \u002F Robinhood (CSV\u002FXLS\u002FPDF\u002Fscreenshot)\n   into the bind-mounted `.\u002Fportfolios\u002F` folder, then call\n   `portfolio_setup` to ingest it.\n\n2. **An LLM provider key for narrative synthesis.** Without one, the\n   engine still runs the deterministic pipeline (numbers are correct)\n   but the narrator returns a stub catalog blurb instead of a real\n   prose answer. The container ships pre-configured to use Together AI\n   (`google\u002Fgemma-4-31B-it`), so all you need is a `TOGETHER_API_KEY`.\n   Set it with:\n\n   ```bash\n   curl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_set \\\n     -H 'Content-Type: application\u002Fjson' \\\n     -d '{\"keys\": {\"TOGETHER_API_KEY\": \"tgp_v1_...\"}}'\n   ```\n\n   Or drop into the dashboard at http:\u002F\u002Flocalhost:18092\u002F and paste it\n   into the Settings tab.\n\n3. **Optional: data-provider keys** for richer \u002F faster results\n   on larger portfolios (see *Optional configuration → Which keys to\n   obtain (by portfolio size)* below). The engine works key-less in\n   degraded mode (yfinance-only, rate-limited).\n\n### What InvestorClaw recommends — by portfolio size\n\n| Size | Required | Recommended | Why |\n|---|---|---|---|\n| **≤ 50 symbols** | `TOGETHER_API_KEY` (narrative) | — | yfinance handles quotes\u002Fhistory at this scale; one key covers narrative |\n| **50–200 symbols** | `TOGETHER_API_KEY` | `FINNHUB_KEY` (free 60\u002Fmin) + `NEWSAPI_KEY` (free 100\u002Fday) | Real-time quotes + analyst + per-symbol news without yfinance throttle |\n| **200+ symbols** | `TOGETHER_API_KEY` + `MASSIVE_API_KEY` (Massive, paid) | `FINNHUB_KEY` + `MARKETAUX_API_KEY` (free 100\u002Fday) + `FRED_API_KEY` (free, registration) + `ALPHA_VANTAGE_KEY` (free 25\u002Fday) | Yahoo's anonymous query1 endpoint rate-limits globally on 200+ symbols under barrage; Massive is required, the rest fill analyst + news + yields |\n\nWhy `TOGETHER_API_KEY` is the only hard requirement for narrative:\n\n- Cheapest serverless tier on Together AI (~$0.0008 \u002F 1 K tokens)\n- Default model `google\u002Fgemma-4-31B-it` has good quality for portfolio\n  narrative + ~100 tok\u002Fs throughput\n- Single key replaces the older multi-tier model setup that v2.x used\n\nSign-up links (all have free tiers):\n\n| Provider | URL | Free-tier limit |\n|---|---|---|\n| Together AI | https:\u002F\u002Fapi.together.ai\u002Fsettings\u002Fapi-keys | $1 free credits |\n| Finnhub | https:\u002F\u002Ffinnhub.io\u002Fregister | 60 calls\u002Fmin |\n| Massive | https:\u002F\u002Fmassive.com\u002F | paid only |\n| MarketAux | https:\u002F\u002Fwww.marketaux.com\u002Faccount\u002Fdashboard | 100 calls\u002Fday |\n| NewsAPI | https:\u002F\u002Fnewsapi.org\u002Fregister | 100 calls\u002Fday |\n| FRED | https:\u002F\u002Ffred.stlouisfed.org\u002Fdocs\u002Fapi\u002Fapi_key.html | unlimited (registration only) |\n| Alpha Vantage | https:\u002F\u002Fwww.alphavantage.co\u002Fsupport\u002F#api-key | 25 calls\u002Fday |\n\nThe `TOGETHER_API_KEY` is the only one that's genuinely required.\nEverything else degrades gracefully.\n\n### First call — what your agent will see\n\nOnce `init_state: ready` and a portfolio is loaded, the very first\n`portfolio_ask` call returns a response shaped like:\n\n```json\n{\n  \"exit_code\": 0,\n  \"narrative\": \"I have holdings summary data in the envelope.\\n- bond_pct: 26.76\\n- bond_value: 705646.57\\n- cash_pct: 1.69\\n- equity_pct: 71.55\\n- equity_value: 1886470.25\\nTop holding symbols: MSFT, NVDA, SCHB, GOOG, AAPL, ...\",\n  \"ic_result\": {\n    \"hmac\": \"75ca79c...\",\n    \"engine_version\": \"2.5.2\",\n    \"command\": \"ask\",\n    \"run_id\": \"299d36b0-...\"\n  }\n}\n```\n\nThe `narrative` field is the agent-facing answer. The `ic_result`\ncontains the HMAC signature that proves the response came from the\ndeterministic engine (not LLM-fabricated).\n\nIf you see *\"is a general finance concept. ic-engine is portfolio-specific\"*\nin the narrative for a question that obviously is about your portfolio,\nyou're on a pre-v4.1.25 image — pull the latest:\n\n```bash\ndocker compose pull && docker compose up -d\n```\n\n---\n\n## How to call the tools\n\n### Option A: native MCP client (preferred)\n\nIf your runtime has a native MCP client, register the server:\n\n```\nURL:       http:\u002F\u002F127.0.0.1:18090\u002Fmcp\nTransport: streamable-http\nAuth:      none (localhost only)\n```\n\nPer-runtime CLI:\n\n| Runtime | Command |\n|---|---|\n| zeroclaw | Add `[[mcp.servers]]` with `name = \"ic-engine\"`, `url = \"http:\u002F\u002F127.0.0.1:18090\u002Fmcp\"`, `transport = \"http\"` to `~\u002F.zeroclaw\u002Fconfig.toml` |\n| openclaw | `openclaw mcp set ic-engine '{\"url\":\"http:\u002F\u002F127.0.0.1:18090\u002Fmcp\",\"transport\":\"streamable-http\"}'` |\n| hermes | `hermes mcp add ic-engine --url http:\u002F\u002F127.0.0.1:18090\u002Fmcp` |\n| claude code | Add to `~\u002F.claude\u002Fmcp_servers.json` per Claude Code docs |\n\nThen call tools by name (`portfolio_ask`, `portfolio_holdings`, etc.) via your runtime's tool-use API.\n\n### Option B: plain HTTP REST (works when MCP integration is flaky)\n\nEquivalent endpoints exist at `\u002Fapi\u002Fportfolio\u002F*`. Use your runtime's shell or HTTP tool:\n\n```bash\n# Ask any portfolio question\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fask \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"question\": \"What is in my portfolio?\"}' \\\n  --max-time 120\n\n# Other endpoints (no body needed)\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fholdings -H 'Content-Type: application\u002Fjson' -d '{}'\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Frefresh  -H 'Content-Type: application\u002Fjson' -d '{}'\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fsetup    -H 'Content-Type: application\u002Fjson' -d '{}'\n\n# Self-describing tool catalog\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Ftools\n```\n\nThe JSON response has a `narrative` field with the human-readable answer — quote that to the user. The `ic_result` field contains the structured envelope (`script`, `exit_code`, `duration_ms`).\n\n---\n\n## What to ask — example queries\n\nOnce installed, ask portfolio questions in natural language. The agent routes\nthrough `portfolio_ask`; ic-engine handles the deterministic computation and\nthe narrator quotes verbatim from the signed envelope.\n\n| Intent | Example phrasing |\n|---|---|\n| **Holdings snapshot** | \"What's in my portfolio?\" • \"Show me my positions\" • \"What do I own?\" |\n| **Performance** | \"How am I doing this year?\" • \"What's my Sharpe ratio?\" • \"Show me my drawdowns\" |\n| **Bonds** | \"Show me my bond exposure and yield-to-maturity\" • \"What's my bond ladder look like?\" |\n| **Allocation \u002F risk** | \"What's my sector exposure?\" • \"How concentrated is my portfolio?\" • \"What's my risk profile?\" |\n| **Optimization \u002F rebalancing** | \"Help me rebalance to a 60\u002F40 target\" • \"Show me an efficient frontier\" |\n| **Market data** | \"What's the current price of NVDA?\" • \"How is the S&P performing today?\" |\n| **Fixed-income concepts** | \"What does yield-to-maturity mean?\" • \"Explain duration\" |\n| **News** | \"Today's news on my holdings\" • \"Crypto news today\" |\n| **Reports** | \"Generate today's EOD report\" • \"Prepare a full analysis for my advisor meeting\" |\n| **Fresh data** | \"Prices moved — refresh before answering\" → triggers `portfolio_refresh` |\n\nThe first call after a cold cache may take 30–60 seconds while the\ndeterministic pipeline builds the signed envelope. Subsequent calls reuse\nthe cache (TTL: 30s for news, 60s for other sections); ask for a refresh\nexplicitly if data feels stale.\n\n---\n\n## Agent routing rules\n\nThese rules apply when an agent has the InvestorClaw skill installed:\n\n**Use InvestorClaw — do NOT answer from training data, web search, or browsing — for:**\n- Any portfolio \u002F holdings \u002F positions question\n- Performance, returns, Sharpe\u002FSortino, drawdown\n- Bonds, yield-to-maturity, duration, ladders\n- Sector \u002F asset \u002F account allocation\n- Optimization, rebalancing, target allocation, scenarios\n- Cash flow, dividend \u002F coupon calendars\n- Analyst ratings, price targets\n- Today's news on holdings or market-wide topics\n- Live ticker prices and quotes\n- EOD reports, peer comparison, what-changed analysis\n\n**Deterministic-first rules:**\n- Never calculate portfolio metrics in the agent — call the tool.\n- Never fabricate market, ticker, bond, portfolio, optimization, or news data.\n- Preserve quoted source passages, numbers, dates, timestamps, and freshness\n  labels exactly.\n- If the signed envelope lacks a requested fact, say InvestorClaw did not\n  provide it and quote the engine's limitation verbatim.\n- Use `portfolio_refresh` only when the user asks for fresh data or when\n  data appears stale.\n\n**Attachment handling:**\n- When the user attaches a CSV \u002F XLS \u002F XLSX \u002F PDF \u002F screenshot in the same\n  turn as a portfolio question, stage the file to the bind-mounted\n  `portfolios\u002F` directory, call `portfolio_setup`, then ask the original\n  question.\n- Do not ask the user to move files manually; the agent owns staging.\n- Report low-confidence extraction or setup gaps exactly as InvestorClaw\n  returns them.\n\n**Educational guardrails:**\n- All output is educational, not investment advice.\n- Never present \"buy\u002Fsell\" recommendations as advice.\n- Never assess suitability for the user's situation.\n- Preserve the engine's disclaimer language verbatim.\n\n---\n\n## Required response format (when answering as an agent)\n\nEnd every portfolio reply with:\n\n```\nVerification: ic-engine ask completed (exit_code: 0)\n```\n\n(Substitute the actual `exit_code` from the response.) The harness depends on this exact line.\n\nFor finance-concept questions (\"what is YTM?\") or market-wide questions (\"how is the S&P performing?\"), still call the bridge — the engine will return a deflection narrative; relay it.\n\n---\n\n## Configure portfolios\n\nDrop your broker exports (CSV, XLS, PDF) into the bind-mounted directory:\n\n```bash\n# default mount: .\u002Fportfolios on the host -> \u002Fdata\u002Fportfolios in the container\nmkdir -p portfolios\ncp ~\u002FDownloads\u002FUBS_Holdings_2026-05-02.xls portfolios\u002F\n\n# Then ask the agent or curl the setup endpoint\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fsetup -H 'Content-Type: application\u002Fjson' -d '{}'\n```\n\nSupported formats: UBS, Schwab, Fidelity, Vanguard, ETrade, Robinhood (CSV\u002FXLS); generic CSV with `symbol`\u002F`quantity`\u002F`value` columns; PDF statements (auto-extracted).\n\n### Broker export instructions\n\nMost major US brokers expose a CSV download of holdings. CSV is the highest-\ncompatibility format; XLS \u002F XLSX \u002F PDF \u002F screenshot also work.\n\n| Broker | Path |\n|---|---|\n| Schwab | Accounts → Positions → Export CSV |\n| Fidelity | NetBenefits → Investments → Download CSV |\n| Vanguard | My Accounts → Download Holdings |\n| UBS | Wealth Management → Holdings → Export |\n| ETrade | Portfolio → Holdings → Download |\n| Robinhood | Account → Statements → CSV |\n\nWhen the user attaches a broker file directly to an agent chat, the agent\nstages it to the bind-mounted `portfolios\u002F` directory, then calls\n`portfolio_setup` followed by `portfolio_ask`. Account numbers and SSNs are\nscrubbed at ingest before any data leaves the container.\n\n---\n\n## Optional configuration\n\nThe container reads optional env vars from `\u002Fdata\u002Fkeys.env` (host-mounted). All optional — the deterministic-engine works without LLM\u002Fnews keys, just in degraded mode (no narrative synthesis, no live news).\n\n### Which keys to obtain (by portfolio size)\n\nThe bridge has built-in fallback across providers; the only **hard\nrequirement** is an LLM key for narrative synthesis. Below that, your\nchoice depends on portfolio size.\n\n**Small (≤50 symbols)** — yfinance-only is fine:\n- `TOGETHER_API_KEY` (or any LLM): required for narrative\n- That's it. Yahoo Finance handles quotes\u002Fhistory at this scale.\n\n**Medium (50–200 symbols)** — add Finnhub:\n- `TOGETHER_API_KEY`: LLM narrative\n- `FINNHUB_KEY`: real-time quotes + analyst ratings (60\u002Fmin, free)\n- `NEWSAPI_KEY` *(optional)*: per-symbol news (100\u002Fday free)\n\n**Large (200+ symbols)** — Massive is required:\n- `TOGETHER_API_KEY`: LLM narrative\n- `MASSIVE_API_KEY` (Massive): paid, un-rate-limited quotes + history + Benzinga news + analyst ratings\n- `FINNHUB_KEY`: analyst ratings + general\u002Fforex\u002Fcrypto\u002Fmerger news\n- `MARKETAUX_API_KEY` *(optional)*: broader news with category filters\n- `FRED_API_KEY` *(optional)*: Treasury yield curve (Treasury.gov fallback runs without)\n- `ALPHA_VANTAGE_KEY` *(optional)*: supplemental EOD prices (25\u002Fday free)\n\nWhy: Yahoo's anonymous query1 endpoint rate-limits globally (HTTP 429) on\n200+ symbol portfolios under barrage load. Massive handles the\nbulk of quotes\u002Fhistory without throttling; Finnhub fills analyst + news;\nthe no-key Frankfurter (FX) and Treasury Fiscal Data (yields) providers\ncover the remainder.\n\n### Full key reference\n\n| Key | Purpose | Cost note |\n|---|---|---|\n| `TOGETHER_API_KEY` | LLM narrative synthesis (Together google\u002Fgemma-4-31B-it) | serverless, fleet default |\n| `MASSIVE_API_KEY` | Massive: quotes + history (200+ symbol portfolios) + Benzinga news + analyst ratings | paid, un-rate-limited |\n| `FINNHUB_KEY` | Real-time quotes + analyst ratings + category news | 60\u002Fmin free |\n| `MARKETAUX_API_KEY` | Financial news with broader filters than NewsAPI | 100\u002Fday free |\n| `NEWSAPI_KEY` | Per-symbol news (US sources only) | 100\u002Fday free |\n| `ALPHA_VANTAGE_KEY` | Supplemental EOD prices | 25\u002Fday free |\n| `FRED_API_KEY` | FRED yield curve | free, registration required |\n| `OPENAI_API_KEY` | Alternative LLM (GPT-4o, GPT-5) | paid |\n\n### No-key providers (always available)\n\n| Provider | Coverage |\n|---|---|\n| **yfinance** | Quotes, history, news, analyst (rate-limited; safety-net only on 200+ portfolios) |\n| **Frankfurter** | FX spot rates (EUR\u002FUSD, USD\u002FJPY, etc.) — ECB-sourced |\n| **Treasury Fiscal Data** | US Treasury yield curve fallback when FRED_API_KEY missing |\n\n### Configure keys via REST\u002FMCP (preferred — no host shell needed)\n\nThe agent can set keys directly via the running container, no `\u002Fdata\u002Fkeys.env`\nedit required. Persists atomically (mode 0600), takes effect on the next\n`portfolio_ask` without a restart.\n\n```bash\n# What's configured?\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_status \\\n  -H 'Content-Type: application\u002Fjson' -d '{}'\n# → {\"configured\":[\"FINNHUB_KEY\",\"NEWSAPI_KEY\"], \"settable\":[...], \"missing\":[...]}\n\n# Set one or more keys\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_set \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"keys\": {\"TOGETHER_API_KEY\": \"tgp_v1_...\", \"FRED_API_KEY\": \"...\"}}'\n# → {\"configured\":[\"FRED_API_KEY\",\"TOGETHER_API_KEY\"], \"rejected\":[], \"deleted\":[]}\n\n# Remove a key\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_delete \\\n  -H 'Content-Type: application\u002Fjson' -d '{\"name\": \"OPENAI_API_KEY\"}'\n```\n\nThe same operations are available as MCP tools: `portfolio_keys_status`,\n`portfolio_keys_set`, `portfolio_keys_delete`. Only the standard ic-engine\nkey names are accepted; arbitrary names are rejected with a structured\n`{\"rejected\": [...], \"settable\": [...]}` response.\n\n### Configure keys via host file (alternative)\n\nIf you prefer to manage keys outside the container, drop them into\n`portfolios\u002Fkeys.env` on the host (the bind-mounted location), one\n`KEY=VALUE` per line:\n\n```env\nTOGETHER_API_KEY=tgp_v1_...\nFINNHUB_KEY=...\nNEWSAPI_KEY=...\n```\n\nThe container reads from `\u002Fdata\u002Fkeys.env` at boot.\n\n---\n\n## Model recommendations\n\nInvestorClaw uses two LLM roles when answering: **narrative** (synthesizes\nthe signed envelope into prose) and **validator** (checks the narrative\nagainst the envelope for fabrication and number-preservation). The\nrecommended model mix depends on your runtime.\n\n### Claude Code \u002F Claude Desktop\n\nThe agent's own LLM does both roles — no external API key required.\n\n- **Narrative**: Haiku 4.5 — fast, cheap, ~10× lower output cost than\n  Sonnet. Synthesis with a clean envelope is mostly transcription, so the\n  cheap model is sufficient.\n- **Validator**: Sonnet 4.6 (default) or Opus 4.7 (escalation) — gates the\n  Haiku output for fabrication, mis-quoted numbers, and training-leak\n  drift. Validator output is short (~1 K tokens) so the smart-model bill\n  stays low.\n\nThis split is cost-shaped: cheap model on the long output, smart model on\nthe short safety check. Total session cost on a 100-position portfolio\ntypically lands well under $0.01.\n\n### openclaw \u002F zeroclaw \u002F hermes\n\n**Anthropic on the claws stack — three paths, two of them paid:**\nsince 2026-04-04 your Anthropic OAuth subscription no longer covers\nthird-party-tool usage. To use Anthropic models on a claws-agent\nruntime you need either (a) Anthropic's discounted \"extra usage\nbundles\" added to your subscription, or (b) a direct Anthropic API\nkey. Routing OAuth-subscription tokens to a claws-agent without one of\nthose is a ToS violation per Anthropic's Apr 3 announcement.\n\nEven with paid credits, Anthropic isn't cost-competitive with Together\nfor InvestorClaw narrative synthesis (~10–50× the per-token cost).\n**On our own fleet infrastructure we don't deploy Anthropic for these\nruntimes**; end-users should weigh ToS, cost, and quality before\nopting into it.\n\nBring a non-Anthropic provider via `TOGETHER_API_KEY` (or equivalent).\nFleet defaults:\n\n- **Default narrative**: Together AI `google\u002Fgemma-4-31B-it` — serverless\n  tier, ~100 tok\u002Fs, ~$0.0008 \u002F 1 K tokens, ships as the container default.\n- **Higher-quality alternative**: Together AI `MiniMaxAI\u002FMiniMax-M2` —\n  larger context, but **moved off Together's serverless tier in 2026-05**\n  and now requires a paid dedicated endpoint. Use only if you've\n  provisioned that endpoint.\n- **Local-only \u002F offline**: Ollama `gemma4:e4b` on host — zero cloud cost,\n  GPU-bound, no key required.\n\nTo switch the narrative model, set `INVESTORCLAW_NARRATIVE_MODEL` in\n`portfolios\u002Fkeys.env` (e.g. `INVESTORCLAW_NARRATIVE_MODEL=MiniMaxAI\u002FMiniMax-M2`\nonce you have a dedicated endpoint configured at Together).\nThe container reads it on next call without restart.\n\n---\n\n## Data privacy\n\n**Stays on your machine:**\n- Raw broker exports (CSV \u002F XLS \u002F PDF) in `portfolios\u002F`\n- Account numbers and SSNs (scrubbed at ingest)\n- Full position details (lot history, cost basis)\n- Python computation internals (intermediate calculations)\n\n**Sent to the configured LLM provider for narrative synthesis:**\n- The user's question\n- The HMAC-signed JSON envelope produced by ic-engine\n- Computed metrics needed for presentation\n\n**Never sent anywhere:**\n- Raw PII (account numbers, SSNs, names)\n- Pre-computation intermediate state\n- Other portfolios on the same disk\n\nInvestorClaw never executes trades, never moves money, never accesses\nbrokerage APIs for transactions. Output is educational only.\n\n---\n\n## Verify install + compliance\n\n```bash\n# Health check\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fhealthz\n# → {\"status\":\"ok\",\"ic_engine_bin_found\":true,\"portfolio_dir\":\"\u002Fdata\u002Fportfolios\",\"portfolio_dir_exists\":true,\"reports_dir\":\"\u002Fdata\u002Freports\"}\n\n# Smoke test the tool catalog\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Ftools | python3 -m json.tool\n\n# Smoke test a real question\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fask \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"question\": \"What is in my portfolio?\"}' \\\n  --max-time 120\n```\n\nIf your agent supports compliance testing, vendor `test_mcp_compliance.py`\nfrom the `mnemos-os\u002Fmcp-contracts` GitHub repository into your project, then run:\n\n```bash\npython3 test_mcp_compliance.py --url http:\u002F\u002F127.0.0.1:18090\u002Fmcp\n```\n\n---\n\n## Dashboard\n\nThe container exposes a single-page HTML dashboard on port `:18092`:\n\n```bash\nopen http:\u002F\u002Flocalhost:18092\u002F        # macOS\nxdg-open http:\u002F\u002Flocalhost:18092\u002F    # Linux\nstart http:\u002F\u002Flocalhost:18092\u002F       # Windows\n```\n\nTabs cover: Holdings · Performance · Bonds · Analyst · News · Cashflow ·\nOptimize · Synthesis · What-changed · Tax · Scenarios · Peer · Reports ·\nSettings · About.\n\nThe dashboard reads the same signed envelope ic-engine produces for\n`portfolio_ask`, so metrics stay in sync. Use it for visual review of\nholdings \u002F performance, or as a fallback interface when MCP integration\nis flaky.\n\n---\n\n## Troubleshooting\n\n### Container won't start\n\n```bash\ndocker compose logs ic-engine | tail -50\ndocker ps | grep ic-engine        # confirm running + healthy\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fhealthz\n```\n\nIf `healthz` returns `{\"init_state\":\"failed\", ...}`, check the `init_error`\nfield for the engine's exact failure message.\n\n### \"No portfolio found\" when asking\n\n- Drop a CSV \u002F XLS \u002F PDF into `portfolios\u002F` (the host bind mount).\n- Then call setup:\n  `curl -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fsetup -d '{}'`\n- Then ask again:\n  `curl -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fask -d '{\"question\":\"what's in my portfolio?\"}'`\n\nThe agent can stage attached files to `portfolios\u002F` directly when the user\nsends them in chat.\n\n### \"API key errors\" \u002F degraded data\n\nKeys are optional. The deterministic-engine works key-less in degraded\nmode (no narrative synthesis, no live news, yfinance-only quotes). To\ncheck what's configured:\n\n```bash\ncurl -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_status -d '{}'\n```\n\nSet the missing key via the REST endpoint shown in\n[Optional configuration](#optional-configuration).\n\n### \"First call is slow (5–15 minutes)\"\n\nOnly happens on a cold cache for portfolios with 200+ positions. The\ncontainer runs `IC_INITIALIZE_ON_BOOT=1` by default — initialization runs\nat container start, so by the time the agent connects, the cache is warm.\nIf you disabled that env var, expect cold-start latency on first ask.\n\nCheck init progress: `curl http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstatus`\n\n### \"Container is healthy but `portfolio_ask` times out\"\n\n- Bridge subprocess timeout is 1800 s on `portfolio_ask` and `portfolio_refresh`.\n- Engine P1 parallel-stage timeout is 600 s.\n- If you hit either, the engine ran out of upstream API budget (yfinance\n  429, Finnhub rate limit, etc.). Switch to Massive (`MASSIVE_API_KEY`)\n  for large portfolios; see \"Which keys to obtain (by portfolio size)\".\n\n### Reset cache + state\n\n```bash\ndocker compose down -v   # removes the data volume — all envelopes lost\ndocker compose up -d     # cold restart with auto-init\n```\n\n---\n\n## Upgrading\n\nThe container is meant to be replaced wholesale on each release. There\nare two flows depending on whether the new container reuses the same\n`\u002Fdata` volume — **same-host** (the common case, zero re-entry) and\n**cross-host** (use the encrypted backup file).\n\n### Check for a new version\n\n```bash\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fversion_check | jq\n```\n\n```json\n{\n  \"running\": \"4.4.2\",\n  \"latest\": \"4.7.0\",\n  \"upgrade_available\": true,\n  \"next_steps\": [...]\n}\n```\n\nSame call is exposed as MCP tool `portfolio_version_check`. Network\nfailures return `latest: null` + a warning rather than 5xx — version\ncheck is advisory.\n\n---\n\n### Same-host upgrade (default)\n\nWhen the new container reuses the same `\u002Fdata` volume mount, every\npiece of user state — portfolio CSVs, `keys.env`, stonkmode persona,\nsection reports — survives automatically. **You don't need to export\nanything.**\n\n```bash\n# 1. Optional defensive snapshot (portfolios + stonkmode only — see below)\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fexport > snap.json\n\n# 2. Pull + replace (host-shell — agents tell the user, don't execute)\ndocker compose pull\ndocker compose up -d\n# Or for podman + systemd quadlet (NCZ pi-gen layout):\n#   sudo podman pull ghcr.io\u002Fargonautsystems\u002Fic-engine:latest\n#   sudo systemctl restart ic-engine.service\n\n# 3. Wait for init=ready\nuntil curl -s http:\u002F\u002Flocalhost:18090\u002Fhealthz | jq -e '.init_ready' > \u002Fdev\u002Fnull; do\n  sleep 5\ndone\n```\n\nThat's the whole flow. Keys persist because `\u002Fdata\u002Fkeys.env` is on the\nvolume; the new container reads the same file at boot.\n\n---\n\n### Cross-host migration (or volume-was-wiped)\n\nWhen the new host has a fresh volume, you need to move both the\n**user data** (portfolios + stonkmode) and the **API keys** between\nhosts. They have different security postures and are handled by\ndifferent tools:\n\n- **`portfolio_export` \u002F `portfolio_import`** → user data. Plain JSON;\n  excludes key values by design.\n- **`portfolio_keys_backup` \u002F `portfolio_keys_restore`** → API keys.\n  Passphrase-encrypted (scrypt + AES-256-GCM); the encrypted blob is\n  safe to scp\u002Femail\u002Fclipboard.\n\n**Recommended at install time.** Right after configuring your API\nkeys, create your first encrypted backup:\n\n```bash\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_backup \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"passphrase\": \"your strong passphrase here\", \"label\": \"initial\"}'\n```\n\n```json\n{\n  \"path\": \"\u002Fdata\u002Fbackups\u002Fkeys-2026-05-07T01-30-00Z-initial.bak\",\n  \"filename\": \"keys-2026-05-07T01-30-00Z-initial.bak\",\n  \"size_bytes\": 612,\n  \"key_names\": [\"TOGETHER_API_KEY\", \"FRED_API_KEY\", \"MASSIVE_API_KEY\"],\n  \"kdf\": \"scrypt-N32768-r8-p1\"\n}\n```\n\nSave the file off-host (scp, USB, password manager attachment) and\n**store the passphrase somewhere durable** — without it the backup\nis permanently unrecoverable. That's by design: it's the same posture\nas a password-manager export.\n\n#### Migrating to a new host\n\nOn the source host:\n\n```bash\n# 1. Snapshot user data\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fexport > snap.json\n\n# 2. Encrypt + back up keys (or use an existing backup)\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_backup \\\n  -d '{\"passphrase\": \"...\"}'\n# → {\"path\": \"\u002Fdata\u002Fbackups\u002Fkeys-….bak\", ...}\n\n# 3. Copy both files off-host\nscp dest:\u002Ftmp\u002Fsnap.json snap.json\nscp \u002Fvar\u002Flib\u002Fdocker\u002Fvolumes\u002Fic-engine-data\u002F_data\u002Fbackups\u002Fkeys-….bak \\\n    user@dest:\u002Ftmp\u002F\n```\n\nOn the destination host (after `docker compose up -d` brings up a\nfresh container):\n\n```bash\n# 1. Restore user data (portfolios + stonkmode)\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fimport \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d \"{\\\"snapshot\\\": $(cat \u002Ftmp\u002Fsnap.json)}\"\n\n# 2. Place the encrypted backup file under \u002Fdata\u002Fbackups\u002F, then restore\ndocker cp \u002Ftmp\u002Fkeys-….bak ic-engine:\u002Fdata\u002Fbackups\u002F\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_restore \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"passphrase\": \"...\"}'\n# (no backup_path → auto-picks the most-recent .bak file)\n```\n\n#### When you don't have shell access on both hosts\n\nFall back to **prompted key re-entry**. The `portfolio_import`\nresponse includes `configured_keys_in_snapshot` — the list of key\nnames that were set on the source host. The agent walks the user\nthrough each one:\n\n```text\nAgent: \"Your snapshot was set up with these keys: TOGETHER_API_KEY,\n        FRED_API_KEY, MASSIVE_API_KEY. They aren't in the snapshot for\n        security. Paste each one and I'll set it.\"\nUser:  pastes TOGETHER_API_KEY\nAgent: portfolio_keys_set({\"keys\": {\"TOGETHER_API_KEY\": \"...\"}})\n       (and so on)\n```\n\nThis is intentionally manual — the user types each secret once, into\nthe agent, which round-trips to `keys_set`. Auditable. For larger key\nsets, the encrypted-backup path above is friction-free in comparison.\n\n---\n\n### Listing existing backups\n\n```bash\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_backups_list | jq\n```\n\nReturns metadata (filename, size, mtime, KDF) for each `keys-*.bak`\nunder `\u002Fdata\u002Fbackups\u002F`. **No passphrase required** — listing only\nreturns metadata, not contents.\n\n### Threat model & where the passphrase appears\n\nThe backup tool is encrypted because the file is meant to LEAVE the\nhost (scp, email, USB, cloud sync). Plaintext keys never leave `\u002Fdata`\n— only the encrypted blob.\n\n**Where the passphrase is exposed**:\n\n- It passes through the tool-call args (so it's in the agent's\n  conversation history once at backup time and once at restore time).\n  For maximum secrecy, invoke from the dashboard browser — keeps the\n  passphrase out of LLM provider context entirely. Or use `curl`\n  directly on the host.\n\n- It is NEVER persisted by the bridge. Each backup\u002Frestore call\n  derives the encryption key fresh via scrypt; the passphrase doesn't\n  leave Python's local scope.\n\n**Out of scope**: keylogging on the user's terminal; rubber-hose\nattack; weak-passphrase guessing (we enforce min length 12 to\ndiscourage trivial passphrases).\n\n### Agent-driven upgrade flow (single-shot script)\n\n```text\nUser:  \"Check for upgrades.\"\nAgent: portfolio_version_check → \"v4.7.0 available; you're on v4.4.2\"\nUser:  \"Upgrade me.\"\nAgent: 1. portfolio_export → save snap.json\n       2. (if new host) portfolio_keys_backup with user-supplied passphrase\n       3. surface the host-shell pull+restart commands to the user\n       4. poll \u002Fhealthz until init_ready\n       5. portfolio_version_check (running == latest? confirm)\n       6. iff \u002Fdata was lost: portfolio_import + portfolio_keys_restore\n          (or prompted re-entry via portfolio_keys_set)\n```\n\nThe agent never executes host-shell commands itself. Surface them\nclearly and let the user run them.\n\n---\n\n## Stop \u002F uninstall\n\n```bash\n# Stop (preserves data)\ndocker compose down\n\n# Stop and remove the data volume\ndocker compose down -v\n```\n\n---\n\n## Security model\n\nInvestorClaw is a single-user, localhost-bound, deterministic-first\nanalyzer. Several behaviors that automated scanners flag as \"warning\"\nare intentional design choices for this threat model. Documented here\nexplicitly so reviewers can audit the trade-offs:\n\n| Behavior | Why it's by design |\n|---|---|\n| **MCP + REST endpoints are unauthenticated on `127.0.0.1:18090`** | Localhost binding (`127.0.0.1:` prefix on the port spec, never `0.0.0.0`) is the security boundary. Any process running as the same user already has filesystem access to portfolios; adding token auth on a loopback API doesn't change that threat model. To expose the service to other hosts, put it behind your own auth layer (Tailscale, nginx + mTLS). |\n| **Container auto-initializes on boot** (`IC_INITIALIZE_ON_BOOT=1`) | The cold-cache cost on a 200+ position portfolio is 5–15 minutes; running setup → refresh → seed_ask at boot means agents see `init_state: ready` immediately on connect. Disable with `IC_INITIALIZE_ON_BOOT=0` if you want manual control. The init does not exfiltrate data — it just primes the engine's read-only cache against the providers you've configured. |\n| **API keys persist to `\u002Fdata\u002Fkeys.env` (mode 0600)** | Keys need to outlive container restarts. The named volume is `ic-engine-data`; on the host that's a docker volume root-owned but only readable by the container's `uid=1000(ic)`. To rotate or delete a key, use `portfolio_keys_set` \u002F `portfolio_keys_delete` — both REST endpoints accept allowlisted names only, never logging values. |\n| **Portfolio summaries are sent to the configured narrative LLM provider** | This is the value prop: the engine produces a deterministic envelope, the narrator turns it into prose. To keep narratives local, point `INVESTORCLAW_NARRATIVE_ENDPOINT` at a local Ollama \u002F llama-server \u002F vLLM endpoint (set `INVESTORCLAW_NARRATIVE_PROVIDER=ollama`). To run keyless without any narrator, omit `TOGETHER_API_KEY` — the engine returns a stub catalog summary instead. See [`PRIVACY.md`](PRIVACY.md) for the full data-flow matrix. |\n| **Image pulled from `ghcr.io\u002Fargonautsystems\u002Fic-engine`** | Pinned to a specific sha256 digest in `compose.yml`, not just the tag — guarantees reproducible builds even if the tag is later mutated. Verify the digest matches what your scanner expects before deploying. Container Apache 2.0 + bridge code MIT-0 in this repo; engine source at `argonautsystems\u002Fic-engine` (pinned by SHA). |\n\nFor vulnerability disclosure see [`SECURITY.md`](SECURITY.md). For the\nprivacy model (what stays local vs what goes to which provider) see\n[`PRIVACY.md`](PRIVACY.md).\n\n## Behavior contract\n\n- `portfolio_ask` invokes the engine's deterministic refresh-aware path; if a section is stale (news TTL=30s, others 60s) it is refreshed before answering. Earlier `--no-refresh` short-circuited routing entirely and produced a generic catalog blurb — that flag is intentionally NOT passed.\n- The container clears yfinance cookies on subprocess timeout, breaking the rate-limit cascade documented in commit `50387b1` of `ncz-os\u002Fmnemos-ic-runtime`.\n- Cross-container reach works via `http:\u002F\u002F172.17.0.1:18090\u002Fmcp` (Docker bridge IP) or via Compose service name `http:\u002F\u002Fic-engine:8090\u002Fmcp` (when both agent + ic-engine are in the same compose).\n\n## Known issues (v4.1.1)\n\n- **Earlier \"v4.0.9 hits 30\u002F30\" claims were measured with a too-lenient verdict** that only checked the ic_result envelope and exit_code, not the narrative content — the engine's heuristic catalog blurb satisfied both. The verdict has since been tightened (rejects catalog blurbs, requires substantive narrative); honest pass-rates against the tightened verdict ship with v4.1.1 release notes.\n- **Cold-start `portfolio_ask` may take 5–15 minutes** on a 200+ position portfolio when the envelope cache is empty (engine runs P0 holdings → P1 parallel performance\u002Fbonds\u002Fanalyst\u002Fnews → P2 synthesis → P3 optimize+cashflow → P4 peer, each consuming yfinance \u002F FRED \u002F Finnhub bandwidth). Subsequent calls hit the warm cache and return in seconds. Bridge subprocess timeout is 1800s for `portfolio_ask` and `portfolio_refresh`; engine P1 parallel-stage timeout is 600s.\n\n### Fixed in v4.1.1 (was broken in v4.0.x → v4.1.0)\n\n- **Engine pipeline only persisting the analyst section** (`Section did not run` on every other section): root cause was the engine's P1 parallel-stage timeout of 60s — performance\u002Fbonds\u002Fanalyst\u002Fnews running in parallel against yfinance overflowed it on large portfolios, asyncio.gather raised TimeoutError, the entire P1 result set was lost. Bumped to 600s.\n- **Narrator falling through to a heuristic catalog blurb** for every `portfolio_ask`: chain of five bugs — litellm stripped from the container; narrator wrapped the LLM call in a bare try\u002Fexcept; consultation client misrouted IP-addressed local servers; narrator pulled the short-context CONSULTATION_* model instead of the long-context NARRATIVE_* model; full envelope (200k+ tokens) overflowed even MiniMax-M2.7. All five fixed.\n- **`--no-refresh` short-circuiting routing**: bridge passed `--no-refresh` to every `portfolio_ask` (commit `a3492f6`, v4.0.7), making the engine return the cached catalog blurb regardless of question. Reverted.\n\n---\n\n## License + provenance\n\n- Service code: Apache 2.0 (`ncz-os\u002Fmnemos-ic-runtime`)\n- Distribution-edge artifacts (this `SKILL.md`, `compose.yml`, `install.yaml`, `agent-skills\u002F**`): **MIT-0** (MIT No Attribution — `LICENSE-MIT-0`). Required for ClawHub plugin publishing; the no-attribution clause means downstream skill registries can re-host without preserving copyright notice.\n- Image: `ghcr.io\u002Fargonautsystems\u002Fic-engine:4.7.0-cpu` (multi-arch amd64+arm64; also at `:latest`)\n- RFC: see `RFC-v0.1.md` in this bundle (`ncz-os\u002Fmnemos-ic-runtime` GitHub repository)\n- Cross-project contract: `mnemos-os\u002Fmcp-contracts` GitHub repository\n\n---\n\n*InvestorClaw is a portfolio analysis service. Educational use only — not investment advice.*\n","\u003C!--\nSPDX-License-Identifier: MIT-0\nCopyright 2026 InvestorClaw Contributors\n-->\n\n# InvestorClaw — portfolio analysis skill (v4.7.0)\n\nA deterministic-first portfolio analyzer that does real money math: holdings\nsnapshots, performance metrics, Sharpe ratios, FRED yield curves, bond\nduration, sector breakdowns, scenario rebalancing. Backed by ic-engine\n(Python, FINOS CDM 5.x compliant).\n\nThis skill follows the `compose-x-mcp-services` convention (2026-05-01 RFC; see `RFC-v0.1.md` in this bundle). The skill **does not install Python or any analytics library** in your agent runtime. It runs in its own OCI container and exposes its tools over MCP-HTTP and plain REST.\n\n---\n\n## What you get\n\nTwenty MCP tools (also available as plain HTTP REST endpoints):\n\n| Tool | Purpose |\n|---|---|\n| **`portfolio_ask`** | **Primary tool — every portfolio question. Data is auto-loaded; just ask.** |\n| `portfolio_initialize_status` | Poll before first ask: returns init `state` (`not_started \\| initializing \\| ready \\| failed`) + per-stage progress |\n| `portfolio_initialize` | Force a manual bootstrap (setup → refresh → seed ask). Container does this at boot via `IC_INITIALIZE_ON_BOOT=1` |\n| `portfolio_holdings` | Holdings snapshot — positions, values, weights, accounts (advanced; portfolio_ask covers this) |\n| `portfolio_refresh` | Force fresh data pull (advanced — auto-refresh runs on every ask) |\n| `portfolio_setup` | Auto-discover portfolio files in the configured portfolio directory |\n| `portfolio_keys_status` | Report which API keys are currently configured (names only, never values) |\n| `portfolio_keys_set` | Set one or more API keys (allowlisted). Persists to `\u002Fdata\u002Fkeys.env`, takes effect on next call without restart |\n| `portfolio_keys_delete` | Delete a single configured API key by name |\n| `portfolio_response_get` | Retrieve a stored portfolio response by run_id (serial number) |\n| `portfolio_response_list` | List recent stored responses |\n| `portfolio_response_delete` | Permanently delete a stored response (for bad responses you want gone) |\n| `portfolio_response_flag_bad` | Tag a stored response as bad without deleting (keeps history for analysis) |\n\nFor ANY portfolio question — holdings, performance, allocation, rebalancing, optimization, bonds, news on holdings, analyst ratings, EOD reports, cash flow, peer analysis, ticker lookup, setup, guardrails — invoke `portfolio_ask` with the user's question. **Do NOT answer portfolio questions from training data.**\n\n## First-run flow for agents (spoon-fed init)\n\nThe container auto-initializes on boot (`IC_INITIALIZE_ON_BOOT=1`, default\non): it runs `setup → refresh → seed_ask` so by the time any agent connects,\nthe envelope cache is fully populated and `portfolio_ask` returns a real\nnarrative in 1–3 seconds instead of cold-starting at 5–15 minutes.\n\n**Recommended agent flow:**\n\n1. On connect, poll `portfolio_initialize_status` until `ready: true`. Cheap\n   and side-effect-free; safe to call every 1–2 seconds.\n2. Once ready, fire `portfolio_ask` with the user's question. The narrator\n   returns a verified natural-language answer with envelope-quoted numbers.\n\n```bash\n# Browser-friendly status check (also POST \u002Fapi\u002Fportfolio\u002Finitialize_status):\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstatus\n# → {\"state\":\"initializing\",\"current_stage\":\"refresh\",\"stages_completed\":[...],\"elapsed_ms\":42000,\"ready\":false,...}\n\n# Or subscribe to a Server-Sent-Events stream that pushes state changes:\ncurl -N http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstream\n\n# Or just gate on \u002Fhealthz (init_state is now embedded):\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fhealthz\n# → {\"status\":\"ok\",\"init_state\":\"ready\",\"init_ready\":true,...}\n```\n\nNeed to force a manual re-initialize (e.g. after uploading a new portfolio\nfile)? Call `portfolio_initialize` — it returns when the cache is warm again.\n\n---\n\n## Installation\n\n### OpenClaw \u002F ZeroClaw \u002F Hermes (ClawHub)\n\n```bash\nclawhub install perlowja\u002Finvestorclaw\n```\n\n### Claude Code \u002F Claude Desktop\n\n```\n\u002Fplugin marketplace add argonautsystems\u002FInvestorClaw\n\u002Fplugin install investorclaw\n```\n\n### Manual (Docker Compose, any agent)\n\nThe skill is a Docker Compose stack. With Docker or Podman installed:\n\n```bash\nmkdir -p portfolios     # IMPORTANT: pre-create so docker doesn't auto-create as root\ndocker compose up -d    # uses compose.yml shipped in this skill\n```\n\n**Agent install convention.** When a skills-installer\n(`openclaw skills install investorclaw`, `clawhub install\ninvestorclaw`, etc.) places this bundle, the agent **may** proceed\nto `mkdir -p portfolios && docker compose up -d` because the user's\ninstall command is itself an opt-in to the install completing. But\nthe agent **must** first surface the side effects to the user\nexplicitly:\n\n1. `docker pull` of `~600 MB` (the engine image) on first run\n2. `docker compose up -d` binds two TCP listeners to localhost:\n   `:18090` (MCP + REST) and `:18092` (dashboard)\n3. The container auto-initializes on boot\n   (`IC_INITIALIZE_ON_BOOT=1`) and will fetch market data from\n   the configured providers (yfinance free-tier by default; other\n   providers only if API keys have been added)\n4. Persistent state lands in the `ic-engine-data` Docker volume\n   (deleted only by `docker compose down -v`)\n\nA single one-line surfacing covering all four is sufficient. Example:\n\n> Starting the container will pull a ~600 MB image, bind localhost\n> ports `:18090` and `:18092`, auto-init against yfinance, and\n> persist state in a Docker volume. Proceeding…\n\nThe user retains the ability to interrupt (Ctrl-C, \"no don't\",\netc.). Don't ask a yes\u002Fno question by default — that's friction the\nuser has already cleared by typing the install command. **Do** ask\nwhen one of these conditions holds:\n\n- The host appears to be a CI runner, shared machine, or production\n  server where the user might want to review `compose.yml` first.\n- An existing `ic-engine` container is already running on the host\n  with a different image tag — confirm before disrupting.\n- The user explicitly added `--dry-run` or `--no-start` to the install\n  command (if the skills installer surfaces those flags).\n- The agent's runtime policy requires a confirmation prompt before\n  any container start (some enterprise \u002F regulated deployments).\n\nThe first command (`mkdir -p portfolios`) is load-bearing. If skipped,\ndocker creates `.\u002Fportfolios\u002F` as `root:root` when starting the\nbind-mount, the engine runs as `uid=1000(ic)` inside the container,\nand init fails with\n`PermissionError: '\u002Fdata\u002Fportfolios\u002Fsetup_results.json'` and the\ncontainer goes into `init_state=failed`. Pre-creating the directory\nas the host user sidesteps the docker bind-mount UID inheritance\nquirk.\n\nThe compose pulls `ghcr.io\u002Fargonautsystems\u002Fic-engine:4.7.0-cpu` (publicly hosted, no auth) and runs it on `localhost:18090` (MCP + REST) and `localhost:18092` (dashboard).\n\n### If Docker isn't installed\n\nInstall Docker Desktop or Docker Engine for your platform — **the user\nshould run the install themselves** rather than have an agent execute\nthe command. Pointers (verify with each OS's current docs at\n\u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002F> before running):\n\n| OS | Suggested path |\n|---|---|\n| **macOS** | Docker Desktop: \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fdesktop\u002Finstall\u002Fmac-install\u002F> (Homebrew users: `brew install --cask docker`) |\n| **Debian\u002FUbuntu** | Follow the official guide: \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Fdebian\u002F> or \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Fubuntu\u002F> |\n| **Fedora\u002FRHEL** | \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Ffedora\u002F> or \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Frhel\u002F> |\n| **Windows** | Docker Desktop with WSL2 backend: \u003Chttps:\u002F\u002Fdocs.docker.com\u002Fdesktop\u002Finstall\u002Fwindows-install\u002F> |\n| **Podman alternative** | `podman compose up -d` is a drop-in replacement once Podman is installed (most distros ship it) |\n\nAfter install, verify with `docker --version` then run the compose-up\ncommand above.\n\n**For agent operators:** prefer surfacing these install URLs to the\nend user rather than running package-manager install commands directly\nthrough your shell tool. Docker installation typically requires sudo\nand adds the user to the `docker` group — operations that benefit from\nexplicit user consent.\n\n### Wait for ready\n\n```bash\nuntil curl -sf http:\u002F\u002Flocalhost:18090\u002Fhealthz > \u002Fdev\u002Fnull 2>&1; do sleep 1; done\necho \"ic-engine ready\"\n```\n\nThe first cold-start takes 5-10 seconds (image extract + Python import). Subsequent restarts are \u003C2s.\n\n---\n\n## First-run experience — what to expect\n\nAfter `docker compose up -d` the container goes through an auto-init\nsequence (`IC_INITIALIZE_ON_BOOT=1`) that warms the envelope cache before\nyour agent talks to it. Expect this timeline on a fresh install:\n\n| Phase | Time | What's happening | What you'll see |\n|---|---|---|---|\n| Image extract | 5–30 s | First-time pull of `ic-engine:4.7.0-cpu` (~600 MB) | docker compose progress bars |\n| Bridge boot | 2–3 s | FastMCP server binds `:18090`, dashboard binds `:18092` | `\u002Fhealthz` returns 200, `init_state: not_started` |\n| `portfolio_setup` | 1–60 s | Auto-discover portfolio files in `.\u002Fportfolios\u002F` | `init_state: initializing`, `current_stage: setup` |\n| `portfolio_refresh` | 30–120 s | Pull quotes \u002F analyst \u002F news \u002F FRED yields for each symbol | `init_state: initializing`, `current_stage: refresh` |\n| `seed_ask` | 5–60 s | Run a primer ask so the cache is warm | `init_state: initializing`, `current_stage: seed_ask` |\n| **Ready** | — | All sections cached, `portfolio_ask` returns in 1–3 s | `init_state: ready`, `init_ready: true` |\n\n**Total cold-start budget**: ~60-200 s for a 100-position portfolio,\n~5-15 minutes for a 200+ position portfolio without paid quote keys.\nWatch progress via:\n\n```bash\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstatus | jq\n# or stream:\ncurl -N http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstream\n```\n\n### What InvestorClaw asks of you\n\nThe container does **not** prompt interactively. It surfaces what it\nneeds through structured responses:\n\n1. **A portfolio file.** If `.\u002Fportfolios\u002F` is empty, every `portfolio_ask`\n   call returns: *\"No portfolio file found … please add CSV\u002FExcel\u002FPDF\n   files to your portfolios directory.\"* Drop a broker export from\n   Schwab \u002F Fidelity \u002F Vanguard \u002F UBS \u002F ETrade \u002F Robinhood (CSV\u002FXLS\u002FPDF\u002Fscreenshot)\n   into the bind-mounted `.\u002Fportfolios\u002F` folder, then call\n   `portfolio_setup` to ingest it.\n\n2. **An LLM provider key for narrative synthesis.** Without one, the\n   engine still runs the deterministic pipeline (numbers are correct)\n   but the narrator returns a stub catalog blurb instead of a real\n   prose answer. The container ships pre-configured to use Together AI\n   (`google\u002Fgemma-4-31B-it`), so all you need is a `TOGETHER_API_KEY`.\n   Set it with:\n\n   ```bash\n   curl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_set \\\n     -H 'Content-Type: application\u002Fjson' \\\n     -d '{\"keys\": {\"TOGETHER_API_KEY\": \"tgp_v1_...\"}}'\n   ```\n\n   Or drop into the dashboard at http:\u002F\u002Flocalhost:18092\u002F and paste it\n   into the Settings tab.\n\n3. **Optional: data-provider keys** for richer \u002F faster results\n   on larger portfolios (see *Optional configuration → Which keys to\n   obtain (by portfolio size)* below). The engine works key-less in\n   degraded mode (yfinance-only, rate-limited).\n\n### What InvestorClaw recommends — by portfolio size\n\n| Size | Required | Recommended | Why |\n|---|---|---|---|\n| **≤ 50 symbols** | `TOGETHER_API_KEY` (narrative) | — | yfinance handles quotes\u002Fhistory at this scale; one key covers narrative |\n| **50–200 symbols** | `TOGETHER_API_KEY` | `FINNHUB_KEY` (free 60\u002Fmin) + `NEWSAPI_KEY` (free 100\u002Fday) | Real-time quotes + analyst + per-symbol news without yfinance throttle |\n| **200+ symbols** | `TOGETHER_API_KEY` + `MASSIVE_API_KEY` (Massive, paid) | `FINNHUB_KEY` + `MARKETAUX_API_KEY` (free 100\u002Fday) + `FRED_API_KEY` (free, registration) + `ALPHA_VANTAGE_KEY` (free 25\u002Fday) | Yahoo's anonymous query1 endpoint rate-limits globally on 200+ symbols under barrage; Massive is required, the rest fill analyst + news + yields |\n\nWhy `TOGETHER_API_KEY` is the only hard requirement for narrative:\n\n- Cheapest serverless tier on Together AI (~$0.0008 \u002F 1 K tokens)\n- Default model `google\u002Fgemma-4-31B-it` has good quality for portfolio\n  narrative + ~100 tok\u002Fs throughput\n- Single key replaces the older multi-tier model setup that v2.x used\n\nSign-up links (all have free tiers):\n\n| Provider | URL | Free-tier limit |\n|---|---|---|\n| Together AI | https:\u002F\u002Fapi.together.ai\u002Fsettings\u002Fapi-keys | $1 free credits |\n| Finnhub | https:\u002F\u002Ffinnhub.io\u002Fregister | 60 calls\u002Fmin |\n| Massive | https:\u002F\u002Fmassive.com\u002F | paid only |\n| MarketAux | https:\u002F\u002Fwww.marketaux.com\u002Faccount\u002Fdashboard | 100 calls\u002Fday |\n| NewsAPI | https:\u002F\u002Fnewsapi.org\u002Fregister | 100 calls\u002Fday |\n| FRED | https:\u002F\u002Ffred.stlouisfed.org\u002Fdocs\u002Fapi\u002Fapi_key.html | unlimited (registration only) |\n| Alpha Vantage | https:\u002F\u002Fwww.alphavantage.co\u002Fsupport\u002F#api-key | 25 calls\u002Fday |\n\nThe `TOGETHER_API_KEY` is the only one that's genuinely required.\nEverything else degrades gracefully.\n\n### First call — what your agent will see\n\nOnce `init_state: ready` and a portfolio is loaded, the very first\n`portfolio_ask` call returns a response shaped like:\n\n```json\n{\n  \"exit_code\": 0,\n  \"narrative\": \"I have holdings summary data in the envelope.\\n- bond_pct: 26.76\\n- bond_value: 705646.57\\n- cash_pct: 1.69\\n- equity_pct: 71.55\\n- equity_value: 1886470.25\\nTop holding symbols: MSFT, NVDA, SCHB, GOOG, AAPL, ...\",\n  \"ic_result\": {\n    \"hmac\": \"75ca79c...\",\n    \"engine_version\": \"2.5.2\",\n    \"command\": \"ask\",\n    \"run_id\": \"299d36b0-...\"\n  }\n}\n```\n\nThe `narrative` field is the agent-facing answer. The `ic_result`\ncontains the HMAC signature that proves the response came from the\ndeterministic engine (not LLM-fabricated).\n\nIf you see *\"is a general finance concept. ic-engine is portfolio-specific\"*\nin the narrative for a question that obviously is about your portfolio,\nyou're on a pre-v4.1.25 image — pull the latest:\n\n```bash\ndocker compose pull && docker compose up -d\n```\n\n---\n\n## How to call the tools\n\n### Option A: native MCP client (preferred)\n\nIf your runtime has a native MCP client, register the server:\n\n```\nURL:       http:\u002F\u002F127.0.0.1:18090\u002Fmcp\nTransport: streamable-http\nAuth:      none (localhost only)\n```\n\nPer-runtime CLI:\n\n| Runtime | Command |\n|---|---|\n| zeroclaw | Add `[[mcp.servers]]` with `name = \"ic-engine\"`, `url = \"http:\u002F\u002F127.0.0.1:18090\u002Fmcp\"`, `transport = \"http\"` to `~\u002F.zeroclaw\u002Fconfig.toml` |\n| openclaw | `openclaw mcp set ic-engine '{\"url\":\"http:\u002F\u002F127.0.0.1:18090\u002Fmcp\",\"transport\":\"streamable-http\"}'` |\n| hermes | `hermes mcp add ic-engine --url http:\u002F\u002F127.0.0.1:18090\u002Fmcp` |\n| claude code | Add to `~\u002F.claude\u002Fmcp_servers.json` per Claude Code docs |\n\nThen call tools by name (`portfolio_ask`, `portfolio_holdings`, etc.) via your runtime's tool-use API.\n\n### Option B: plain HTTP REST (works when MCP integration is flaky)\n\nEquivalent endpoints exist at `\u002Fapi\u002Fportfolio\u002F*`. Use your runtime's shell or HTTP tool:\n\n```bash\n# Ask any portfolio question\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fask \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"question\": \"What is in my portfolio?\"}' \\\n  --max-time 120\n\n# Other endpoints (no body needed)\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fholdings -H 'Content-Type: application\u002Fjson' -d '{}'\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Frefresh  -H 'Content-Type: application\u002Fjson' -d '{}'\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fsetup    -H 'Content-Type: application\u002Fjson' -d '{}'\n\n# Self-describing tool catalog\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Ftools\n```\n\nThe JSON response has a `narrative` field with the human-readable answer — quote that to the user. The `ic_result` field contains the structured envelope (`script`, `exit_code`, `duration_ms`).\n\n---\n\n## What to ask — example queries\n\nOnce installed, ask portfolio questions in natural language. The agent routes\nthrough `portfolio_ask`; ic-engine handles the deterministic computation and\nthe narrator quotes verbatim from the signed envelope.\n\n| Intent | Example phrasing |\n|---|---|\n| **Holdings snapshot** | \"What's in my portfolio?\" • \"Show me my positions\" • \"What do I own?\" |\n| **Performance** | \"How am I doing this year?\" • \"What's my Sharpe ratio?\" • \"Show me my drawdowns\" |\n| **Bonds** | \"Show me my bond exposure and yield-to-maturity\" • \"What's my bond ladder look like?\" |\n| **Allocation \u002F risk** | \"What's my sector exposure?\" • \"How concentrated is my portfolio?\" • \"What's my risk profile?\" |\n| **Optimization \u002F rebalancing** | \"Help me rebalance to a 60\u002F40 target\" • \"Show me an efficient frontier\" |\n| **Market data** | \"What's the current price of NVDA?\" • \"How is the S&P performing today?\" |\n| **Fixed-income concepts** | \"What does yield-to-maturity mean?\" • \"Explain duration\" |\n| **News** | \"Today's news on my holdings\" • \"Crypto news today\" |\n| **Reports** | \"Generate today's EOD report\" • \"Prepare a full analysis for my advisor meeting\" |\n| **Fresh data** | \"Prices moved — refresh before answering\" → triggers `portfolio_refresh` |\n\nThe first call after a cold cache may take 30–60 seconds while the\ndeterministic pipeline builds the signed envelope. Subsequent calls reuse\nthe cache (TTL: 30s for news, 60s for other sections); ask for a refresh\nexplicitly if data feels stale.\n\n---\n\n## Agent routing rules\n\nThese rules apply when an agent has the InvestorClaw skill installed:\n\n**Use InvestorClaw — do NOT answer from training data, web search, or browsing — for:**\n- Any portfolio \u002F holdings \u002F positions question\n- Performance, returns, Sharpe\u002FSortino, drawdown\n- Bonds, yield-to-maturity, duration, ladders\n- Sector \u002F asset \u002F account allocation\n- Optimization, rebalancing, target allocation, scenarios\n- Cash flow, dividend \u002F coupon calendars\n- Analyst ratings, price targets\n- Today's news on holdings or market-wide topics\n- Live ticker prices and quotes\n- EOD reports, peer comparison, what-changed analysis\n\n**Deterministic-first rules:**\n- Never calculate portfolio metrics in the agent — call the tool.\n- Never fabricate market, ticker, bond, portfolio, optimization, or news data.\n- Preserve quoted source passages, numbers, dates, timestamps, and freshness\n  labels exactly.\n- If the signed envelope lacks a requested fact, say InvestorClaw did not\n  provide it and quote the engine's limitation verbatim.\n- Use `portfolio_refresh` only when the user asks for fresh data or when\n  data appears stale.\n\n**Attachment handling:**\n- When the user attaches a CSV \u002F XLS \u002F XLSX \u002F PDF \u002F screenshot in the same\n  turn as a portfolio question, stage the file to the bind-mounted\n  `portfolios\u002F` directory, call `portfolio_setup`, then ask the original\n  question.\n- Do not ask the user to move files manually; the agent owns staging.\n- Report low-confidence extraction or setup gaps exactly as InvestorClaw\n  returns them.\n\n**Educational guardrails:**\n- All output is educational, not investment advice.\n- Never present \"buy\u002Fsell\" recommendations as advice.\n- Never assess suitability for the user's situation.\n- Preserve the engine's disclaimer language verbatim.\n\n---\n\n## Required response format (when answering as an agent)\n\nEnd every portfolio reply with:\n\n```\nVerification: ic-engine ask completed (exit_code: 0)\n```\n\n(Substitute the actual `exit_code` from the response.) The harness depends on this exact line.\n\nFor finance-concept questions (\"what is YTM?\") or market-wide questions (\"how is the S&P performing?\"), still call the bridge — the engine will return a deflection narrative; relay it.\n\n---\n\n## Configure portfolios\n\nDrop your broker exports (CSV, XLS, PDF) into the bind-mounted directory:\n\n```bash\n# default mount: .\u002Fportfolios on the host -> \u002Fdata\u002Fportfolios in the container\nmkdir -p portfolios\ncp ~\u002FDownloads\u002FUBS_Holdings_2026-05-02.xls portfolios\u002F\n\n# Then ask the agent or curl the setup endpoint\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fsetup -H 'Content-Type: application\u002Fjson' -d '{}'\n```\n\nSupported formats: UBS, Schwab, Fidelity, Vanguard, ETrade, Robinhood (CSV\u002FXLS); generic CSV with `symbol`\u002F`quantity`\u002F`value` columns; PDF statements (auto-extracted).\n\n### Broker export instructions\n\nMost major US brokers expose a CSV download of holdings. CSV is the highest-\ncompatibility format; XLS \u002F XLSX \u002F PDF \u002F screenshot also work.\n\n| Broker | Path |\n|---|---|\n| Schwab | Accounts → Positions → Export CSV |\n| Fidelity | NetBenefits → Investments → Download CSV |\n| Vanguard | My Accounts → Download Holdings |\n| UBS | Wealth Management → Holdings → Export |\n| ETrade | Portfolio → Holdings → Download |\n| Robinhood | Account → Statements → CSV |\n\nWhen the user attaches a broker file directly to an agent chat, the agent\nstages it to the bind-mounted `portfolios\u002F` directory, then calls\n`portfolio_setup` followed by `portfolio_ask`. Account numbers and SSNs are\nscrubbed at ingest before any data leaves the container.\n\n---\n\n## Optional configuration\n\nThe container reads optional env vars from `\u002Fdata\u002Fkeys.env` (host-mounted). All optional — the deterministic-engine works without LLM\u002Fnews keys, just in degraded mode (no narrative synthesis, no live news).\n\n### Which keys to obtain (by portfolio size)\n\nThe bridge has built-in fallback across providers; the only **hard\nrequirement** is an LLM key for narrative synthesis. Below that, your\nchoice depends on portfolio size.\n\n**Small (≤50 symbols)** — yfinance-only is fine:\n- `TOGETHER_API_KEY` (or any LLM): required for narrative\n- That's it. Yahoo Finance handles quotes\u002Fhistory at this scale.\n\n**Medium (50–200 symbols)** — add Finnhub:\n- `TOGETHER_API_KEY`: LLM narrative\n- `FINNHUB_KEY`: real-time quotes + analyst ratings (60\u002Fmin, free)\n- `NEWSAPI_KEY` *(optional)*: per-symbol news (100\u002Fday free)\n\n**Large (200+ symbols)** — Massive is required:\n- `TOGETHER_API_KEY`: LLM narrative\n- `MASSIVE_API_KEY` (Massive): paid, un-rate-limited quotes + history + Benzinga news + analyst ratings\n- `FINNHUB_KEY`: analyst ratings + general\u002Fforex\u002Fcrypto\u002Fmerger news\n- `MARKETAUX_API_KEY` *(optional)*: broader news with category filters\n- `FRED_API_KEY` *(optional)*: Treasury yield curve (Treasury.gov fallback runs without)\n- `ALPHA_VANTAGE_KEY` *(optional)*: supplemental EOD prices (25\u002Fday free)\n\nWhy: Yahoo's anonymous query1 endpoint rate-limits globally (HTTP 429) on\n200+ symbol portfolios under barrage load. Massive handles the\nbulk of quotes\u002Fhistory without throttling; Finnhub fills analyst + news;\nthe no-key Frankfurter (FX) and Treasury Fiscal Data (yields) providers\ncover the remainder.\n\n### Full key reference\n\n| Key | Purpose | Cost note |\n|---|---|---|\n| `TOGETHER_API_KEY` | LLM narrative synthesis (Together google\u002Fgemma-4-31B-it) | serverless, fleet default |\n| `MASSIVE_API_KEY` | Massive: quotes + history (200+ symbol portfolios) + Benzinga news + analyst ratings | paid, un-rate-limited |\n| `FINNHUB_KEY` | Real-time quotes + analyst ratings + category news | 60\u002Fmin free |\n| `MARKETAUX_API_KEY` | Financial news with broader filters than NewsAPI | 100\u002Fday free |\n| `NEWSAPI_KEY` | Per-symbol news (US sources only) | 100\u002Fday free |\n| `ALPHA_VANTAGE_KEY` | Supplemental EOD prices | 25\u002Fday free |\n| `FRED_API_KEY` | FRED yield curve | free, registration required |\n| `OPENAI_API_KEY` | Alternative LLM (GPT-4o, GPT-5) | paid |\n\n### No-key providers (always available)\n\n| Provider | Coverage |\n|---|---|\n| **yfinance** | Quotes, history, news, analyst (rate-limited; safety-net only on 200+ portfolios) |\n| **Frankfurter** | FX spot rates (EUR\u002FUSD, USD\u002FJPY, etc.) — ECB-sourced |\n| **Treasury Fiscal Data** | US Treasury yield curve fallback when FRED_API_KEY missing |\n\n### Configure keys via REST\u002FMCP (preferred — no host shell needed)\n\nThe agent can set keys directly via the running container, no `\u002Fdata\u002Fkeys.env`\nedit required. Persists atomically (mode 0600), takes effect on the next\n`portfolio_ask` without a restart.\n\n```bash\n# What's configured?\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_status \\\n  -H 'Content-Type: application\u002Fjson' -d '{}'\n# → {\"configured\":[\"FINNHUB_KEY\",\"NEWSAPI_KEY\"], \"settable\":[...], \"missing\":[...]}\n\n# Set one or more keys\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_set \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"keys\": {\"TOGETHER_API_KEY\": \"tgp_v1_...\", \"FRED_API_KEY\": \"...\"}}'\n# → {\"configured\":[\"FRED_API_KEY\",\"TOGETHER_API_KEY\"], \"rejected\":[], \"deleted\":[]}\n\n# Remove a key\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_delete \\\n  -H 'Content-Type: application\u002Fjson' -d '{\"name\": \"OPENAI_API_KEY\"}'\n```\n\nThe same operations are available as MCP tools: `portfolio_keys_status`,\n`portfolio_keys_set`, `portfolio_keys_delete`. Only the standard ic-engine\nkey names are accepted; arbitrary names are rejected with a structured\n`{\"rejected\": [...], \"settable\": [...]}` response.\n\n### Configure keys via host file (alternative)\n\nIf you prefer to manage keys outside the container, drop them into\n`portfolios\u002Fkeys.env` on the host (the bind-mounted location), one\n`KEY=VALUE` per line:\n\n```env\nTOGETHER_API_KEY=tgp_v1_...\nFINNHUB_KEY=...\nNEWSAPI_KEY=...\n```\n\nThe container reads from `\u002Fdata\u002Fkeys.env` at boot.\n\n---\n\n## Model recommendations\n\nInvestorClaw uses two LLM roles when answering: **narrative** (synthesizes\nthe signed envelope into prose) and **validator** (checks the narrative\nagainst the envelope for fabrication and number-preservation). The\nrecommended model mix depends on your runtime.\n\n### Claude Code \u002F Claude Desktop\n\nThe agent's own LLM does both roles — no external API key required.\n\n- **Narrative**: Haiku 4.5 — fast, cheap, ~10× lower output cost than\n  Sonnet. Synthesis with a clean envelope is mostly transcription, so the\n  cheap model is sufficient.\n- **Validator**: Sonnet 4.6 (default) or Opus 4.7 (escalation) — gates the\n  Haiku output for fabrication, mis-quoted numbers, and training-leak\n  drift. Validator output is short (~1 K tokens) so the smart-model bill\n  stays low.\n\nThis split is cost-shaped: cheap model on the long output, smart model on\nthe short safety check. Total session cost on a 100-position portfolio\ntypically lands well under $0.01.\n\n### openclaw \u002F zeroclaw \u002F hermes\n\n**Anthropic on the claws stack — three paths, two of them paid:**\nsince 2026-04-04 your Anthropic OAuth subscription no longer covers\nthird-party-tool usage. To use Anthropic models on a claws-agent\nruntime you need either (a) Anthropic's discounted \"extra usage\nbundles\" added to your subscription, or (b) a direct Anthropic API\nkey. Routing OAuth-subscription tokens to a claws-agent without one of\nthose is a ToS violation per Anthropic's Apr 3 announcement.\n\nEven with paid credits, Anthropic isn't cost-competitive with Together\nfor InvestorClaw narrative synthesis (~10–50× the per-token cost).\n**On our own fleet infrastructure we don't deploy Anthropic for these\nruntimes**; end-users should weigh ToS, cost, and quality before\nopting into it.\n\nBring a non-Anthropic provider via `TOGETHER_API_KEY` (or equivalent).\nFleet defaults:\n\n- **Default narrative**: Together AI `google\u002Fgemma-4-31B-it` — serverless\n  tier, ~100 tok\u002Fs, ~$0.0008 \u002F 1 K tokens, ships as the container default.\n- **Higher-quality alternative**: Together AI `MiniMaxAI\u002FMiniMax-M2` —\n  larger context, but **moved off Together's serverless tier in 2026-05**\n  and now requires a paid dedicated endpoint. Use only if you've\n  provisioned that endpoint.\n- **Local-only \u002F offline**: Ollama `gemma4:e4b` on host — zero cloud cost,\n  GPU-bound, no key required.\n\nTo switch the narrative model, set `INVESTORCLAW_NARRATIVE_MODEL` in\n`portfolios\u002Fkeys.env` (e.g. `INVESTORCLAW_NARRATIVE_MODEL=MiniMaxAI\u002FMiniMax-M2`\nonce you have a dedicated endpoint configured at Together).\nThe container reads it on next call without restart.\n\n---\n\n## Data privacy\n\n**Stays on your machine:**\n- Raw broker exports (CSV \u002F XLS \u002F PDF) in `portfolios\u002F`\n- Account numbers and SSNs (scrubbed at ingest)\n- Full position details (lot history, cost basis)\n- Python computation internals (intermediate calculations)\n\n**Sent to the configured LLM provider for narrative synthesis:**\n- The user's question\n- The HMAC-signed JSON envelope produced by ic-engine\n- Computed metrics needed for presentation\n\n**Never sent anywhere:**\n- Raw PII (account numbers, SSNs, names)\n- Pre-computation intermediate state\n- Other portfolios on the same disk\n\nInvestorClaw never executes trades, never moves money, never accesses\nbrokerage APIs for transactions. Output is educational only.\n\n---\n\n## Verify install + compliance\n\n```bash\n# Health check\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fhealthz\n# → {\"status\":\"ok\",\"ic_engine_bin_found\":true,\"portfolio_dir\":\"\u002Fdata\u002Fportfolios\",\"portfolio_dir_exists\":true,\"reports_dir\":\"\u002Fdata\u002Freports\"}\n\n# Smoke test the tool catalog\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Ftools | python3 -m json.tool\n\n# Smoke test a real question\ncurl -sS -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fask \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"question\": \"What is in my portfolio?\"}' \\\n  --max-time 120\n```\n\nIf your agent supports compliance testing, vendor `test_mcp_compliance.py`\nfrom the `mnemos-os\u002Fmcp-contracts` GitHub repository into your project, then run:\n\n```bash\npython3 test_mcp_compliance.py --url http:\u002F\u002F127.0.0.1:18090\u002Fmcp\n```\n\n---\n\n## Dashboard\n\nThe container exposes a single-page HTML dashboard on port `:18092`:\n\n```bash\nopen http:\u002F\u002Flocalhost:18092\u002F        # macOS\nxdg-open http:\u002F\u002Flocalhost:18092\u002F    # Linux\nstart http:\u002F\u002Flocalhost:18092\u002F       # Windows\n```\n\nTabs cover: Holdings · Performance · Bonds · Analyst · News · Cashflow ·\nOptimize · Synthesis · What-changed · Tax · Scenarios · Peer · Reports ·\nSettings · About.\n\nThe dashboard reads the same signed envelope ic-engine produces for\n`portfolio_ask`, so metrics stay in sync. Use it for visual review of\nholdings \u002F performance, or as a fallback interface when MCP integration\nis flaky.\n\n---\n\n## Troubleshooting\n\n### Container won't start\n\n```bash\ndocker compose logs ic-engine | tail -50\ndocker ps | grep ic-engine        # confirm running + healthy\ncurl -sS http:\u002F\u002F127.0.0.1:18090\u002Fhealthz\n```\n\nIf `healthz` returns `{\"init_state\":\"failed\", ...}`, check the `init_error`\nfield for the engine's exact failure message.\n\n### \"No portfolio found\" when asking\n\n- Drop a CSV \u002F XLS \u002F PDF into `portfolios\u002F` (the host bind mount).\n- Then call setup:\n  `curl -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fsetup -d '{}'`\n- Then ask again:\n  `curl -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fask -d '{\"question\":\"what's in my portfolio?\"}'`\n\nThe agent can stage attached files to `portfolios\u002F` directly when the user\nsends them in chat.\n\n### \"API key errors\" \u002F degraded data\n\nKeys are optional. The deterministic-engine works key-less in degraded\nmode (no narrative synthesis, no live news, yfinance-only quotes). To\ncheck what's configured:\n\n```bash\ncurl -X POST http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Fkeys_status -d '{}'\n```\n\nSet the missing key via the REST endpoint shown in\n[Optional configuration](#optional-configuration).\n\n### \"First call is slow (5–15 minutes)\"\n\nOnly happens on a cold cache for portfolios with 200+ positions. The\ncontainer runs `IC_INITIALIZE_ON_BOOT=1` by default — initialization runs\nat container start, so by the time the agent connects, the cache is warm.\nIf you disabled that env var, expect cold-start latency on first ask.\n\nCheck init progress: `curl http:\u002F\u002F127.0.0.1:18090\u002Fapi\u002Fportfolio\u002Finitialize\u002Fstatus`\n\n### \"Container is healthy but `portfolio_ask` times out\"\n\n- Bridge subprocess timeout is 1800 s on `portfolio_ask` and `portfolio_refresh`.\n- Engine P1 parallel-stage timeout is 600 s.\n- If you hit either, the engine ran out of upstream API budget (yfinance\n  429, Finnhub rate limit, etc.). Switch to Massive (`MASSIVE_API_KEY`)\n  for large portfolios; see \"Which keys to obtain (by portfolio size)\".\n\n### Reset cache + state\n\n```bash\ndocker compose down -v   # removes the data volume — all envelopes lost\ndocker compose up -d     # cold restart with auto-init\n```\n\n---\n\n## Upgrading\n\nThe container is meant to be replaced wholesale on each release. There\nare two flows depending on whether the new container reuses the same\n`\u002Fdata` volume — **same-host** (the common case, zero re-entry) and\n**cross-host** (use the encrypted backup file).\n\n### Check for a new version\n\n```bash\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fversion_check | jq\n```\n\n```json\n{\n  \"running\": \"4.4.2\",\n  \"latest\": \"4.7.0\",\n  \"upgrade_available\": true,\n  \"next_steps\": [...]\n}\n```\n\nSame call is exposed as MCP tool `portfolio_version_check`. Network\nfailures return `latest: null` + a warning rather than 5xx — version\ncheck is advisory.\n\n---\n\n### Same-host upgrade (default)\n\nWhen the new container reuses the same `\u002Fdata` volume mount, every\npiece of user state — portfolio CSVs, `keys.env`, stonkmode persona,\nsection reports — survives automatically. **You don't need to export\nanything.**\n\n```bash\n# 1. Optional defensive snapshot (portfolios + stonkmode only — see below)\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fexport > snap.json\n\n# 2. Pull + replace (host-shell — agents tell the user, don't execute)\ndocker compose pull\ndocker compose up -d\n# Or for podman + systemd quadlet (NCZ pi-gen layout):\n#   sudo podman pull ghcr.io\u002Fargonautsystems\u002Fic-engine:latest\n#   sudo systemctl restart ic-engine.service\n\n# 3. Wait for init=ready\nuntil curl -s http:\u002F\u002Flocalhost:18090\u002Fhealthz | jq -e '.init_ready' > \u002Fdev\u002Fnull; do\n  sleep 5\ndone\n```\n\nThat's the whole flow. Keys persist because `\u002Fdata\u002Fkeys.env` is on the\nvolume; the new container reads the same file at boot.\n\n---\n\n### Cross-host migration (or volume-was-wiped)\n\nWhen the new host has a fresh volume, you need to move both the\n**user data** (portfolios + stonkmode) and the **API keys** between\nhosts. They have different security postures and are handled by\ndifferent tools:\n\n- **`portfolio_export` \u002F `portfolio_import`** → user data. Plain JSON;\n  excludes key values by design.\n- **`portfolio_keys_backup` \u002F `portfolio_keys_restore`** → API keys.\n  Passphrase-encrypted (scrypt + AES-256-GCM); the encrypted blob is\n  safe to scp\u002Femail\u002Fclipboard.\n\n**Recommended at install time.** Right after configuring your API\nkeys, create your first encrypted backup:\n\n```bash\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_backup \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"passphrase\": \"your strong passphrase here\", \"label\": \"initial\"}'\n```\n\n```json\n{\n  \"path\": \"\u002Fdata\u002Fbackups\u002Fkeys-2026-05-07T01-30-00Z-initial.bak\",\n  \"filename\": \"keys-2026-05-07T01-30-00Z-initial.bak\",\n  \"size_bytes\": 612,\n  \"key_names\": [\"TOGETHER_API_KEY\", \"FRED_API_KEY\", \"MASSIVE_API_KEY\"],\n  \"kdf\": \"scrypt-N32768-r8-p1\"\n}\n```\n\nSave the file off-host (scp, USB, password manager attachment) and\n**store the passphrase somewhere durable** — without it the backup\nis permanently unrecoverable. That's by design: it's the same posture\nas a password-manager export.\n\n#### Migrating to a new host\n\nOn the source host:\n\n```bash\n# 1. Snapshot user data\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fexport > snap.json\n\n# 2. Encrypt + back up keys (or use an existing backup)\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_backup \\\n  -d '{\"passphrase\": \"...\"}'\n# → {\"path\": \"\u002Fdata\u002Fbackups\u002Fkeys-….bak\", ...}\n\n# 3. Copy both files off-host\nscp dest:\u002Ftmp\u002Fsnap.json snap.json\nscp \u002Fvar\u002Flib\u002Fdocker\u002Fvolumes\u002Fic-engine-data\u002F_data\u002Fbackups\u002Fkeys-….bak \\\n    user@dest:\u002Ftmp\u002F\n```\n\nOn the destination host (after `docker compose up -d` brings up a\nfresh container):\n\n```bash\n# 1. Restore user data (portfolios + stonkmode)\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fimport \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d \"{\\\"snapshot\\\": $(cat \u002Ftmp\u002Fsnap.json)}\"\n\n# 2. Place the encrypted backup file under \u002Fdata\u002Fbackups\u002F, then restore\ndocker cp \u002Ftmp\u002Fkeys-….bak ic-engine:\u002Fdata\u002Fbackups\u002F\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_restore \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"passphrase\": \"...\"}'\n# (no backup_path → auto-picks the most-recent .bak file)\n```\n\n#### When you don't have shell access on both hosts\n\nFall back to **prompted key re-entry**. The `portfolio_import`\nresponse includes `configured_keys_in_snapshot` — the list of key\nnames that were set on the source host. The agent walks the user\nthrough each one:\n\n```text\nAgent: \"Your snapshot was set up with these keys: TOGETHER_API_KEY,\n        FRED_API_KEY, MASSIVE_API_KEY. They aren't in the snapshot for\n        security. Paste each one and I'll set it.\"\nUser:  pastes TOGETHER_API_KEY\nAgent: portfolio_keys_set({\"keys\": {\"TOGETHER_API_KEY\": \"...\"}})\n       (and so on)\n```\n\nThis is intentionally manual — the user types each secret once, into\nthe agent, which round-trips to `keys_set`. Auditable. For larger key\nsets, the encrypted-backup path above is friction-free in comparison.\n\n---\n\n### Listing existing backups\n\n```bash\ncurl -s -X POST http:\u002F\u002Flocalhost:18090\u002Fapi\u002Fportfolio\u002Fkeys_backups_list | jq\n```\n\nReturns metadata (filename, size, mtime, KDF) for each `keys-*.bak`\nunder `\u002Fdata\u002Fbackups\u002F`. **No passphrase required** — listing only\nreturns metadata, not contents.\n\n### Threat model & where the passphrase appears\n\nThe backup tool is encrypted because the file is meant to LEAVE the\nhost (scp, email, USB, cloud sync). Plaintext keys never leave `\u002Fdata`\n— only the encrypted blob.\n\n**Where the passphrase is exposed**:\n\n- It passes through the tool-call args (so it's in the agent's\n  conversation history once at backup time and once at restore time).\n  For maximum secrecy, invoke from the dashboard browser — keeps the\n  passphrase out of LLM provider context entirely. Or use `curl`\n  directly on the host.\n\n- It is NEVER persisted by the bridge. Each backup\u002Frestore call\n  derives the encryption key fresh via scrypt; the passphrase doesn't\n  leave Python's local scope.\n\n**Out of scope**: keylogging on the user's terminal; rubber-hose\nattack; weak-passphrase guessing (we enforce min length 12 to\ndiscourage trivial passphrases).\n\n### Agent-driven upgrade flow (single-shot script)\n\n```text\nUser:  \"Check for upgrades.\"\nAgent: portfolio_version_check → \"v4.7.0 available; you're on v4.4.2\"\nUser:  \"Upgrade me.\"\nAgent: 1. portfolio_export → save snap.json\n       2. (if new host) portfolio_keys_backup with user-supplied passphrase\n       3. surface the host-shell pull+restart commands to the user\n       4. poll \u002Fhealthz until init_ready\n       5. portfolio_version_check (running == latest? confirm)\n       6. iff \u002Fdata was lost: portfolio_import + portfolio_keys_restore\n          (or prompted re-entry via portfolio_keys_set)\n```\n\nThe agent never executes host-shell commands itself. Surface them\nclearly and let the user run them.\n\n---\n\n## Stop \u002F uninstall\n\n```bash\n# Stop (preserves data)\ndocker compose down\n\n# Stop and remove the data volume\ndocker compose down -v\n```\n\n---\n\n## Security model\n\nInvestorClaw is a single-user, localhost-bound, deterministic-first\nanalyzer. Several behaviors that automated scanners flag as \"warning\"\nare intentional design choices for this threat model. Documented here\nexplicitly so reviewers can audit the trade-offs:\n\n| Behavior | Why it's by design |\n|---|---|\n| **MCP + REST endpoints are unauthenticated on `127.0.0.1:18090`** | Localhost binding (`127.0.0.1:` prefix on the port spec, never `0.0.0.0`) is the security boundary. Any process running as the same user already has filesystem access to portfolios; adding token auth on a loopback API doesn't change that threat model. To expose the service to other hosts, put it behind your own auth layer (Tailscale, nginx + mTLS). |\n| **Container auto-initializes on boot** (`IC_INITIALIZE_ON_BOOT=1`) | The cold-cache cost on a 200+ position portfolio is 5–15 minutes; running setup → refresh → seed_ask at boot means agents see `init_state: ready` immediately on connect. Disable with `IC_INITIALIZE_ON_BOOT=0` if you want manual control. The init does not exfiltrate data — it just primes the engine's read-only cache against the providers you've configured. |\n| **API keys persist to `\u002Fdata\u002Fkeys.env` (mode 0600)** | Keys need to outlive container restarts. The named volume is `ic-engine-data`; on the host that's a docker volume root-owned but only readable by the container's `uid=1000(ic)`. To rotate or delete a key, use `portfolio_keys_set` \u002F `portfolio_keys_delete` — both REST endpoints accept allowlisted names only, never logging values. |\n| **Portfolio summaries are sent to the configured narrative LLM provider** | This is the value prop: the engine produces a deterministic envelope, the narrator turns it into prose. To keep narratives local, point `INVESTORCLAW_NARRATIVE_ENDPOINT` at a local Ollama \u002F llama-server \u002F vLLM endpoint (set `INVESTORCLAW_NARRATIVE_PROVIDER=ollama`). To run keyless without any narrator, omit `TOGETHER_API_KEY` — the engine returns a stub catalog summary instead. See [`PRIVACY.md`](PRIVACY.md) for the full data-flow matrix. |\n| **Image pulled from `ghcr.io\u002Fargonautsystems\u002Fic-engine`** | Pinned to a specific sha256 digest in `compose.yml`, not just the tag — guarantees reproducible builds even if the tag is later mutated. Verify the digest matches what your scanner expects before deploying. Container Apache 2.0 + bridge code MIT-0 in this repo; engine source at `argonautsystems\u002Fic-engine` (pinned by SHA). |\n\nFor vulnerability disclosure see [`SECURITY.md`](SECURITY.md). For the\nprivacy model (what stays local vs what goes to which provider) see\n[`PRIVACY.md`](PRIVACY.md).\n\n## Behavior contract\n\n- `portfolio_ask` invokes the engine's deterministic refresh-aware path; if a section is stale (news TTL=30s, others 60s) it is refreshed before answering. Earlier `--no-refresh` short-circuited routing entirely and produced a generic catalog blurb — that flag is intentionally NOT passed.\n- The container clears yfinance cookies on subprocess timeout, breaking the rate-limit cascade documented in commit `50387b1` of `ncz-os\u002Fmnemos-ic-runtime`.\n- Cross-container reach works via `http:\u002F\u002F172.17.0.1:18090\u002Fmcp` (Docker bridge IP) or via Compose service name `http:\u002F\u002Fic-engine:8090\u002Fmcp` (when both agent + ic-engine are in the same compose).\n\n## Known issues (v4.1.1)\n\n- **Earlier \"v4.0.9 hits 30\u002F30\" claims were measured with a too-lenient verdict** that only checked the ic_result envelope and exit_code, not the narrative content — the engine's heuristic catalog blurb satisfied both. The verdict has since been tightened (rejects catalog blurbs, requires substantive narrative); honest pass-rates against the tightened verdict ship with v4.1.1 release notes.\n- **Cold-start `portfolio_ask` may take 5–15 minutes** on a 200+ position portfolio when the envelope cache is empty (engine runs P0 holdings → P1 parallel performance\u002Fbonds\u002Fanalyst\u002Fnews → P2 synthesis → P3 optimize+cashflow → P4 peer, each consuming yfinance \u002F FRED \u002F Finnhub bandwidth). Subsequent calls hit the warm cache and return in seconds. Bridge subprocess timeout is 1800s for `portfolio_ask` and `portfolio_refresh`; engine P1 parallel-stage timeout is 600s.\n\n### Fixed in v4.1.1 (was broken in v4.0.x → v4.1.0)\n\n- **Engine pipeline only persisting the analyst section** (`Section did not run` on every other section): root cause was the engine's P1 parallel-stage timeout of 60s — performance\u002Fbonds\u002Fanalyst\u002Fnews running in parallel against yfinance overflowed it on large portfolios, asyncio.gather raised TimeoutError, the entire P1 result set was lost. Bumped to 600s.\n- **Narrator falling through to a heuristic catalog blurb** for every `portfolio_ask`: chain of five bugs — litellm stripped from the container; narrator wrapped the LLM call in a bare try\u002Fexcept; consultation client misrouted IP-addressed local servers; narrator pulled the short-context CONSULTATION_* model instead of the long-context NARRATIVE_* model; full envelope (200k+ tokens) overflowed even MiniMax-M2.7. All five fixed.\n- **`--no-refresh` short-circuiting routing**: bridge passed `--no-refresh` to every `portfolio_ask` (commit `a3492f6`, v4.0.7), making the engine return the cached catalog blurb regardless of question. Reverted.\n\n---\n\n## License + provenance\n\n- Service code: Apache 2.0 (`ncz-os\u002Fmnemos-ic-runtime`)\n- Distribution-edge artifacts (this `SKILL.md`, `compose.yml`, `install.yaml`, `agent-skills\u002F**`): **MIT-0** (MIT No Attribution — `LICENSE-MIT-0`). Required for ClawHub plugin publishing; the no-attribution clause means downstream skill registries can re-host without preserving copyright notice.\n- Image: `ghcr.io\u002Fargonautsystems\u002Fic-engine:4.7.0-cpu` (multi-arch amd64+arm64; also at `:latest`)\n- RFC: see `RFC-v0.1.md` in this bundle (`ncz-os\u002Fmnemos-ic-runtime` GitHub repository)\n- Cross-project contract: `mnemos-os\u002Fmcp-contracts` GitHub repository\n\n---\n\n*InvestorClaw is a portfolio analysis service. Educational use only — not investment advice.*\n",{"name":5,"homepage":24,"metadata":25,"description":7,"user-invocable":31},"https:\u002F\u002Fgithub.com\u002Fargonautsystems\u002FInvestorClaw",{"image":26,"license":27,"version":28,"transport":29,"mcp-endpoint":30},"ghcr.io\u002Fargonautsystems\u002Fic-engine:4.7.0-cpu","MIT-0","4.7.0","streamable-http","http:\u002F\u002Flocalhost:18090\u002Fmcp",true,"master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fi\u002Finvestorclaw",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":31},[43,46,49],{"tool":44,"command":45},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill investorclaw",{"tool":47,"command":48},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill investorclaw",{"tool":50,"command":51},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill investorclaw","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fi\u002Finvestorclaw\u002FSKILL.md",[],[55,62,69,76,83,90],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]