Skip to content

Real-time dashboard for monitoring global news, markets, and geopolitical events

TypeScript

Add Polymarket predictions panel

Reggie24d0cd756fce
diff --git a/index.html b/index.html
index 016a756..f9c1ef8 100644
--- a/index.html
+++ b/index.html
@@ -259,6 +259,51 @@
.heatmap-cell.down-2 { background: #aa3333; color: #fff; }
.heatmap-cell.down-3 { background: #cc2222; color: #fff; }
+ /* Polymarket */
+ .prediction-item {
+ padding: 0.6rem 1rem;
+ border-bottom: 1px solid var(--border);
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 1rem;
+ }
+
+ .prediction-question {
+ font-size: 0.75rem;
+ flex: 1;
+ color: var(--text);
+ }
+
+ .prediction-odds {
+ display: flex;
+ gap: 0.5rem;
+ flex-shrink: 0;
+ }
+
+ .prediction-yes, .prediction-no {
+ padding: 0.25rem 0.5rem;
+ font-size: 0.65rem;
+ font-weight: bold;
+ border-radius: 2px;
+ }
+
+ .prediction-yes {
+ background: var(--green);
+ color: var(--bg);
+ }
+
+ .prediction-no {
+ background: var(--red);
+ color: #fff;
+ }
+
+ .prediction-volume {
+ font-size: 0.55rem;
+ color: var(--text-dim);
+ margin-top: 0.25rem;
+ }
+
.error-msg {
padding: 1rem;
color: var(--text-dim);
@@ -395,6 +440,17 @@
<div class="loading-msg">Loading...</div>
</div>
</section>
+
+ <!-- Polymarket -->
+ <section class="panel wide">
+ <div class="panel-header">
+ <span class="panel-title">Polymarket Predictions</span>
+ <span class="panel-count" id="polymarketCount">-</span>
+ </div>
+ <div class="panel-content" id="polymarketPanel">
+ <div class="loading-msg">Loading...</div>
+ </div>
+ </section>
</main>
<script>
@@ -656,6 +712,32 @@
return results;
}
+ // Fetch Polymarket predictions
+ async function fetchPolymarket() {
+ try {
+ const text = await fetchWithProxy('https://gamma-api.polymarket.com/markets?closed=false&limit=20');
+ const data = JSON.parse(text);
+
+ // Filter for active markets with volume and sort by volume
+ const markets = data
+ .filter(m => m.active && m.volume && parseFloat(m.volume) > 10000)
+ .sort((a, b) => parseFloat(b.volume) - parseFloat(a.volume))
+ .slice(0, 15)
+ .map(m => ({
+ question: m.question,
+ yes: (parseFloat(m.outcomePrices?.[0] || m.bestAsk || 0) * 100).toFixed(0),
+ no: (parseFloat(m.outcomePrices?.[1] || (1 - (m.bestAsk || 0))) * 100).toFixed(0),
+ volume: parseFloat(m.volume),
+ slug: m.slug
+ }));
+
+ return markets;
+ } catch (error) {
+ console.error('Error fetching Polymarket:', error);
+ return [];
+ }
+ }
+
// Format relative time
function timeAgo(dateString) {
if (!dateString) return '';
@@ -785,6 +867,38 @@
}).join('');
}
+ // Render Polymarket predictions
+ function renderPolymarket(markets) {
+ const panel = document.getElementById('polymarketPanel');
+ const count = document.getElementById('polymarketCount');
+
+ if (markets.length === 0) {
+ panel.innerHTML = '<div class="error-msg">Failed to load predictions</div>';
+ count.textContent = '0';
+ return;
+ }
+
+ const formatVolume = (v) => {
+ if (v >= 1000000) return '$' + (v / 1000000).toFixed(1) + 'M';
+ if (v >= 1000) return '$' + (v / 1000).toFixed(0) + 'K';
+ return '$' + v.toFixed(0);
+ };
+
+ panel.innerHTML = markets.map(m => `
+ <div class="prediction-item">
+ <div>
+ <div class="prediction-question">${m.question}</div>
+ <div class="prediction-volume">Vol: ${formatVolume(m.volume)}</div>
+ </div>
+ <div class="prediction-odds">
+ <span class="prediction-yes">${m.yes}%</span>
+ </div>
+ </div>
+ `).join('');
+
+ count.textContent = markets.length;
+ }
+
// Update status
function setStatus(text, loading = false) {
const status = document.getElementById('status');
@@ -799,14 +913,15 @@
setStatus('Fetching...', true);
try {
- const [politics, tech, finance, gov, markets, sectors, commodities] = await Promise.all([
+ const [politics, tech, finance, gov, markets, sectors, commodities, polymarket] = await Promise.all([
fetchCategory(FEEDS.politics),
fetchCategory(FEEDS.tech),
fetchCategory(FEEDS.finance),
fetchCategory(FEEDS.gov),
fetchMarkets(),
fetchSectors(),
- fetchCommodities()
+ fetchCommodities(),
+ fetchPolymarket()
]);
renderNews(politics, 'politicsPanel', 'politicsCount');
@@ -816,6 +931,7 @@
renderMarkets(markets);
renderHeatmap(sectors);
renderCommodities(commodities);
+ renderPolymarket(polymarket);
const now = new Date();
setStatus(`Updated ${now.toLocaleTimeString()}`);