Glanceway Glanceway
Alle Quellen

Stock Price Monitor

Finanzen

Monitor global stock prices in your menu bar. Displays real-time price, change amount, and change percentage. Powered by Finnhub (free API key required).

@codytseng #stock #finance #market

Install and configure this source

  1. Install Glanceway and open it on your Mac before using the install link above.
  2. Choose Install in Glanceway. If the browser cannot open the app, download the .gwsrc file and import it through source management.
  3. Complete the required fields below, save, and choose a refresh interval. Check the source after its first successful fetch.

Configuration checklist

  • FINNHUB_TOKEN — Required. Free API token from https://finnhub.io Use your own credential; do not share it in screenshots or public files.
  • SYMBOLS — Required. Stock symbols (e.g. AAPL, TSLA, MSFT) Add each value as a separate list item.

The source requests each symbol from Finnhub and skips failed or zero-price responses. Coverage and quote latency depend on your provider access. Enter symbols separately; the source does not place trades.

Example settings

FINNHUB_TOKEN: <your Finnhub token>
SYMBOLS (list items):
  AAPL
  MSFT

If items are missing

  • Verify the field names, list entries, and credentials against the current version’s configuration table. Sample values below are examples, not active credentials.
  • Check network access and upstream service availability. Authentication failures and rate limits can prevent a refresh; use a slower interval when the provider limits requests.
  • An empty result can also mean there are no matching items. Fetched content and update timing depend on the provider and source implementation.

Konfiguration

Name Schlüssel Typ Erforderlich Standard Beschreibung
Finnhub API Token FINNHUB_TOKEN secret Ja — Free API token from https://finnhub.io
Stock Symbols SYMBOLS list Ja — Stock symbols (e.g. AAPL, TSLA, MSFT)

Quellcode

id: codytseng/stock-price
version: 1.1.0
name: Stock Price Monitor
description: |
  Monitor global stock prices in your menu bar.
  Displays real-time price, change amount, and change percentage.
  Powered by Finnhub (free API key required).
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
  - stock
  - finance
  - market

config:
  - key: FINNHUB_TOKEN
    name: Finnhub API Token
    type: secret
    required: true
    description: "Free API token from https://finnhub.io"
  - key: SYMBOLS
    name: Stock Symbols
    type: list
    required: true
    description: "Stock symbols (e.g. AAPL, TSLA, MSFT)"

module.exports = async (api) => {
  const token = api.config.get("FINNHUB_TOKEN");
  const symbolsRaw = api.config.get("SYMBOLS") ?? [];

  async function fetchData() {
    const symbols = symbolsRaw.map((s) => s.toUpperCase());

    if (symbols.length === 0) {
      api.emit([]);
      return;
    }

    const items = [];

    for (const symbol of symbols) {
      const quoteRes = await api.fetch(
        `https://finnhub.io/api/v1/quote?symbol=${symbol}&token=${token}`,
      );

      if (!quoteRes.ok || !quoteRes.json || quoteRes.json.c === 0) {
        api.log("warn", `Failed to fetch quote for ${symbol}`);
        continue;
      }

      const q = quoteRes.json;

      // fetch and cache company name
      let name = api.storage.get(`name:${symbol}`);
      if (!name) {
        const profileRes = await api.fetch(
          `https://finnhub.io/api/v1/stock/profile2?symbol=${symbol}&token=${token}`,
        );
        if (profileRes.ok && profileRes.json?.name) {
          name = profileRes.json.name;
          api.storage.set(`name:${symbol}`, name);
        }
      }

      const price = q.c.toFixed(2);
      const change = q.d.toFixed(2);
      const changePct = q.dp.toFixed(2);
      const arrow = q.d > 0 ? "↑" : q.d < 0 ? "↓" : "";
      const sign = q.d > 0 ? "+" : "";

      items.push({
        id: symbol,
        title: name ? `${name} (${symbol})` : symbol,
        subtitle: `${price} ${arrow} ${sign}${change} (${sign}${changePct}%)`,
        tickerText: `${symbol} ${price} ${sign}${changePct}%`,
        url: `https://finnhub.io/stock/${symbol}`,
      });
    }

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};
id: codytseng/stock-price
version: 1.0.0
name: Stock Price Monitor
description: |
  Monitor global stock prices in your menu bar.
  Displays real-time price, change amount, and change percentage.
  Powered by Finnhub (free API key required).
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
  - stock
  - finance
  - market

config:
  - key: FINNHUB_TOKEN
    name: Finnhub API Token
    type: secret
    required: true
    description: "Free API token from https://finnhub.io"
  - key: SYMBOLS
    name: Stock Symbols
    type: list
    required: true
    description: "Stock symbols (e.g. AAPL, TSLA, MSFT)"

module.exports = async (api) => {
  const token = api.config.get("FINNHUB_TOKEN");
  const symbolsRaw = api.config.get("SYMBOLS") ?? [];

  async function fetchData() {
    const symbols = symbolsRaw.map((s) => s.toUpperCase());

    if (symbols.length === 0) {
      api.emit([]);
      return;
    }

    const items = [];

    for (const symbol of symbols) {
      const quoteRes = await api.fetch(
        `https://finnhub.io/api/v1/quote?symbol=${symbol}&token=${token}`,
      );

      if (!quoteRes.ok || !quoteRes.json || quoteRes.json.c === 0) {
        api.log("warn", `Failed to fetch quote for ${symbol}`);
        continue;
      }

      const q = quoteRes.json;

      // fetch and cache company name
      let name = api.storage.get(`name:${symbol}`);
      if (!name) {
        const profileRes = await api.fetch(
          `https://finnhub.io/api/v1/stock/profile2?symbol=${symbol}&token=${token}`,
        );
        if (profileRes.ok && profileRes.json?.name) {
          name = profileRes.json.name;
          api.storage.set(`name:${symbol}`, name);
        }
      }

      const price = q.c.toFixed(2);
      const change = q.d.toFixed(2);
      const changePct = q.dp.toFixed(2);
      const arrow = q.d > 0 ? "↑" : q.d < 0 ? "↓" : "";
      const sign = q.d > 0 ? "+" : "";

      items.push({
        id: symbol,
        title: name ? `${name} (${symbol})` : symbol,
        subtitle: `${price} ${arrow} ${sign}${change} (${sign}${changePct}%)`,
        url: `https://finnhub.io/stock/${symbol}`,
      });
    }

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

Ähnliche Quellen