---
name: pp-investorpaisa
description: "The Nifty 200 momentum screener, movers and market breadth in your terminal, with a local history that builds from your first sync. Trigger phrases: `what's moving in the Nifty 200`, `screen Nifty 200 stocks`, `market breadth today`, `quote RELIANCE`, `sector rotation in India`, `what changed since yesterday in Nifty 200`, `morning market brief for my watchlist`, `5 year price history of TCS`, `use investorpaisa`, `run investorpaisa`."
author: "Som Samantray"
license: "Apache-2.0"
argument-hint: "<command> [args] | install cli|mcp"
allowed-tools: "Read Bash"
metadata:
  openclaw:
    requires:
      bins:
        - investorpaisa-pp-cli
    install:
      - kind: go
        bins: [investorpaisa-pp-cli]
        module: github.com/mvanhorn/printing-press-library/library/payments/investorpaisa/cmd/investorpaisa-pp-cli
---
<!-- GENERATED FILE — DO NOT EDIT.
     This file is a verbatim mirror of library/payments/investorpaisa/SKILL.md,
     regenerated post-merge by tools/generate-skills/. Hand-edits here are
     silently overwritten on the next regen. Edit the library/ source instead.
     See the repository agent guide, section "Generated artifacts: registry.json, cli-skills/". -->

# InvestorPaisa — Printing Press CLI

## Prerequisites: Install the CLI

This skill drives the `investorpaisa-pp-cli` binary. **You must verify the CLI is installed before invoking any command from this skill.** If it is missing, install it first:

1. Install via the Printing Press installer. It defaults binaries to `$HOME/.local/bin` on macOS/Linux and `%LOCALAPPDATA%\Programs\PrintingPress\bin` on Windows:
   ```bash
   npx -y @mvanhorn/printing-press-library install investorpaisa --cli-only
   ```
2. Verify: `investorpaisa-pp-cli --version`
3. Ensure the reported install directory is on `$PATH` for the agent/runtime that will invoke this skill.

If the `npx` install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.26.9 or newer). This installs into `$GOPATH/bin` (default `$HOME/go/bin`), so add that directory to `$PATH` instead:

```bash
go install github.com/mvanhorn/printing-press-library/library/payments/investorpaisa/cmd/investorpaisa-pp-cli@latest
```

If `--version` reports "command not found" after install, the runtime cannot see the binary directory on `$PATH`. Do not proceed with skill commands until verification succeeds.

InvestorPaisa shows a clean Nifty 200 dashboard in the browser only, behind a Google sign-in. This CLI reuses your browser session, runs the site's screener expression language from scripts, and stores daily snapshots in SQLite so you can diff what changed since the last sync, track breadth over time, and hand an agent a one-call morning brief. Every live data command needs a signed-in session; --data-source local replays stored snapshots offline.

## When to Use This CLI

Use for Indian large/mid-cap momentum questions on the Nifty 200: what is moving, which stocks pass a trend/RS filter, how breadth and sectors are shifting, and what changed since the last sync. Best for scheduled agent briefs and ad-hoc screens that need stable JSON.

## Anti-triggers

Do not use this CLI for:
- Fundamental data such as P/E history, balance sheets or earnings (the site does not provide them)
- Placing orders or portfolio P&L (the site stores symbols only, no positions)
- Renaming watchlists or adding/removing bookmarks (not implemented; watchlists support list, create, delete and set-items)
- Stocks outside the Nifty 200 universe
- Tick-level or intraday backtesting

## Unique Capabilities

### Local analytics over synced data
- **`screen`** — Run the site's screener expression language (close > sma50 and rs >= 70) from the terminal over the Nifty 200 metrics (live, falling back to your last stored snapshot).

  _Reach for this when an agent needs a custom multi-metric filter of the Nifty 200 instead of paging raw rows._

  ```bash
  investorpaisa-pp-cli screen "close > sma50 and sma50 > sma200 and rs >= 70" --sector IT --agent
  ```
