Metadata-Version: 2.4
Name: algorithm-stat
Version: 0.1.2
Summary: Unified quant-finance toolkit: market data, metrics, charts, Monte Carlo, backtesting, ML, macro, options, mortgage, Alpaca.
Project-URL: Homepage, https://github.com/analyticswithharry/algo-stat
Project-URL: Repository, https://github.com/analyticswithharry/algo-stat
Project-URL: Issues, https://github.com/analyticswithharry/algo-stat/issues
Author-email: Hemant Thapa <hemant@squidconsultancygroup.com>
Maintainer: Squid Consultancy Group Ltd
License-Expression: Elastic-2.0
License-File: LICENSE
Keywords: backtesting,finance,fred,monte-carlo,quant,trading,yfinance
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: Other/Proprietary 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: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.10
Requires-Dist: fastapi>=0.110
Requires-Dist: httpx>=0.27
Requires-Dist: ipympl>=0.9
Requires-Dist: ipywidgets>=8.0
Requires-Dist: lxml>=5.0
Requires-Dist: matplotlib>=3.8
Requires-Dist: mplfinance>=0.12.10b0
Requires-Dist: numpy>=1.26
Requires-Dist: pandas-datareader>=0.10.0
Requires-Dist: pandas>=2.1
Requires-Dist: pydantic-settings>=2.2
Requires-Dist: pydantic>=2.6
Requires-Dist: python-dotenv>=1.0
Requires-Dist: requests>=2.32
Requires-Dist: rich>=13.7
Requires-Dist: scikit-learn>=1.4
Requires-Dist: seaborn>=0.13
Requires-Dist: streamlit>=1.34
Requires-Dist: tabulate>=0.9
Requires-Dist: typer>=0.12
Requires-Dist: uvicorn[standard]>=0.29
Requires-Dist: yfinance>=0.2.40
Provides-Extra: all
Requires-Dist: alpaca-py>=0.20; extra == 'all'
Requires-Dist: tensorflow>=2.15; extra == 'all'
Provides-Extra: dev
Requires-Dist: jupyterlab>=4; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: ml-deep
Requires-Dist: tensorflow>=2.15; extra == 'ml-deep'
Provides-Extra: test
Requires-Dist: pytest-mpl>=0.17; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Provides-Extra: trading
Requires-Dist: alpaca-py>=0.20; extra == 'trading'
Description-Content-Type: text/markdown

# algo-stat

> **Quant analysis in 3 lines.** A self-contained Python toolkit for
> market data, metrics, charts, Monte Carlo, backtesting, ML, macro,
> options, mortgage, and Alpaca paper trading.

```
algo-stat = library  +  CLI  +  REST API  +  Streamlit dashboard
```

---

## Install (local laptop)

```bash
cd algo-stat
python -m venv .venv && source .venv/bin/activate
pip install -e ".[all,test,dev]"        # all = trading + ml-deep
cp .env.example .env                    # add FRED_API_KEY (free, optional)
```

> **API keys?** `yfinance` needs **none**. FRED needs a free key (signup:
> https://fred.stlouisfed.org/docs/api/api_key.html). Alpaca only if you
> want paper trading.

## 3-line analyses (Jupyter / Python REPL)

```python
import algo_stat as a; a.use_dark()
a.report(a.fetch("NVDA", period="1y"), ticker="NVDA")
```

```python
import algo_stat as a
a.compare(["AAPL","MSFT","NVDA","GOOGL"], period="2y").show()
```

```python
import algo_stat as a
a.MonteCarlo("NVDA").simulate(n=1000, days=252).plot()
```

```python
import algo_stat as a
bt = a.Backtester("NVDA", period="2y").run(a.SMACrossover(20, 50))
print(bt.stats); bt.plot()
```

More examples in [notebooks/quickstart.py](notebooks/quickstart.py).

## CLI

```bash
algo-stat quote NVDA
algo-stat analyze NVDA --period 1y --chart
algo-stat compare AAPL,MSFT,NVDA,GOOGL --period 2y --chart
algo-stat montecarlo NVDA --n 1000 --days 252 --chart
algo-stat backtest NVDA --fast 20 --slow 50 --chart
algo-stat mortgage 300000 60000 0.055 --years 25
algo-stat macro cpi --years 10
algo-stat serve            # FastAPI on :8000
algo-stat dashboard        # Streamlit on :8501
```

## REST API

```bash
algo-stat serve
# → open http://127.0.0.1:8000/docs   (Swagger UI)
```

Endpoints:

| Method | Path                     | Purpose                   |
| ------ | ------------------------ | ------------------------- |
| GET    | `/health`                | health check              |
| GET    | `/quote/{ticker}`        | fundamental snapshot      |
| GET    | `/prices/{ticker}`       | OHLCV tail                |
| GET    | `/performance/{ticker}`  | CAGR / Sharpe / VaR / MDD |
| GET    | `/compare?tickers=...`   | normalized growth         |
| POST   | `/montecarlo`            | GBM simulation summary    |
| POST   | `/backtest/sma`          | SMA crossover stats       |
| POST   | `/mortgage`              | mortgage summary          |
| GET    | `/macro/{series}`        | FRED series               |
| POST   | `/options/black-scholes` | option pricing            |

## Streamlit dashboard

```bash
algo-stat dashboard
```

7 tabs: Performance · Compare · Monte Carlo · Backtest · Mortgage · Macro · Options.

## Package layout

```
algo_stat/
  data/         market.py · macro.py · universe.py
  metrics/      returns.py · performance.py · risk.py
  charts/       theme.py · price.py · compare.py · correlation.py · fundamentals.py
  derivatives/  montecarlo.py · options.py
  backtest/     engine.py · strategies.py
  ml/           pca.py · regression.py · classifier.py
  property/     mortgage.py
  trading/      alpaca_client.py
  cli.py        api.py        dashboard.py     report.py     config.py
```

## Tests

```bash
pytest -q
```

## Credits

© 2026 Squid Consultancy Group Ltd — Elastic License 2.0.
