-
-
Save pa-0/52eb2f4c742e622f738cc2f2b998d7f8 to your computer and use it in GitHub Desktop.
BTC vs Polymarket Monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import time | |
| import json | |
| # --- KONFIGURATION --- | |
| # Indsæt Token ID for det Polymarket marked du vil overvåge | |
| # Du finder dette ID på Polymarket under "Details" eller via deres API. | |
| # Eksempel: Hvis du vil handle på om BTC er over en vis pris. | |
| POLYMARKET_TOKEN_ID = "INDSAET_TOKEN_ID_HER" | |
| def get_binance_price(): | |
| """Henter real-time BTC pris fra Binance""" | |
| url = "https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT" | |
| try: | |
| response = requests.get(url) | |
| data = response.json() | |
| return float(data['price']) | |
| except Exception as e: | |
| print(f"Fejl ved Binance: {e}") | |
| return None | |
| def get_polymarket_price(token_id): | |
| """Henter pris fra Polymarket CLOB (Central Limit Order Book)""" | |
| if token_id == "INDSAET_TOKEN_ID_HER": | |
| return 0.0 | |
| url = f"https://clob.polymarket.com/book?token_id={token_id}" | |
| try: | |
| response = requests.get(url) | |
| data = response.json() | |
| bids = data.get('bids', []) | |
| asks = data.get('asks', []) | |
| if not bids or not asks: | |
| return None | |
| best_bid = float(bids[0]['price']) | |
| best_ask = float(asks[0]['price']) | |
| # Midpoint pris | |
| return (best_bid + best_ask) / 2 | |
| except Exception as e: | |
| print(f"Fejl ved Polymarket: {e}") | |
| return None | |
| def main(): | |
| print("Starter BTC vs. Polymarket Monitor...") | |
| print("Husk at indsætte et gyldigt Token ID i filen!") | |
| print("-" * 50) | |
| while True: | |
| btc_price = get_binance_price() | |
| poly_price = get_polymarket_price(POLYMARKET_TOKEN_ID) | |
| if btc_price is not None: | |
| timestamp = time.strftime("%H:%M:%S") | |
| poly_display = f"${poly_price:.3f}" if poly_price else "N/A (Check Token ID)" | |
| print(f"[{timestamp}] Binance BTC: ${btc_price:.2f} | Polymarket Token: {poly_display}") | |
| time.sleep(1) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment