IF IT AIN'T BROKE, DON'T FIX IT

FX Markets

Test 3

function getSentiment(text) {if (/rise|bullish|strong|gain|hawkish/i.test(text)) return "lime";if (/fall|bearish|weak|drop|dovish/i.test(text)) return "red";return "#58a6ff";} function timeAgo(date) {const seconds = Math.floor((new Date() - new Date(date)) / 1000);const mins = Math.floor(seconds / 60);const hrs = Math.floor(mins / 60); if (hrs > 0) return hrs + "h ago";if (mins > 0) return mins + "m ago";return "Just now";} function loadFeed(rssUrl, containerId, sourceName) {const API = "https://api.allorigins.win/get?url=" + encodeURIComponent(rssUrl); fetch(API).then(res => res.json()).then(data => {const parser = new DOMParser();const xml = parser.parseFromString(data.contents, "text/xml");const items = xml.querySelectorAll("item"); const container = document.getElementById(containerId); container.innerHTML = ""; const keywords = /\b(eurusd|euro|usd|dollar|ecb|fed|fomc|cpi|ppi|inflation|interest rate|nfp|gdp|recession)\b/i; let found = false; items.forEach(item => { const title = item.querySelector("title").textContent; const link = item.querySelector("link").textContent; const pubDate = item.querySelector("pubDate").textContent; const text = title; if (keywords.test(text)) { found = true; const div = document.createElement("div"); div.className = "news"; const color = getSentiment(text); div.innerHTML = ` ${title}
${timeAgo(pubDate)}
${sourceName}
`; container.appendChild(div); } }); if (!found) { container.innerHTML = "
No relevant news right now
"; } }) .catch(() => { const container = document.getElementById(containerId); container.innerHTML = "
⚠️ Failed to load
"; }); } const feeds = [{ url: "https://www.forexlive.com/feed/news", container: "forex", name: "ForexLive" },{ url: "https://www.investing.com/rss/news_25.rss", container: "macro", name: "Investing.com" },{ url: "https://www.ecb.europa.eu/rss/press.html", container: "macro", name: "ECB" }]; function loadAll() {document.getElementById("forex").innerHTML = "Loading...";document.getElementById("macro").innerHTML = "Loading..."; feeds.forEach(feed => {loadFeed(feed.url, feed.container, feed.name);});} // Initial loadloadAll(); // Auto refresh every 15 minutessetInterval(loadAll, 900000);
Share:

No comments:

Post a Comment

S&P 500

Crypto

World Clock

Bloomberg

MTV Rocks

    Wikipedia

    Search results

    News

    Powered by Blogger.

    Blog Archive

    Popular Posts

    Pages