agentleFS
SiftingIOSiftingIO/siftingio-ai-rules/.cursor/rules/siftingio-historical.mdc

siftingio-ai-rules / rules

Cursor rule0 starsChanged 6 months agoMITView on GitHub

SiftingIO historical OHLCV bars, /v1/hist/{stocks,forex,crypto,dex}/.../bars. Intervals, gzip requirement, abbreviated bar fields, and cursor pagination.

  • Reads credentials

The file

We split this siftingio-historical.mdc into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Stop paginating when meta.next_cursor is null/absent, don't loop forever on the last page.

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
siftingio-historical.mdc
---
description: SiftingIO historical OHLCV bars, /v1/hist/{stocks,forex,crypto,dex}/.../bars. Intervals, gzip requirement, abbreviated bar fields, and cursor pagination.
globs: ["**/*.py", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.go", "**/*.rb", "**/*.java"]
alwaysApply: false
---

# SiftingIO Historical OHLCV (`/v1/hist/*`)

Time-bucketed bars under a uniform `{ data, meta }` envelope, so one parser works across asset classes. See `siftingio-core` for auth and errors. **All historical bar endpoints are gzip-required** → `406 gzip_required` without `Accept-Encoding: gzip`.

## Endpoints

- `GET /v1/hist/stocks/:ticker/bars`: US equities (regular hours 09:30-16:00 ET, Mon-Fri, excl. holidays).
- `GET /v1/hist/forex/:pair/bars`: forex pairs.
- `GET /v1/hist/crypto/:symbol/bars`: crypto.
- `GET /v1/hist/dex/:symbol/bars`: DEX pools (chain-prefixed symbol, e.g. `eth:WETH-USDC`).

## Parameters (shared)

| Param | In | Notes |
| --- | --- | --- |
| `:ticker`/`:pair`/`:symbol` | path | Case-insensitive. Stocks: 1-10 chars, allows `.`/`-` (e.g. `BRK.A`, `TSLA.WS`). |
| `start` | query | Inclusive lower bound. `YYYY-MM-DD` (interpreted in US Eastern) or full RFC3339 (read as UTC). |
| `end` | query | Inclusive upper bound, same shape. Defaults to now. |
| `interval` | query | `1m`, `5m`, `15m`, `30m`, `1h`, `1d`, `1w`, `1mo`. Default `1m`. |
| `limit` | query | Bars per page. Default 1000, max 2000. |
| `cursor` | query | Opaque pagination token from `meta.next_cursor`. Omit on first request; pass back verbatim. |
| `Accept-Encoding` | header | **Must include `gzip`** or you get `406 gzip_required`. |

## Bar fields (abbreviated)

- `t`: bucket open time, **int64 Unix epoch milliseconds** (same convention as live ticks).
- `o` / `h` / `l` / `c`: open / high / low / close, float prices.
- `v`: volume (integer share/contract volume for stocks).

Known symbol with no bars in range → `200` with `data: []` (not an error). Halted/delisted but still in the registry → empty window. Unknown symbol → `404 not_found`.

## Examples

```bash
# curl, note the gzip header and --compressed
curl -H "X-API-Key: $KEY" -H "Accept-Encoding: gzip" --compressed \
  "https://api.sifting.io/v1/hist/stocks/AAPL/bars?start=2026-05-09&end=2026-05-09&interval=1m"
```

```python
# Python, requests handles gzip transparently; paginate via meta.next_cursor
import os, requests

BASE = "https://api.sifting.io"
s = requests.Session()
s.headers.update({"X-API-Key": os.environ["SIFTING_API_KEY"], "Accept-Encoding": "gzip"})

def bars(ticker, **params):
    cursor = None
    while True:
        if cursor:
            params["cursor"] = cursor
        r = s.get(f"{BASE}/v1/hist/stocks/{ticker}/bars", params=params)
        r.raise_for_status()
        body = r.json()
        yield from body["data"]
        cursor = body["meta"].get("next_cursor")
        if not cursor:          # null/omitted on the final page
            break

for bar in bars("AAPL", start="2026-05-09", end="2026-05-09", interval="1m"):
    print(bar["t"], bar["c"])   # t is in ms
```

```typescript
// JavaScript / TypeScript, fetch decompresses gzip automatically
const BASE = "https://api.sifting.io";
const h = { "X-API-Key": process.env.SIFTING_API_KEY!, "Accept-Encoding": "gzip" };

async function* bars(ticker: string, params: Record<string, string>) {
  let cursor: string | undefined;
  do {
    const qs = new URLSearchParams({ ...params, ...(cursor ? { cursor } : {}) });
    const res = await fetch(`${BASE}/v1/hist/stocks/${ticker}/bars?${qs}`, { headers: h });
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    const body = await res.json();
    yield* body.data;
    cursor = body.meta.next_cursor ?? undefined;
  } while (cursor);
}

for await (const bar of bars("AAPL", { start: "2026-05-09", end: "2026-05-09", interval: "1m" })) {
  console.log(new Date(bar.t).toISOString(), bar.c); // bar.t is already ms
}
```

Response:

```json
{
  "data": [
    { "t": 1746793800000, "o": 198.41, "h": 198.55, "l": 198.36, "c": 198.50, "v": 12340 }
  ],
  "meta": { "symbol": "AAPL", "interval": "1m", "as_of": "2026-05-09T20:00:03Z", "next_cursor": "eyJvIjoxMDAwfQ" }
}
```

## Gotchas

- **Always send `Accept-Encoding: gzip`**: bars are gzip-required.
- `t` is **milliseconds**, `new Date(t)` is correct in JS; in Python use `t / 1000`.
- Date-only `start`/`end` are **US Eastern** for stocks; pass full RFC3339 if you need UTC.
- Stop paginating when `meta.next_cursor` is null/absent, don't loop forever on the last page.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.