Metadata-Version: 2.5
Name: polefinance
Version: 0.1.0
Summary: Official Python client for the Pôle Finance API
Project-URL: Documentation, https://polefinance-invest.com/developers/docs
Author: PoleFinance
License: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.25
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.21; extra == 'test'
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

# polefinance — Python SDK for the Pôle Finance API

Typed client (sync and async) for `https://polefinance-invest.com/api/v1`.

> Status: 0.1.0, not yet published on PyPI (publication pending approval).

## Install (from this repository)

```bash
pip install ./python-sdk
```

## Quick start

1. Create a project and an API key at https://polefinance-invest.com/developers/dashboard.
2. `export POLEFINANCE_API_KEY="pf_live_…"` — never put the key in code.

```python
from polefinance import PoleFinance

with PoleFinance() as client:              # reads POLEFINANCE_API_KEY
    page = client.instruments.list(exchange="BRVM", limit=20)
    for inst in page.data:
        print(inst.id, inst.name)
    sonatel = client.instruments.get("BRVM:SNTS")
    for inst in client.instruments.iterate(q="bank"):   # follows pagination
        ...
```

Compute on your own series (nothing stored, scope `analytics:compute`):

```python
closes = [100, 101.2, 99.8, 102.4, 103.1, 104.0]
client.technical.indicators(close=closes, indicators=[{"name": "sma", "period": 3}])
client.risk.metrics(prices=closes, periods_per_year=252, risk_free_rate=0.03)
client.optimization.portfolio({"BRVM:SNTS": snts_returns, "BRVM:ORAC": orac_returns},
                              method="min_variance")   # max_sharpe, risk_parity, equal_weight
client.backtests.run(dates=dates, assets=[{"id": "A", "closes": closes_a}],
                     strategy="buy_hold", rebalance="monthly", fees=0.01)
```

Async: `AsyncPoleFinance` has the same methods (`await`, `async for` on `iterate`).

## Errors

`AuthenticationError` (401), `PermissionDeniedError` (403), `NotFoundError` (404),
`RateLimitError` (429, `.retry_after`), `APIError` (others), `APIConnectionError` (network).
Each carries `.code`, `.message`, `.request_id`.

## Behaviour

- Timeout 15 s (`timeout=`), up to 2 retries (`max_retries=`) on network errors, 502/503/504 and
  429 with `Retry-After`. A daily-quota 429 is not retried. v1 calls are GETs or pure computations, so retries are safe.
- `market_data.quotes()` currently raises `PermissionDeniedError(code="market_data_not_available")`.

## Develop

```bash
pip install -e ".[test]" && pytest
```