- **`quote`** — Price, range, RSI/SMA/EMA, returns, sector percentile, signals, headlines and watchlist membership for one or more stocks in a single call.

  _Use this first when asked about a specific stock._

  ```bash
  investorpaisa-pp-cli quote RELIANCE TCS --agent
  ```

### Market pulse
- **`movers`** — Ranked gainers, losers, unusual volume, gappers and 52-week highs/lows, filtered by RS and sector.

  _Answers what is moving today and is also strong, in one call._

  ```bash
  investorpaisa-pp-cli movers --kind volume --min-rs 70 --top 10 --agent
  ```
- **`sectors`** — Equal-weight sector returns over 1d-1y, average RS and % above 50/200 DMA, with rank change versus an earlier stored snapshot (--trend needs two stored days).

  _Use for sector rotation questions across the sectors._

  ```bash
  investorpaisa-pp-cli sectors --window 1m --trend --agent
  ```
- **`brief`** — Index levels, breadth, your watchlist rows with change, RS and signals, and fresh headlines in one JSON document.

  _One call gives a scheduled agent the whole market-morning note._

  ```bash
  investorpaisa-pp-cli brief --agent
  ```

### Local state that compounds
- **`changes`** — Which stocks entered or left conditions (new 52-week high, RS crossing 70, 50/200 DMA crossings, 2x volume) since an earlier stored snapshot; needs two stored trading days.

  _Gives a morning agent the what-changed primitive without a scrape-and-diff script._

  ```bash
  investorpaisa-pp-cli changes --since 1d --agent
  ```
- **`breadth`** — Trend of advance/decline, % above 50/200 DMA, new 52-week highs and stocks at 52-week lows across your stored daily snapshots.

  _Answers whether participation is widening or narrowing._

  ```bash
  investorpaisa-pp-cli breadth --days 30 --agent
  ```
- **`history`** — Five years of daily OHLCV, split/bonus adjustment factors and corporate events for a stock, read from its chart page and cached locally (--raw, --years, --tail).

  _Use for long-horizon price context and backtests on adjusted prices._

  ```bash
  investorpaisa-pp-cli history TCS --years 5 --agent
  ```

## Command Reference

**bookmarks** — Bookmarked news and video cards

- `investorpaisa-pp-cli bookmarks` — List bookmarked cards

**health** — Service health (public, no auth)

- `investorpaisa-pp-cli health` — Check that investorpaisa.com is up

**live** — Live Nifty 200 snapshot: index levels, breadth, per-stock LTP rows, signals, intraday curve

- `investorpaisa-pp-cli live` — Current intraday snapshot (server cache 15s).

**market** — Market overview: breadth, 52-week signals, equal-weight index

- `investorpaisa-pp-cli market` — End-of-day market overview with the ranked signal list (52-week highs/lows, gaps, volume spikes)

**me** — Your profile and saved chart/screener layout

- `investorpaisa-pp-cli me get` — Show the signed-in profile (name, image)
- `investorpaisa-pp-cli me layout` — Show your saved chart layout (symbol, range, indicators, screener expression, theme)

**news** — Headlines (Google News RSS aggregation) tagged to Nifty 200 symbols

- `investorpaisa-pp-cli news by-symbol` — Latest news for one stock symbol, newest first
- `investorpaisa-pp-cli news feed` — Market-wide news and video card feed with cursor pagination

**screener** — Daily screener metrics for every Nifty 200 stock (48 fields: RS, RSI, SMAs, returns, beta, drawdown, volume pace)

- `investorpaisa-pp-cli screener` — Fetch the full 200-row metrics table (the site filters client-side; the sector query param is ignored server-side)

**screens** — Your saved screens

- `investorpaisa-pp-cli screens` — List saved screener screens

**universe** — The Nifty 200 stock universe (symbol, name, sector, last close, day change)

- `investorpaisa-pp-cli universe` — List the 200 stocks tracked by InvestorPaisa with last close and 1-day change

