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

# Python SDK

> Install and use the official VecTrade Python SDK

## Installation

```bash theme={null}
pip install vectrade
```

Optional extras:

```bash theme={null}
pip install vectrade[telemetry]   # OpenTelemetry integration
pip install vectrade[pandas]      # DataFrame helpers
```

## Quick Start

```python theme={null}
from vectrade import VecTrade

client = VecTrade()  # reads VECTRADE_API_KEY env var

quote = client.quotes.get("AAPL")
print(f"{quote.symbol}: ${quote.price}")
```

### Async Client

```python theme={null}
from vectrade import AsyncVecTrade

async def main():
    client = AsyncVecTrade()
    quote = await client.quotes.get("AAPL")
    print(f"{quote.symbol}: ${quote.price}")
```

## Configuration

```python theme={null}
client = VecTrade(
    api_key="vq_live_...",       # or VECTRADE_API_KEY env var
    base_url="https://...",      # custom endpoint
    timeout=30,                  # request timeout (seconds)
    max_retries=2,               # automatic retries on 429/5xx
    sandbox=True,                # use sandbox environment
)
```

## Resources

All 12 resource groups available:

| Resource              | Methods                                                         |
| --------------------- | --------------------------------------------------------------- |
| `client.quotes`       | `get(symbol)`, `batch(symbols)`                                 |
| `client.fundamentals` | `get(symbol)`, `statements(symbol)`                             |
| `client.technicals`   | `get(symbol)`                                                   |
| `client.news`         | `list(symbol)`                                                  |
| `client.options`      | `chain(symbol)`                                                 |
| `client.analyst`      | `consensus(symbol)`, `price_targets(symbol)`, `ratings(symbol)` |
| `client.earnings`     | `history(symbol)`                                               |
| `client.insider`      | `transactions(symbol)`                                          |
| `client.profile`      | `get(symbol)`                                                   |
| `client.sentiment`    | `get(symbol)`                                                   |
| `client.historical`   | `get(symbol, period="5d")`                                      |
| `client.etf`          | `get(symbol)`                                                   |

## Usage Examples

### Real-Time Quote

```python theme={null}
quote = client.quotes.get("AAPL")
print(f"{quote.symbol}: ${quote.price:.2f} ({quote.change_pct:+.2f}%)")
```

### Batch Quotes

```python theme={null}
quotes = client.quotes.batch(["AAPL", "MSFT", "GOOGL"])
for q in quotes:
    print(f"{q.symbol}: ${q.price:.2f}")
```

### Technical Analysis

```python theme={null}
tech = client.technicals.get("AAPL")
print(f"Score: {tech.technical_score}/100")
print(f"RSI: {tech.indicators['rsi']['value']:.1f} ({tech.indicators['rsi']['signal']})")
print(f"Trend: {tech.summary['trend']}")
```

### Analyst Consensus

```python theme={null}
analyst = client.analyst.consensus("AAPL")
print(f"Rating: {analyst.consensus} | Signal: {analyst.signal}")
print(f"Analysts: {analyst.total_analysts}")
```

## Error Handling

```python theme={null}
from vectrade import RateLimitError, NotFoundError

try:
    quote = client.quotes.get("INVALID")
except NotFoundError as e:
    print(f"Not found: {e} (request_id: {e.request_id})")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
```

## Requirements

* Python 3.9+
* Dependencies: `httpx`, `pydantic`

<Card title="GitHub" icon="github" href="https://github.com/VecTrade-io/vectrade-python">
  Source code, issues, and contributions
</Card>
