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

# SMA and EMA for historical exchange rates

> Calculate SMA and EMA over observed closes with stats=1&ma=N on a rate ID’s history endpoint.

Add `stats=1&ma=N` to history for SMA and EMA. `N` must be an integer from 2 to 365. SMA uses the latest observed closes; EMA uses the full requested series.

```bash curl theme={null}
curl "https://api.cotizave.com/v2/fx/VE/rates/ve-bcv/history?stats=1&ma=7" \
  -H "X-API-Key: $COTIZAVE_API_KEY"
```

Illustrative response: `ma=7` adds five fields to `stats`, even with fewer than seven observed closes.

```json theme={null}
{
  "id": "ve-bcv",
  "market": "reference",
  "base": "USD",
  "quote": "VES",
  "from": "2026-11-03",
  "to": "2026-11-05",
  "granularity": "daily",
  "stats": {
    "count": 3,
    "min": 200,
    "max": 204,
    "avg": 202,
    "stddev": 2,
    "first": { "date": "2026-11-03", "mid": 200 },
    "last": { "date": "2026-11-05", "mid": 204 },
    "change": 4,
    "change_pct": 2,
    "period": 7,
    "sma": 202,
    "ema": 201.375,
    "vs_sma_pct": 0.9901,
    "vs_ema_pct": 1.3035
  }
}
```


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