**videos** — Finance videos and shorts (CNBC-TV18, NDTV Profit, Zee Business) from YouTube

- `investorpaisa-pp-cli videos` — List recent finance videos or shorts

**watchlists** — Your watchlists (up to 20, up to 200 symbols each)

**These three watchlist commands change your InvestorPaisa account (`delete` is irreversible); every other command is read-only.**

- `investorpaisa-pp-cli watchlists create` — Create a watchlist
- `investorpaisa-pp-cli watchlists delete` — Delete a watchlist
- `investorpaisa-pp-cli watchlists list` — List watchlists with their symbols
- `investorpaisa-pp-cli watchlists set-items` — Replace the symbols in a watchlist


**breadth**


- `investorpaisa-pp-cli breadth` — Trend of advance/decline, % above 50/200 DMA, new 52-week highs and stocks at 52-week lows across your stored daily snapshots.


**brief**


- `investorpaisa-pp-cli brief` — Index levels, breadth, your watchlist rows with change, RS and signals, and fresh headlines in one JSON document.


**changes**


- `investorpaisa-pp-cli changes` — Which stocks entered or left conditions (new 52-week high, RS crossing 70, 50/200 DMA crossings, 2x volume) since an earlier stored snapshot; needs two stored trading days.


**history**


- `investorpaisa-pp-cli history` — Five years of daily OHLCV, split/bonus adjustment factors and corporate events for a stock, read from its chart page and cached locally (--raw, --years, --tail).


**movers**


- `investorpaisa-pp-cli movers` — Ranked gainers, losers, unusual volume, gappers and 52-week highs/lows, filtered by RS and sector.


**quote**


- `investorpaisa-pp-cli quote` — Price, range, RSI/SMA/EMA, returns, sector percentile, signals, headlines and watchlist membership for one or more stocks in a single call.


**screen**


- `investorpaisa-pp-cli screen` — Run the site's screener expression language (close > sma50 and rs >= 70) from the terminal over the Nifty 200 metrics (live, falling back to your last stored snapshot).


**sectors**


- `investorpaisa-pp-cli sectors` — Equal-weight sector returns over 1d-1y, average RS and % above 50/200 DMA, with rank change versus an earlier stored snapshot (--trend needs two stored days).




### Finding the right command

When you know what you want to do but not which command does it, ask the CLI directly:

```bash
investorpaisa-pp-cli which "<capability in your own words>"
```

`which` resolves a natural-language capability query to the best matching command from this CLI's curated feature index. Exit code `0` means at least one match; exit code `2` means no confident match — fall back to `--help` or use a narrower query. `--json` (and other machine formats) keep that exit-2 contract and write `{"matches":[]}` on stdout so agents can inspect the envelope without treating a miss as success.

## Recipes

### Morning note for an agent

```bash
investorpaisa-pp-cli brief --agent --select index,breadth,watchlists.rows.symbol,watchlists.rows.chg_pct
```

Narrow the brief to the few fields a scheduled agent needs.

### Strong stocks with unusual volume

```bash
investorpaisa-pp-cli movers --kind volume --min-rs 70 --top 10 --agent
```

Volume spikes only among relative-strength leaders.

### What entered the 52-week-high list

```bash
investorpaisa-pp-cli changes --since 1d --agent --select conditions.new_52w_high
```

Compares against the nearest stored earlier snapshot (see baseline_as_of); needs two stored days.

### Sector leaders over a month

```bash
investorpaisa-pp-cli sectors --window 1m --trend
```

Rank the sectors by equal-weight 1-month return and see rank movement versus the earlier snapshot.

## Auth Setup

InvestorPaisa is sign-in only (Google). Sign in to investorpaisa.com in Chrome, then run auth login --chrome (needs the pycookiecheat, cookies or cookie-scoop-cli helper; pip install pycookiecheat). Alternatives: auth login --cookies-file, piping the __Secure-authjs.session-token cookie value into auth set-token, or exporting INVESTORPAISA_SESSION_TOKEN as a cookie string (the cookie name, an equals sign, then its value). No password is ever handled.

