---
related_nodes: ["indicator", "chart_plot", "candle_display"]
---

# Alpaca Market Data

Fetches latest quotes, latest eligible trades, or historical OHLC bars for stocks and ETFs from Alpaca Markets.

## When to Use

- Checking bid/ask availability or an executed trade price for trading decisions
- Fetching historical bars for technical analysis
- Backtesting strategies
- Building market dashboards with price charts

## Configuration

- `connection` - Alpaca connection id. Required.
  - Select it from the dropdown; the stored value is the connection's id, not its name.
- `fetch_type` - Type of data to fetch (default: `"quote"`)
  - `"quote"` - Latest bid/ask
  - `"trade"` - Latest eligible executed trade, not a quote midpoint or prior session close
  - `"bars"` - OHLC bars, for indicators and charts
- `timeframe` - Bar interval (default: `"1Day"`)
  - `"1Min"`, `"5Min"`, `"15Min"`, `"1Hour"`, `"1Day"`, `"1Week"`, `"1Month"`
  - Applies only when `fetch_type` is `"bars"`
  - Weekly and monthly bars come from Alpaca directly; do not resample daily bars
- `lookback` - Number of bars, 1-1000 (default: 30)
  - Applies only when `fetch_type` is `"bars"`
  - The node returns exactly this many bars or fails, unless you set `min_bars`.
    With `min_bars` set, it returns every available bar up to `lookback`, newest first.
- `adjustment` - How Alpaca adjusts historical bars (default: `"split"`)
  - `"split"` - Split-adjusted
  - `"all"` - Split, dividend and spin-off adjusted
  - `"dividend"` - Dividend-adjusted only
  - `"raw"` - Raw (as traded)
  - Applies only when `fetch_type` is `"bars"`
- `min_bars` - Minimum Bars, a whole number from 0 to 1000 (default: empty)
  - Applies only when `fetch_type` is `"bars"`
  - The history is too short only if fewer than `min_bars` are available. Set it to `0`
    to accept an empty series. A fetch refuses `min_bars` above `lookback`.
- `exclude_forming_bars` - Drop the current, still-forming bar (default: `false`)
  - Applies only when `fetch_type` is `"bars"`
  - Only completed bars count toward `lookback` and `min_bars` when this is on.
  - Intraday bars form for their own duration. For a day, week or month, the node reads
    Alpaca's market calendar once per run from the account selected in **Calendar account**.
    The bar stops forming at its last session's regular close (16:00 ET, or 13:00 ET on a
    half day). Holidays can move the last session earlier. After the close, only volume can
    still grow through extended hours until 20:00 ET.
- `calendar_account` - Alpaca account for market calendar reads (default: `"paper"`)
  - `"paper"` - Paper account key
  - `"live"` - Live account key
  - Shown when `exclude_forming_bars` is `true`; used only for `"1Day"`, `"1Week"` and
    `"1Month"` bars.
- `feed` - Which data feed to draw on (default: `"iex"`)
  - `"iex"` - one venue's share of consolidated volume, included with every account
  - `"sip"` - the full consolidated tape; requires an Alpaca market data subscription
- `errors_as_values` - Emit API errors and malformed requests as a value (default: `false`)
  - Adds an `error` output socket and stops a failure from failing the node
  - No effect when the failure mode is Route to error output; see **Errors as values**
