惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
F
Fortinet All Blogs
D
Docker
博客园 - 司徒正美
腾讯CDC
Recent Announcements
Recent Announcements
The Cloudflare Blog
B
Blog RSS Feed
GbyAI
GbyAI
T
Tailwind CSS Blog
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Building a Crypto Funding Rate Data Pipeline with Python
Kai · 2026-05-18 · via DEV Community

Kai

I needed funding rate data across multiple exchanges in a single place. Nothing free gave me what I wanted: historical rates, cross-exchange comparisons, and annualised calculations. So I built it.

Here's how the data pipeline works, and what I learned along the way.

The Architecture

Exchange APIs (Bybit, Binance)
        |
    Scheduled collector (every 8h)
        |
    PostgreSQL + TimescaleDB
        |
    JSON snapshot generator (3x/day)
        |
    Static site (Astro on Cloudflare Pages)

Enter fullscreen mode Exit fullscreen mode

The key design decision: don't serve live API queries to the frontend. Instead, generate JSON snapshots on a schedule and serve them as static files. This gives you:

  • Zero backend load from page views
  • Free hosting on Cloudflare Pages
  • Sub-50ms page loads globally
  • No API rate limits to worry about

Collecting the Data

Both Bybit and Binance expose funding rate history via their public REST APIs. No authentication required for reading rates.

The collector runs on a schedule, pulls the latest rates for each asset, and writes them to TimescaleDB (PostgreSQL with time-series extensions). Each row stores:

  • Asset (BTC, ETH, SOL, etc.)
  • Exchange
  • Funding rate (raw 8h)
  • Annualised rate
  • Timestamp

Annualising Rates

This is where most tools get it wrong. A raw funding rate of 0.01% per 8h doesn't mean 0.03% per day. Funding compounds:

annualised = ((1 + rate_8h) ** (3 * 365) - 1) * 100

Enter fullscreen mode Exit fullscreen mode

The 3 * 365 comes from 3 settlements per day, 365 days per year. At 0.01% per 8h, that's ~11.6% annualised, not 10.95% (which is what simple multiplication gives you).

The difference matters when you're comparing a 0.03% rate against a 0.05% rate. Simple multiplication says the spread is 0.02%. Compound calculation says it's larger.

The Snapshot Generator

Every 8 hours, a scheduled job:

  1. Queries the latest rates from the database
  2. Calculates cross-exchange spreads
  3. Generates JSON files per asset
  4. Triggers a site rebuild on Cloudflare Pages

The static site reads these JSON files at build time using Astro's data layer. No runtime database queries.

What I'd Do Differently

  • Start with TimescaleDB from day one. I initially used plain PostgreSQL and migrated later. Time-series queries (rolling averages, period comparisons) are dramatically faster with hypertables.
  • Collect more frequently than you display. I collect every 8h but could go hourly. Having higher-resolution data lets you spot intraday patterns even if you only show 8h snapshots publicly.
  • Add WebSocket for liquidation data early. REST polling works for funding rates (they only change every 8h). Liquidation events are real-time — you need a persistent WebSocket connection.

The Result

FundingKai tracks 10 major assets across exchanges. The data pipeline runs autonomously — no manual intervention since launch.

If you're building something similar, the key insight is: separate collection from presentation. Collect into a proper database, serve via static snapshots. Your data pipeline and your frontend have completely different reliability and performance requirements.


The data is live at fundingkai.com. Built with Python, PostgreSQL/TimescaleDB, Astro, and Cloudflare Pages.