Metadata-Version: 2.4
Name: stockpro-cli
Version: 0.2.0
Summary: CLI for StockPro -- AI-powered stock research from your terminal
Project-URL: Homepage, https://stockpro-production-11c8.up.railway.app
Project-URL: Source, https://github.com/optimusor/stockpro
Author: StockPro
License: MIT License
        
        Copyright (c) 2026 StockPro
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ai,cli,finance,research,stocks,trading
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: click>=8.1
Requires-Dist: httpx>=0.27
Requires-Dist: keyring>=24.0
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Description-Content-Type: text/markdown

# StockPro CLI

AI-powered stock research from your terminal. Talks to the StockPro backend over HTTPS.

By default the CLI targets the live deployment at `https://stockpro-production-11c8.up.railway.app`.

## Install

```bash
pip install stockpro-cli
```

Or, for local development from the repo root:

```bash
pip install -e stockpro-cli/
```

This registers the `stockpro` command.

### Token storage

Your auth token is stored in your OS keychain (macOS Keychain, Windows Credential Locker, or freedesktop Secret Service on Linux) via the `keyring` library. If no keyring backend is available, the token falls back to `~/.stockpro/config.json` (mode `0600`) and you'll see a warning. For headless/CI use, set `STOCKPRO_TOKEN=...` — it overrides everything else.

## First-time sign-in

```bash
stockpro auth login
```

Opens your browser to the StockPro Clerk sign-in page. After Google OAuth completes, the browser redirects to a short-lived local callback (timeout: 120s) and the CLI stores your token in the OS keychain.

Confirm:

```bash
stockpro auth status
```

Sign out (clears the stored token):

```bash
stockpro auth logout
```

## Headless / serverless (no browser)

For agents running in a serverless environment (no browser to open), use the device-code flow. The agent prints a code; the user opens the URL on any device, signs in, and approves.

```bash
stockpro auth device-login
```

Output:

```
Open https://stockpro-production-11c8.up.railway.app/app/device?user_code=ABCD1234 on any browser,
sign in, and confirm code: ABCD1234
(expires in 10 min). Waiting...
```

Once approved, the token is saved to `~/.stockpro/config.json` just like `auth login`.

### Token injection via env var

If the agent already has a token (e.g. generated from the Settings -> CLI tokens page on the web app), skip the device flow entirely:

```bash
export STOCKPRO_TOKEN=sp_xxxxxxxxxxxxxxxx
stockpro portfolio list
```

`STOCKPRO_TOKEN` takes precedence over `~/.stockpro/config.json`. Perfect for injecting into serverless runtimes as a secret.

## Pointing at local Flask (dev)

Precedence: `--api-url` flag > `STOCKPRO_API_URL` env var > `~/.stockpro/config.json` > default.

Per invocation:

```bash
stockpro --api-url http://127.0.0.1:5000 auth status
```

Shell session:

```bash
export STOCKPRO_API_URL=http://127.0.0.1:5000
stockpro auth status
```

Persist in the config file (only if you pass `--api-url` during `auth login`):

```bash
stockpro --api-url http://127.0.0.1:5000 auth login
```

## Commands

Run `stockpro --help` for the full list. Common ones:

- `stockpro auth login | logout | status`
- `stockpro portfolio list`
- `stockpro report list`
- `stockpro watchlist list`