- `retry` - Retries up to 5 attempts by default; set Retry to Off to send once
  - Every request is a read, sent again freely; see [Retries](http_get.md#retries)

## Input

- `input` - the symbol, or symbols, to fetch:
  - One symbol: `"AAPL"`
  - Several: `["AAPL", "TSLA", "MSFT"]`
  - Symbols are case-insensitive; anything that is not a ticker is rejected

## Output

For `fetch_type: "quote"`:

```json
{
  "symbol": "AAPL",
  "bid": 185.50,
  "ask": 185.55,
  "bid_size": 100,
  "ask_size": 200,
  "timestamp": "2024-01-15T10:30:00Z"
}
```

A quote contains only the book observation, never `last`, `mid`, or `close`. An absent side
is explicit JSON `null`, not zero. Sizes and the timestamp remain the provider's observations:

```json
{
  "symbol": "NVDA",
  "bid": 219.49,
  "ask": null,
  "bid_size": 100,
  "ask_size": 0,
  "timestamp": "2026-09-04T20:00:03.123456789Z"
}
```

Either or both prices can be null. Missing, null, or malformed required provider fields,
and negative quote prices, fail the fetch instead of becoming an absent side.

For `fetch_type: "trade"`:

```json
{
  "symbol": "AAPL",
  "price": 187.25,
  "size": 37,
  "timestamp": "2026-09-04T19:59:58.086175744Z"
}
```

`price`, `size`, and `timestamp` are the provider's trade observations on the selected feed.
Alpaca returns the latest trade eligible to update bar prices; it excludes some conditions,
including odd lots. This is not a guarantee of the most recently executed trade of every
condition, or a prior session close. Use bars' `close` for a bar close.

**Breaking output change:** quote `last` is removed and bid/ask can be null. Consumers of
`last` must deliberately select trade `price` or bar `close` according to intent; workflows
are not automatically converted.

For `fetch_type: "bars"`, the bars themselves:

```json
[
  {
    "timestamp": "2024-01-15T10:00:00Z",
    "open": 185.50,
    "high": 186.20,
    "low": 184.80,
    "close": 185.90,
    "volume": 1500000,
    "vwap": 185.60
  }
]
```

Bars are newest first. This is what the Technical Indicators node takes, so the two connect
directly.

A scalar symbol returns one payload. A symbol array returns an array of payloads in input
order, including a one-element array and repeated symbols. By default, missing data for any
requested symbol fails the whole fetch; there is no successful partial batch or quote/bar
fallback for a missing trade. Turn on `errors_as_values` to keep the symbols Alpaca could
serve.

## Errors as values

With `errors_as_values` on, the node grows a second output socket and never fails a run for
an API error or a malformed input:

- `output` keeps input arity. A failed symbol holds its position as `null`. When nothing
  could be fetched the socket is skipped, so nothing downstream runs on it.
- `error` carries an array with one entry per failure, and is skipped when the fetch
  succeeded:

```json
[
  {
    "symbol": "VIX",
    "message": "Alpaca returned no quote for VIX",
    "kind": "missing_data",
    "retryable": false
  }
]
```

`symbol` is present when the failure belongs to one symbol, and absent when the whole
request failed. `status` carries Alpaca's status code when it answered with one. `kind` is
one of `api`, `transport`, `decode`, `missing_data`, `invalid_data`, `insufficient_history`,
`calendar` or `malformed_request`. A `calendar` failure is retryable when Alpaca's underlying
API error is retryable. An unusable calendar close is `invalid_data`; that error and
`malformed_request` (such as `min_bars` above `lookback`) are not retryable.

A connection that is missing or of the wrong type still fails the node: that is
misconfiguration, not an API error, and it must show red rather than route down an error
branch forever.

With the failure mode set to **Route to error output** (`base_config.failure_mode:
"route_to_error"`), `errors_as_values` has no effect: the node runs as with it off. Any
failure, including one symbol of several, fails the whole fetch and goes out on the routed
`error` output as the node error value (`node_id`, `node_type`, `message`, `causes`), and
`output` is skipped.

## Examples

### Single symbol bid/ask check

```json
{
  "connection": "01JBQ8XZ4N7K2M9P3R5T6V8W0Y",
  "fetch_type": "quote"
}
```

Input: `"AAPL"`

### Executed-price check

```json
{
  "connection": "01JBQ8XZ4N7K2M9P3R5T6V8W0Y",
  "fetch_type": "trade",
  "feed": "iex"
}
```

Input: `"AAPL"` → the latest eligible trade, with its price, size, and execution timestamp.

### Historical bars for analysis

```json
{
  "connection": "01JBQ8XZ4N7K2M9P3R5T6V8W0Y",
  "fetch_type": "bars",
  "timeframe": "1Day",
  "lookback": 100
}
```

Input: `"TSLA"` → the last 100 daily bars.

### Several symbols at once

```json
{
  "connection": "01JBQ8XZ4N7K2M9P3R5T6V8W0Y",
  "fetch_type": "bars",
  "timeframe": "1Hour",
  "lookback": 24
}
```

Input: `["AAPL", "MSFT", "GOOGL"]` → an array of three bar series, in that order.

Each quote or trade batch costs one provider request regardless of the number of symbols.

### Feeding the indicator node

```json
{
  "connection": "01JBQ8XZ4N7K2M9P3R5T6V8W0Y",
  "fetch_type": "bars",
  "timeframe": "1Day",
  "lookback": 50
}
```

Indicators need `"bars"`; a quote or trade carries no series to compute over. Set `lookback` to at
least the longest period configured on the indicator node. A batch fetch feeds a batch of
indicator results without anything in between.

## Choosing a fetch type

| Use case | Fetch type | Timeframe |
|---|---|---|
| Bid/ask availability check | `quote` | n/a |
| Executed-price check | `trade` | n/a |
| Day trading | `bars` | `1Min` or `5Min` |
| Swing trading | `bars` | `1Hour` |
| Long-term analysis | `bars` | `1Day`, `1Week` or `1Month` |
| Technical indicators | `bars` | any |

## Choosing an adjustment

The `split` default applies to every existing bars fetch without an adjustment, including
saved nodes and script calls. Both `split` and `all` adjust prices and volume. The `dividend`
option adjusts prices only. Choose `raw` to restore prices as traded.

## Access

Requires an Alpaca connection holding an API key and secret, added in workspace Settings →
Connections. Alpaca's market calendar is on the trading host for the account your key belongs
to. Paper and live accounts use different keys. Existing bars fetches that exclude forming
day, week or month bars read the calendar from the paper account unless you set
`calendar_account` to `"live"`. The calendar read places no trades.

The `feed` setting decides data quality. `iex` covers a single venue, so its bars and every
indicator derived from them reflect a fraction of traded volume. `sip` is the full
consolidated tape and needs a paid Alpaca subscription; selecting it without one makes Alpaca
reject the request.

## Runtime Errors

| Error | Cause | Remediation |
|---|---|---|
| `Connection is required` | No connection selected | Select a connection in node settings |
| `expected ULID connection id` | The connection field holds a name | Select the connection from the dropdown |
| `Connection '<id>' not found` | The connection was deleted | Select an existing connection |
| `Expected a symbol or an array of symbols` | Input was neither | Send a ticker string or an array of them |
| `alpaca API error 403` | Feed not covered by the subscription | Set `feed` to `"iex"`, or subscribe |
| `alpaca API error 429` | Rate limit; sent again as the `retry` setting allows before failing | Reduce request frequency, or raise the retry attempts |
| `Alpaca has only {available} of the {required} {timeframe} bars required for {symbol}` | Less history than `min_bars`, or than `lookback` if `min_bars` is empty | Lower the required count or choose a shorter timeframe |
| `min_bars ({min_bars}) is above lookback ({lookback}); at most lookback bars are returned` | Minimum Bars exceeds `lookback` | Set `min_bars` at or below `lookback` |
| `could not read the market calendar from the Alpaca {account} account: {source}` | The fetch fails if the calendar request fails | If Alpaca returns 401 or 403, set Calendar account to the account your Alpaca key belongs to |
| `Alpaca's market calendar states a close on {date} that New York time cannot place` | Alpaca supplied a session close that cannot be resolved in New York time | Report the calendar date if the error persists |
| `Alpaca returned an unusable <field>` | The provider sent a negative quote price or unusable bar field | Retry; report if it persists |
| `Alpaca returned no quote/trade for <symbol>` | Requested data is absent | Check the symbol and feed; no substitute price is supplied |

## Common Mistakes

- **Quote or trade data into the indicator node.** Indicators need a bar series. Set `fetch_type` to
  `"bars"`.
- **`lookback` below the indicator's required bar count.** RSI(14) needs 15 bars. Raise
  `lookback` to at least the number the indicator needs.
- **Assuming IEX is the whole market.** It is one venue. Use `sip` where completeness matters.
- **A 1Min timeframe for a monthly trend.** Match the timeframe to the horizon.
- **Treating a quote as an executed price.** Bid/ask describe the book and may be null; select
  `"trade"` for an eligible trade price.
- **Treating the latest trade as a previous close.** It is a trade observation, not a completed
  session. Fetch the appropriate bars when a close is needed.

## Tips

- Ask for several symbols at once; quotes and trades each cost one request per batch.
- Free accounts allow 200 requests/minute.
- Prices serialize as JSON numbers; absent quote sides serialize as `null`.
- Bars come back newest first.