Run `investorpaisa-pp-cli doctor` to verify setup.

## Agent Mode

Add `--agent` to any command. Expands to: `--json --compact --no-input --no-color`.

Global format flags share one contract on promoted, novel, sync, and `--deliver` paths:

- `--json` — one JSON document on stdout (sync progress events go to stderr)
- `--compact` — keep identity/status/timestamp fields; does not change the document vs stream shape
- `--csv` / `--plain` — tabular rows (collection envelopes unwrap to the row array)
- `--quiet` — one identity value per row, no envelope

- **Pipeable** — JSON on stdout, errors on stderr
- **Filterable** — `--select` keeps a subset of fields. Dotted paths descend into nested structures; arrays traverse element-wise. Critical for keeping context small on verbose APIs:

  ```bash
  investorpaisa-pp-cli bookmarks --agent --select kind,id,savedAt
  ```
- **Previewable** — `--dry-run` shows the request without sending
- **Offline-friendly** — sync/search commands can use the local SQLite store when available
- **Non-interactive** — never prompts, every input is a flag
- **Explicit confirmation** — `--agent` does not imply `--yes`; pass `--yes` separately only after the target, arguments, and side effects are clear
- **Explicit retries** — use `--idempotent` (only `watchlists create`) only when an already-existing create should count as success, and use `--ignore-missing` (only `watchlists delete`) only when a missing delete target should count as success

### Response envelope

Commands that read from the local store or the API wrap output in a provenance envelope:

```json
{
  "meta": {"source": "live" | "local", "synced_at": "...", "reason": "..."},
  "results": <data>
}
```

Parse `.results` for data and `.meta.source` to know whether it's live or local. A human-readable `N results (live)` summary is printed to stderr only when stdout is a terminal AND no machine-format flag (`--json`, `--csv`, `--compact`, `--quiet`, `--plain`, `--select`) is set — piped/agent consumers and explicit-format runs get pure JSON on stdout.

## Paths and state

Agents should treat the CLI's path resolver as part of the runtime contract:

- Use `--home <dir>` for one invocation, or set `INVESTORPAISA_HOME=<dir>` to relocate all four path kinds under one root.
- Use per-kind env vars only when a specific kind must diverge: `INVESTORPAISA_CONFIG_DIR`, `INVESTORPAISA_DATA_DIR`, `INVESTORPAISA_STATE_DIR`, `INVESTORPAISA_CACHE_DIR`.
- Resolution order is per-kind env var, `--home`, `INVESTORPAISA_HOME`, XDG (`XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_STATE_HOME`, `XDG_CACHE_HOME`), then platform defaults.
- `config` contains settings like `config.toml` and profiles. `data` contains `credentials.toml`, `data.db`, cookies, and auth sidecars. `state` contains persisted queries, jobs, and `teach.log`. `cache` contains regenerable HTTP/cache files.
- Stored secrets live in `credentials.toml` under the data dir. Existing legacy `config.toml` secrets are read for compatibility and leave `config.toml` on the first auth write.
- Run `investorpaisa-pp-cli doctor --fail-on warn` to surface path and credential-location warnings. `agent-context` exposes a schema v4 `paths` block for agents that need the resolved dirs.
- For MCP, pass relocation through the MCP host config. The MCP binary does not inherit CLI flags:

  ```json
  {
    "mcpServers": {
      "investorpaisa": {
        "command": "investorpaisa-pp-mcp",
        "env": {
          "INVESTORPAISA_HOME": "/srv/investorpaisa"
        }
      }
    }
  }
  ```

Fleet precedence: an inherited per-kind env var overrides an explicit `--home` for that kind. Use `INVESTORPAISA_HOME` or per-kind vars as durable fleet levers, and use `--home` only for a single invocation. Relocation is not reversible by unsetting env vars; move files manually before clearing `INVESTORPAISA_HOME`, or `doctor` will not find credentials left under the former root.

