From 3d92e0d23ccc4ab2d8f5ca1861e58c3a02f2f29a Mon Sep 17 00:00:00 2001 From: 2pk03 Date: Tue, 15 Sep 2026 17:06:22 +0200 Subject: [PATCH] Use Kraken and Coinbase market data --- .env.example | 9 +- README.md | 16 +- com.novatechflow.polydisplay.plist | 2 +- index.html | 6 +- install.sh | 30 +-- server.go | 362 +++++++++++++++++------------ server_test.go | 154 ++++++++++-- 7 files changed, 380 insertions(+), 199 deletions(-) diff --git a/.env.example b/.env.example index 9b66996..dc69019 100644 --- a/.env.example +++ b/.env.example @@ -5,12 +5,11 @@ # # These four are the Polymarket-traded names. Format: # SYM:Name:coingecko-id[,SYM:Name:id…] -# Optional 4th field: Binance symbol if it is not SYM+USDT. +# A legacy fourth field is accepted and reduced to its base symbol. # # install.sh then asks for extra tickers to chart. It looks each one up on -# CoinGecko (id + name) and checks Binance for a USDT pair. No pair is fine: -# the server already serves those from CoinGecko. You can also add tokens later -# in ⚙ search. +# CoinGecko (id + name). Runtime prices and candles come from Kraken with +# Coinbase fallback. You can also add tokens later in ⚙ search. POLYDISPLAY_ASSETS="BTC:Bitcoin:bitcoin,ETH:Ethereum:ethereum,SOL:Solana:solana,XRP:XRP:ripple" @@ -23,5 +22,5 @@ POLYDISPLAY_ASSETS="BTC:Bitcoin:bitcoin,ETH:Ethereum:ethereum,SOL:Solana:solana, # POLYDISPLAY_PIN=000000 # POLYDISPLAY_TOKEN_SECRET= -# Optional: free CoinGecko demo key for higher rate limits +# Optional: free CoinGecko demo key used only by asset search # CG_DEMO_KEY= diff --git a/README.md b/README.md index 196cc55..4692154 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,14 @@ a P/L card (the day's profit as polymarket.com reports it, over a 30-day sparkline, with the 7d, 30d, and all-time figures), then the open positions and recent activity. Right column is charts for a mix of trading and monitoring assets. A Go process on the host serves the page and talks to Polymarket, -Binance, and CoinGecko. Browsers only talk to that process. +Kraken, and Coinbase. CoinGecko is used only for asset search. Browsers only talk +to that process. ``` ┌────────────┐ http ┌─────────────────────────────┐ https │ pad / │ ────────────► │ polydisplayd (Go) │ ──► Polymarket - │ browser │ /api/state │ polls + caches │ ──► Binance - │ │ ◄──────────── │ serves the page │ ──► CoinGecko + │ browser │ /api/state │ polls + caches │ ──► Kraken + │ │ ◄──────────── │ serves the page │ ──► Coinbase └────────────┘ │ /api/config, /api/search │ └─────────────────────────────┘ ``` @@ -36,8 +37,8 @@ Default listen port is 8080 (`POLYDISPLAY_PORT`). Dark/light follows the device. Downloads Go if needed, asks for a Polymarket public address (`0x...`), writes `config.json`, builds `polydisplayd`, and installs a login service: LaunchAgent on macOS, systemd user unit on Linux. At the prompt you can add extra tickers; -those are looked up on CoinGecko. Binance is used at runtime when a USDT pair -exists, otherwise CoinGecko. +those are looked up on CoinGecko. Kraken supplies runtime prices and candles, +with Coinbase as the fallback. ```bash POLYMARKET_WALLET=0x... POLYDISPLAY_EXTRA_ASSETS=FLR,HBAR ./install.sh @@ -118,7 +119,7 @@ search, or run `./install.sh` again and add them at the prompt. Port: `POLYDISPLAY_PORT` in `.env`, else `config.json` `port`, else 8080. Wallet and candle range: ⚙ or `config.json`. Pad PIN: `POLYDISPLAY_PIN` in -`.env`. Optional `CG_DEMO_KEY` in `.env` for a higher CoinGecko rate limit. +`.env`. Optional `CG_DEMO_KEY` in `.env` applies only to asset search. If ⚙ has saved a `coins` list into `config.json`, that list wins until you delete the `coins` key. `config.json` and `.env` are gitignored. @@ -128,7 +129,8 @@ Logs: `polydisplay.log` in the working directory. Rolled at local midnight to ## Data -Candles and prices: Binance when a USDT pair exists, otherwise CoinGecko. +Candles and prices: Kraken, with Coinbase fallback. Kraken ticker prices are +fetched in one request; OHLC requests are paced to its public API guidance. Positions and activity: Polymarket data-api, polled every 30s. Account P/L: Polymarket user-pnl-api, 720 hourly points over 30 days, polled every 2 min and thinned to 120 points for the sparkline. Gamma market metadata supplies diff --git a/com.novatechflow.polydisplay.plist b/com.novatechflow.polydisplay.plist index 7b8bc33..5230e34 100644 --- a/com.novatechflow.polydisplay.plist +++ b/com.novatechflow.polydisplay.plist @@ -39,7 +39,7 @@ /dev/null EnvironmentVariables - + CG_DEMO_KEY diff --git a/index.html b/index.html index fa9b06d..cc7083b 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,7 @@ polyDisplay - LAN web app: Polymarket positions + crypto watchlist. The browser talks ONLY to the local Go server (/api/*): it aggregates - Polymarket + crypto (Binance-first, CoinGecko fallback) so the display + Polymarket + crypto (Kraken-first, Coinbase fallback) so the display never hits an external API, rate limit, or geoblock. -->