No description
Find a file
eliashenrich 475e0583c2
All checks were successful
Deploy Service / deploy (release) Successful in 22s
Run Pipeline on Release
2025-09-08 10:20:04 +02:00
.forgejo/workflows Run Pipeline on Release 2025-09-08 10:20:04 +02:00
src Initial commit 2025-09-02 10:31:56 +02:00
.env.example Initial commit 2025-09-02 10:31:56 +02:00
.gitignore Initial commit 2025-09-02 10:31:56 +02:00
package-lock.json Initial commit 2025-09-02 10:31:56 +02:00
package.json Initial commit 2025-09-02 10:31:56 +02:00
README.md Update Readme 2025-09-02 10:38:12 +02:00

Trader Joes - Trade Republic ticker

Dieses Projekt ist ein leichtgewichtiger Node.js-Dienst, der Live-Marktdaten (Ticker) von Trade Republic per WebSocket abonniert und in einer Postgres-Datenbank speichert. Es liest aktive Symbole aus einer watchlist-Tabelle, verbindet sich zum Trade-Republic-WebSocket, registriert sich, abonniert die Ticker und schreibt relevante Bid-Updates in die Tabelle ticker_tr. Um die Datenmenge zu begrenzen, kommt ein Deadband-Filter zum Einsatz.

Kurzüberblick

  • Datenquelle: WebSocket wss://api.traderepublic.com/ mit Registrierung und Symbol-Abos.
  • Watchlist: Aus Postgres (watchlist) mit Filter ticker_type='Trade Republic' AND status='active'.
  • Speicherung: ticker_tr mit Feldern watchlist_id, symbol, price, timestamp, size.
  • Deadband: Nur Insert, wenn Änderung groß genug ist (Price > 0.1%, Size > 0.1%, Timestamp > 60s).
  • Robustheit: Periodische Verbindungsrotation (1045 Minuten) und zufälliger Reconnect (160 Sekunden).
  • Logging: Steuerbar über LOG_LEVEL (error, warn, info, debug).

Setup

  • Install Node.js 18+.
  • Set Postgres env vars: PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE (or DATABASE_URL).
  • Optional SSL: set PGSSL=true if your provider requires SSL.

Install

  • Run npm install to install dependencies.

Run

  • Execute npm start to connect via WebSocket to Trade Republic, register, subscribe to all watchlist entries where ticker_type = 'Trade Republic' and status = 'active', and insert message.bid updates into ticker_tr.
  • Previous query-only script: npm run query to print ticker_symbols.

Details

  • Registration frame: connect 31 {"locale":"de","platformId":"webtrading","platformVersion":"opera - 120.0.0","clientId":"app.traderepublic.com","clientVersion":"7.38.2"}
  • Subscription frames (per symbol): sub <id> {"type":"ticker","id":"<SYMBOL>"}<id> uses the DB row id (fallback to internal counter if missing).
  • Incoming frames parsed as <id> A <json>; inserts message.bid.{symbol,price,timestamp,size} into ticker_tr alongside watchlist_id (copied from the DB row id used for the subscription).
  • DB filter for subscriptions and query: ticker_type = 'Trade Republic' AND status = 'active'.

Reconnect & Rotation

  • The WebSocket connection is rotated at random intervals between 1045 minutes.
  • After a close (rotation or remote), it reconnects after a random 160 seconds delay.
  • On each reconnect, the watchlist is fetched again from the DB before subscribing.

Logging

  • Control verbosity via LOG_LEVEL env var: error, warn, info (default), debug.
  • At info: logs startup, subscribe count, STORE decisions, and shutdown; skips per-tick raw frames.
  • At debug: logs raw WS frames and SKIP decisions as well.