> ## Documentation Index
> Fetch the complete documentation index at: https://docs.forii.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Set up the venv, run Postgres, crawl, build predictor panels, and serve the API.

## Setup

`.env` at `providers/data/market/`:

```bash theme={null}
DATABASE_URL=postgresql+psycopg://postgres:postgres@localhost:5432/investments
POSTGRES_DB=investments
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
KITE_API_KEY=
KITE_API_SECRET=
KITE_ACCESS_TOKEN=
```

Rebuild the venv (one per repo, at the root):

```bash theme={null}
cd providers/data/market/components
uv venv ../../../../.venv --python 3.13 --prompt asset-pricing
UV_PROJECT_ENVIRONMENT=../../../../.venv uv sync --all-packages --all-extras
```

Activate once per shell:

```bash theme={null}
cd ~/ws/asset-pricing && source .venv/bin/activate   # prompt shows (asset-pricing)
```

## Run the pipeline

```bash theme={null}
docker compose -f providers/data/market/docker-compose.yml up -d postgres
python -m db_interface.cli init-db          # create tables

python scripts/kite_login_flask_app.py      # daily Kite login (from data/market/), :5001
python -m instruments_crawler.cli sync      # all NSE instruments
python -m historical_crawler.cli sync      # 25 years of daily candles

python -m market_api.cli export             # stage per-ticker CSVs
python -m market_api.cli build-panel --all  # predictor panel CSVs
```

## Serve

```bash theme={null}
python -m uvicorn market_api.app:app --port 8000
curl localhost:8000/tickers
curl "localhost:8000/tickers/INFY/metrics?metrics=mvel1"
curl localhost:8000/panel/mom1m
```

## Test

```bash theme={null}
make -C providers test    # pytest over all components
make -C providers lint    # ruff over all components
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.