Log crypto funding rates and open interest to Google Sheets

By General Input

Every 8 hours, snapshot funding rates and open interest from CoinGlass into a Google Sheet so you build a clean history for backtesting and your trading journal.

Integrations

  • CoinGlass
  • Google Sheets

Type

Deterministic Code

Categories

  • Finance
  • Operations

Build me a deterministic ETL workflow that logs crypto derivatives data to Google Sheets on a schedule. This is structured time-series logging only. No summarization, no judgement calls, no branching on content. Just a fixed loop over a watchlist that writes rows.

Trigger: cron, every 8 hours, aligned with the standard perpetual funding cycle (00:00, 08:00, 16:00 UTC). I want it to run on the same cadence that major exchanges settle funding so each snapshot lines up with a real funding event.

Inputs I want exposed as workflow variables:

- coins: a list of ticker symbols to track. Default to ["BTC", "ETH", "SOL"] and let me extend it later.

- spreadsheetId: the Google Sheet to write to.

For each coin in the watchlist, do the following in a loop:

1. Call CoinGlass "Get Funding Rate by Exchange" for the coin. This returns current funding rates across every exchange that lists the perp.

2. Call CoinGlass "Get Open Interest by Exchange" for the coin. This returns current open interest per exchange in both USD and coin units.

3. Flatten and join the two responses by exchange into one row per exchange with these columns: timestamp (ISO 8601 UTC of the run), coin, exchange, funding_rate, open_interest_usd, open_interest_coin. If an exchange shows up in one response but not the other, still write the row and leave the missing field blank.

4. Append those rows to a tab in the Google Sheet named after the coin ("BTC", "ETH", "SOL", etc.) using Google Sheets "Append Values" with valueInputOption USER_ENTERED so numbers are stored as numbers.

First-run setup: before the main loop, check whether each coin's tab exists in the spreadsheet. If not, use Google Sheets "Batch Update Spreadsheet" to add a new tab named after the coin and seed row 1 with the header row [timestamp, coin, exchange, funding_rate, open_interest_usd, open_interest_coin]. After the tab exists, never recreate it; just append.

Error handling: if CoinGlass returns a non-zero code envelope or 429, log the error and skip that coin for this run. Do not block other coins. If Google Sheets returns 429, retry with exponential backoff (1s, 2s, 4s, capped at 16s).

Output: nothing user-facing. The success signal is that the sheet has fresh rows. Optionally include a final summary log line with how many rows were written per coin so I can see it in the run history.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageLet support send one-off Loops emails without an engineerStop cold emails to anyone with a live deal in PipedriveiMessage campaign console with pre-flight checks and delivery boardLinkedIn Ads budget pacing dashboard for every client accountFront desk appointment confirmation board for the next 3 daysGive your team Looker numbers without buying more seatsBuild audience segments from product usage and push to LoopsTurn the people who engage with your posts into Pipedrive leads