# Dollar-Cost Averaging API
> Live dollar-cost-averaging analytics that investors run to see how periodic buying plays out — computed on demand from the price series you pass in, no key, nothing cached. Get the outcome of investing a fixed amount each period (total invested, units accumulated, average cost, current value, profit and ROI) with a lump-sum comparison; the per-period breakdown; and a ranking of dollar-cost averaging against lump-sum, best-case and worst-case timing. Works for any market — stocks, crypto, ETFs or forex. A dollar-cost-averaging engine, distinct from compound-interest and return-analysis tools: it turns a price path and a contribution into the cost basis and outcome of buying over time.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/dca-api/..."
```

## Pricing
- **Free** (Free) — 5,550 calls/Mo, 3 req/s
- **Starter** ($6/Mo) — 123,000 calls/Mo, 12 req/s
- **Pro** ($16/Mo) — 578,000 calls/Mo, 30 req/s
- **Business** ($39/Mo) — 3,430,000 calls/Mo, 60 req/s

## Endpoints

### DCA

#### `GET /v1/calculate` — DCA outcome + lump-sum comparison

**Parameters:**
- `prices` (query, required, string) — Asset price at each buy, comma-separated oldest first Example: `100,95,110,90,105,120,115,100,130,125,140,135`
- `contribution` (query, required, string) — Cash invested each period Example: `100`
- `fee_pct` (query, optional, string) — Fee percent per buy (default 0) Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dca-api/v1/calculate?prices=100%2C95%2C110%2C90%2C105%2C120%2C115%2C100%2C130%2C125%2C140%2C135&contribution=100&fee_pct=0"
```

**Response:**
```json
{
    "data": {
        "profit": 251.57,
        "source": "DCA",
        "winner": "lump_sum",
        "fee_pct": 0,
        "periods": 12,
        "roi_pct": 20.9642,
        "lump_sum": {
            "units": 12,
            "value": 1620,
            "profit": 420,
            "roi_pct": 35,
            "buy_price": 100
        },
        "total_units": 10.75237033,
        "average_cost": 111.60329895,
        "current_price": 135,
        "current_value": 1451.57,
        "total_invested": 1200,
        "dca_vs_lump_sum": -168.43,
        "contribution_per_period": 100
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:30.189Z",
        "request_id": "4a67d026-c245-4cd0-abe8-9ab90139bcb5"
    },
    "status": "ok",
    "message": "DCA calculated",
    "success": true
}
```

#### `GET /v1/compare` — DCA vs lump-sum vs best/worst-case timing

**Parameters:**
- `prices` (query, required, string) — Asset price at each buy, comma-separated Example: `100,95,110,90,105,120,115,100,130,125,140,135`
- `contribution` (query, required, string) — Cash invested each period Example: `100`
- `fee_pct` (query, optional, string) — Fee percent per buy (default 0) Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dca-api/v1/compare?prices=100%2C95%2C110%2C90%2C105%2C120%2C115%2C100%2C130%2C125%2C140%2C135&contribution=100&fee_pct=0"
```

**Response:**
```json
{
    "data": {
        "note": "best_case / worst_case = investing the whole sum at the lowest / highest price in the series (timing bounds).",
        "source": "DCA",
        "fee_pct": 0,
        "periods": 12,
        "ranking": [
            "best_case",
            "lump_sum",
            "dca",
            "worst_case"
        ],
        "strategies": {
            "dca": {
                "units": 10.75237033,
                "value": 1451.57,
                "profit": 251.57,
                "roi_pct": 20.9642,
                "avg_cost": 111.60329895
            },
            "lump_sum": {
                "units": 12,
                "value": 1620,
                "profit": 420,
                "roi_pct": 35,
                "buy_price": 100
            },
            "best_case": {
                "units": 13.33333333,
                "value": 1800,
                "profit": 600,
                "roi_pct": 50,
                "buy_price": 90
            },
            "worst_case": {
                "units": 8.57142857,
                "value": 1157.14,
                "profit": -42.86,
                "roi_pct": -3.5714,
                "buy_price": 140
            }
        },
        "current_price": 135,
        "total_invested": 1200
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:30.292Z",
        "request_id": "25d5e019-c2c6-4b8a-af32-7d9e1a872a7d"
    },
    "status": "ok",
    "message": "Strategies compared",
    "success": true
}
```

#### `GET /v1/meta` — Service metadata and endpoint list

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dca-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "prices = the asset price at each buy, comma-separated oldest first. contribution = cash invested each period. fee_pct optional.",
        "source": "Computed in-process from caller-supplied prices (no upstream)",
        "service": "dca-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/compare": "DCA vs lump-sum vs best/worst-case timing (prices=..., contribution=100).",
            "GET /v1/schedule": "Per-period breakdown (prices=..., contribution=100).",
            "GET /v1/calculate": "DCA outcome + lump-sum comparison (prices=100,80,120,100, contribution=100)."
        },
        "description": "Live dollar-cost-averaging analytics computed on demand from a price series. The calculate endpoint returns the outcome of investing a fixed amount each period (total invested, units, average cost, current value, profit, ROI) with a lump-sum comparison; the schedule endpoint returns the per-period breakdown; the compare endpoint ranks dollar-cost averaging against lump-sum, best-case and worst-case timing. Computed live from your input, nothing stored — works for stocks, crypto, ETFs or forex. A dollar-cost-averaging engine, distinct from compound-interest and return-analysis tools.",
        "upstream_status": "ok"
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:30.387Z",
        "request_id": "96af1ea3-b988-46d4-a6c8-6f6e1e4ede20"
    },
    "status": "ok",
    "message": "Meta",
    "
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/schedule` — Per-period DCA breakdown

**Parameters:**
- `prices` (query, required, string) — Asset price at each buy, comma-separated Example: `100,95,110,90,105,120,115,100,130,125,140,135`
- `contribution` (query, required, string) — Cash invested each period Example: `100`
- `fee_pct` (query, optional, string) — Fee percent per buy (default 0) Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dca-api/v1/schedule?prices=100%2C95%2C110%2C90%2C105%2C120%2C115%2C100%2C130%2C125%2C140%2C135&contribution=100&fee_pct=0"
```

**Response:**
```json
{
    "data": {
        "source": "DCA",
        "fee_pct": 0,
        "periods": 12,
        "schedule": [
            {
                "price": 100,
                "value": 100,
                "period": 1,
                "avg_cost": 100,
                "units_bought": 1,
                "cumulative_units": 1,
                "cumulative_invested": 100
            },
            {
                "price": 95,
                "value": 195,
                "period": 2,
                "avg_cost": 97.43589744,
                "units_bought": 1.05263158,
                "cumulative_units": 2.05263158,
                "cumulative_invested": 200
            },
            {
                "price": 110,
                "value": 325.79,
                "period": 3,
                "avg_cost": 101.29240711,
                "units_bought": 0.90909091,
                "cumulative_units": 2.96172249,
                "cumulative_invested": 300
            },
            {
                "price": 90,
                "value": 366.56,
                "period": 4,
                "avg_cost": 98.21172171,
                "units_bought": 1.11111111,
                "cumulative_units": 4.0728336,
                "cumulative_invested": 400
            },
            {
                "price": 105,
                "value": 527.65,
                "period": 5,
                "avg_cost": 99.4982393,
                "units_bought": 0.95238095,
                "cumulative_units": 5.02521455,

…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/dca-api
OpenAPI spec: https://www.oanor.com/api/dca-api/openapi.json
