← notes

Reporting three change windows without storing any history

Oct 30, 2020

Post the WBTC price and its 1-hour, 24-hour and 7-day changes for assets with option markets on Siren.

One Ruby script, chatterbot for posting, CoinMarketCap for the data. Price floored to a whole dollar, percentages rounded to two places, floor on price because a figure that ticks up by rounding reads as wrong to anyone watching, and round on percentages because they need the precision.

The design fact worth keeping is that the bot stores nothing. All three change windows come back in the same API response, computed by the vendor, so there is no history to keep and no state to get wrong. That is why a bot like this is fifty lines instead of a service.

It is also the boundary. The moment you want a window the vendor does not offer, since the market opened, since I bought it, since the last announcement, you need your own time series: a datastore, a collection schedule, backfill for the gap when collection was down, and a decision about resolution. That is a different program, and the fifty-line version gives no warning it is about to become one.

Credentials sit in plaintext in sirenticker.yml, which is chatterbot’s default and got committed anyway.