## Automatic learning

This CLI ships a self-capturing learning loop. The CLI does its own bookkeeping: every invocation is journaled locally, a failed flag followed by a corrected retry auto-derives a `flag_alias` candidate, and a `teach` on a query family without a playbook auto-synthesizes a `playbook_candidate` from the session's journal. Your job is judgment only: `recall` first, act on surfaced candidates, `teach` the final answer, `playbook amend` when you observe a correction. You never record failures by hand.

### Step 1: `recall` before any discovery

Before list/search/drill commands on a new user question, pass the question as an argv or MCP tool argument to `recall --agent`. Do not interpolate user-controlled text into a shell command line.

Quoted `recall "<question>"` breaks on an apostrophe, which is ordinary English. A quoted heredoc breaks when a body line equals the delimiter, and that delimiter is published in these docs. Write the question with a non-shell file-writing tool, then read it back as data:

```bash
# Write the question verbatim with your file-writing tool (no shell involved).
# Command substitution on a file only ever yields data — the shell never
# parses the file's bytes as syntax.
QUERY=$(cat /path/to/question.txt)
investorpaisa-pp-cli recall "$QUERY" --agent
```

Prefer MCP: pass the question as the tool's query argument. `"$QUERY"` after a file read is argv-safe; putting the question itself in the command text is not.

The response envelope:

```json
{
  "query": "...",
  "normalized": "<normalized form>",
  "query_entities": ["..."],
  "found": true | false,
  "match_score": 0.0,
  "results": [
    { "resource_id": "...", "resource_type": "...", "venue": "...",
      "confidence": 2, "entity_match": "exact|partial|unknown",
      "source": "taught|preseed|pattern", "warnings": ["..."] }
  ],
  "mismatches": [ /* only when --debug-mismatches */ ],
  "warnings": [ /* top-level */ ],
  "candidates": [
    { "id": 12, "class": "flag_alias | playbook_candidate",
      "summary": "...", "sightings": 3, "last_seen": "...",
      "rationale": "...",
      "next_action": ["<trial command>", "investorpaisa-pp-cli learnings confirm 12"] }
  ],
  "playbook": {
    "query_family": "...",
    "playbook": {
      "steps": [ { "cmd": "<command with {slot} substitution>", "purpose": "..." } ],
      "entity_slots": ["$ENTITY"],
      "expected_tool_calls": 3
    },
    "slots_resolved": { "$ENTITY": { "token": "<live token>", "canonical": "<canonical>" } },
    "notes": "<workarounds + gotchas for this query family>"
  },
  "notes": "<duplicate surface for non-playbook callers>"
}
```

Empty-store short-circuit: if the store has no learnings, playbooks, or candidates yet (recall finds nothing and `learnings list` and `learnings candidates` are both empty), skip recall for the rest of this session instead of taxing every query; resume recall-first once something has been taught.

### Step 2: decision tree

Read `candidates`, `playbook`, `notes`, `results[0]`, and warnings in that order:

```
if Candidates present (warnings include "candidates_present"):
    -> candidates are try-then-confirm, never facts. Follow each candidate's
       two-step next_action verbatim: run the trial command first, then run
       `learnings confirm <id>` only after the trial verified the behavior.
       Reject a wrong candidate with `learnings reject <id>`.
    -> NEVER re-teach something recall surfaced as a candidate; confirm or
       reject that candidate instead of teaching a duplicate.
    -> candidates ride alongside playbooks and resource hits, not instead of
       them; continue with the branches below after acting on them.

if Playbook present:
    -> READ Playbook.notes verbatim FIRST (workarounds + gotchas the CLI surface doesn't expose)
    -> replay Playbook.steps in order, substituting Playbook.slots_resolved entries
       for the entity slot tokens. If a step's slot is unresolved, fall back to
       discovery for that step only.
 