Skip to content

fix(sensor): re-point to www.bitstamp.net after source drift - #18

Merged
rbaker5 merged 1 commit into
mainfrom
fix/sensor-bitstamp.net
Jul 6, 2026
Merged

rbaker5 merged 1 commit into
mainfrom
fix/sensor-bitstamp.net

Conversation

@continuous-research-bot

Copy link
Copy Markdown
Contributor

Why

Issue #17: the sensor's declared source, api.exchange.coinbase.com, was
added to .research/source-firewall.json (simulated feed retirement),
so every sense run drifts with source-firewalled instead of producing an
edition.

Evidence trail

Chosen source: https://www.bitstamp.net/api/v2/ohlc/btcusd/?step=86400&limit=20

  • Host www.bitstamp.net is not present in .research/source-firewall.json
    (only api.exchange.coinbase.com is blocked).

  • No API key required — plain unauthenticated GET.

  • Plainly fetchable JSON (verified via curl, no JS rendering needed).

  • Confirmed live via curl on 2026-07-04 (UTC "today" = 2026-07-04):

    {"data": {"pair": "BTC/USD", "ohlc": [
      {"timestamp": "1781913600", "open": "63487.34", "high": "64334.69", "low": "63133.21", "close": "64245.72", "volume": "610.71977158"},
      {"timestamp": "1782000000", "open": "64225.99", "high": "64522.00", "low": "63197.23", "close": "63237.18", "volume": "551.09674747"},
      ...
      {"timestamp": "1783123200", "open": "62522.45", "high": "62888...", "close": "62541.58", "volume": "..."}
    ]}}

    Decoding timestamp shows the buckets are UTC-midnight-aligned, one per
    calendar day, ascending, with the last bucket (1783123200 →
    2026-07-04T00:00:00Z) being today's still-in-progress candle:

    1782864000 2026-07-01T00:00:00.000Z close=59963.46
    1782950400 2026-07-02T00:00:00.000Z close=61479.10
    1783036800 2026-07-03T00:00:00.000Z close=62522.46
    1783123200 2026-07-04T00:00:00.000Z close=62541.58   <- today, incomplete, filtered out
    
  • Entry contract: step=86400&limit=20 returns 20 daily buckets; after
    filtering out the current (incomplete) UTC day, 19 completed days remain
    — well over the required minimum of 9. Each bucket maps directly to
    { day: "YYYY-MM-DD", close: Number }, ascending (buckets already arrive
    ascending; sorted defensively by timestamp to guarantee the contract).

Change

sensor.mjs only:

  • SOURCE → Bitstamp's public OHLC endpoint.
  • fetchEntries() → reads res.json().data.ohlc, sorts by timestamp,
    drops the current UTC day, and maps {timestamp, close} (strings) to
    { day, close: Number }.

sensor-lib.mjs, the firewall, workflows, tests, and the artifact schema
are untouched.

Verification

  • node --test → 10/10 passing.
  • node sensor.mjs → emits:
    {"changed":true,"descriptor":"btcusd-2026-07-03","source":"https://www.bitstamp.net/api/v2/ohlc/btcusd/?step=86400&limit=20","retrievedAt":"2026-07-04T12:53:53.971Z","hash":"sha256:...","artifacts":["data/btcusd/btcusd-2026-07-03.json"]}
    No drift report written; data/btcusd/btcusd-2026-07-03.json contains a
    plausible edition (close: 62522.46, ma7_trend: "rising", etc.).

Fixes #17

Coinbase Exchange (api.exchange.coinbase.com) was added to
.research/source-firewall.json (simulated feed retirement), so the sensor
could no longer reach its declared source. Re-point SOURCE and
fetchEntries() to Bitstamp's public OHLC endpoint, which is unauthenticated,
plainly fetchable JSON, and not present in the firewall list.

Fixes #17
@rbaker5
rbaker5 merged commit b303335 into main Jul 6, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sensor drift: cannot produce an edition

1 participant