Skip to content
aeon/feed

Code examples

Every example uses wss://aeonfeed.com/ws. Replace it with your own host if you self-host.

Keep a local order-book map (JavaScript)

js
const books = new Map(); // symbol -> Map(exchange -> quote)

const ws = new WebSocket("wss://YOUR_HOST/ws?subscribe=ticker:BTCUSDT,ticker:ETHUSDT");
ws.onmessage = (e) => {
  const m = JSON.parse(e.data);
  if (m.type !== "ticker" && m.type !== "snapshot") return;
  if (!m.s) return;
  if (m.type === "snapshot") books.set(m.s, new Map());
  const book = books.get(m.s) ?? new Map();
  for (const q of m.data) book.set(q.ex, q);
  books.set(m.s, book);

  const bids = [...book.values()].sort((x, y) => y.b - x.b);
  console.log(m.s, "best bid", bids[0].b, "on", bids[0].ex);
};

Cross-exchange arbitrage watcher (Python)

python
import asyncio, json, websockets

async def main():
    async with websockets.connect("wss://YOUR_HOST/ws?subscribe=agg:*") as ws:
        async for raw in ws:
            m = json.loads(raw)
            if m["type"] not in ("agg", "snapshot"):
                continue
            for a in m["data"]:
                if a["sp"] < -0.1:  # bid on one venue >0.1% above ask on another
                    print(f'{a["s"]}: buy {a["bax"]} @ {a["ba"]}, sell {a["bbx"]} @ {a["bb"]} ({a["sp"]}%)')

asyncio.run(main())

Crossed spreads are often eaten by fees, withdrawal limits and latency. Treat them as signals, not free money.

React hook

tsx
import { useEffect, useState } from "react";

export function useAggs(url = "wss://YOUR_HOST/ws?subscribe=agg:*") {
  const [aggs, setAggs] = useState<Record<string, { p: number; ch?: number }>>({});
  useEffect(() => {
    const ws = new WebSocket(url);
    ws.onmessage = (e) => {
      const m = JSON.parse(e.data);
      if (m.channel !== "agg:*" || !m.data) return;
      setAggs((prev) => {
        const next = m.type === "snapshot" ? {} : { ...prev };
        for (const a of m.data) next[a.s] = a;
        return next;
      });
    };
    return () => ws.close();
  }, [url]);
  return aggs;
}

Node.js

Node.js 22+ has WebSocket built in, so the browser example runs unchanged. On older versions, use the ws package:

js
import WebSocket from "ws";
const ws = new WebSocket("wss://YOUR_HOST/ws?subscribe=ticker:SOLUSDT");
ws.on("message", (raw) => console.log(JSON.parse(raw.toString())));

Rust, without this server

Want the raw exchange streams in your own Rust app? Use the library directly:

rust
use aeon_market_scanner_rs::{Binance, CEXTrait};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut rx = Binance::new().stream_price_websocket(&["BTCUSDT", "ETHUSDT"], 10, 5000).await?;
    while let Some(p) = rx.recv().await {
        println!("{} bid={} ask={}", p.symbol, p.bid_price, p.ask_price);
    }
    Ok(())
}

Aeon Feed is free, with no ads and no paid tier. Donations keep it that way.

  • Keeping the project alive: servers and bandwidth for a free, public real-time feed.
  • Maintenance: keeping up with exchange API changes, fixing bugs, adding pairs and exchanges.
  • New features: cross-exchange arbitrage signals are next on the roadmap.
Tron (TRC-20)
Tether (USDT)
TXFraDKB…ZCAmpi

Send USDT only on the network you selected. TRC-20 has the lowest fees.