Skip to content

About

Personal Stock Ticker

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

Stock Ticker

This is a simple stock ticker application that fetches and displays stock/crypto prices on a loop. Each refresh also taps a harmless "phantom" key (F15 by default) so the workstation session registers input activity.

Setup

  • Environment variables will need to be set for the application to run. Add these to your preferred method for setting environment variables, such as your shell configuration.

    export FINNHUB_API_KEY='FINNHUB_API_KEY'
    export CMC_API_KEY='CMC_API_KEY'
  • FINNHUB_API_KEY can be obtained from Finnhub. This is used for stock prices.

  • CMC_API_KEY can be obtained from CoinMarketCap for crypto prices.

Configuration

Edit config/symbols.yaml (or point elsewhere with -config / the CONFIG_PATH env var):

symbols:
  crypto:
    - BTC
    - ETH
  stock:
    - US88160R1014 # TSLA
currency: GBP        # fiat currency for quotes (default GBP)
keepalive_key: f10   # key tapped each cycle (see Keepalive keystroke below)
  • Cryptocurrency symbols are fetched from CoinMarketCap in a single batched request.
  • Stock ISIN codes are resolved to symbols via Finnhub once per process (cached), then used to fetch quotes. ISIN codes ensure the correct stock is fetched, as stock symbols can vary by exchange.
  • If one symbol fails, its row shows dashes with a warning underneath — the rest still render.

Usage

make run                # build and run the ticker loop
./bin/ticker -once      # single update, then exit (no keystroke)
./bin/ticker -json      # single update as JSON, then exit
./bin/ticker -interval 5m
./bin/ticker -no-clear  # append output instead of clearing the screen
  • The default refresh interval is 840s (14 minutes), which stays well inside free-tier API rate limits and fires the keepalive keystroke ahead of typical idle timeouts.
  • Set the NO_COLOR env var to disable ANSI colours.

Keepalive keystroke

Every refresh cycle the ticker taps keepalive_key system-wide so the machine keeps registering input. The default is f10, which is reliably mapped to a real keycode on stock keyboard layouts. Changing this is riskier than it looks: keys like F13-F24 typically have no bound X11/XKB keycode on a normal machine, and tapping an unbound key makes robotgo synthesize keycode 0, which X11 rejects with a fatal BadValue error that kills the process outright (not a recoverable Go error). If you change keepalive_key, verify it with a real run of the loop — -once skips the keystroke entirely and won't catch a bad choice.

Development

make test   # unit tests (no API keys needed)
make lint   # go vet + gofmt check + build

CI runs lint, build, and tests on every pull request (see .github/workflows/ci.yml). Building requires X11 headers on Linux because of the robotgo keystroke dependency.

About

Personal Stock Ticker

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages