Skip to content

tommll/stock_monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Monitoring CLI

A command-line application for real-time monitoring of stock and cryptocurrency prices from multiple data sources.

Features

  • Real-time price monitoring for stocks and cryptocurrencies
  • Support for multiple data sources:
    • Coinbase (cryptocurrencies)
    • Yahoo Finance (stocks)
  • Configurable update intervals
  • Support for monitoring multiple symbols simultaneously
  • Graceful shutdown handling
  • Optional monitoring duration setting

Prerequisites

  • Go 1.21 or later
  • Internet connection for accessing price data

Installation

  1. Clone the repository
  2. Navigate to the project directory
  3. Run:
go mod download
go build

Usage

The application accepts the following command-line flags:

  • -source: Data source to use (required)
    • Options: coinbase, yahoo
  • -symbols: Comma-separated list of symbols to monitor (required)
    • For Coinbase: Use format like "BTC-USD,ETH-USD"
    • For Yahoo: Use stock symbols like "AAPL,GOOGL"
  • -interval: Update interval (optional, default: 5s)
    • Format: Use Go duration format (e.g., "5s", "1m")
  • -duration: How long to run the monitoring (optional, default: 0 = indefinite)
    • Format: Use Go duration format (e.g., "1h", "30m")

Examples

Monitor Bitcoin and Ethereum prices from Coinbase:

./stock_monitoring -source coinbase -symbols BTC-USD,ETH-USD

Monitor Apple and Google stocks from Yahoo Finance with 1-minute updates:

./stock_monitoring -source yahoo -symbols AAPL,GOOGL -interval 1m

Monitor Bitcoin for 1 hour with 30-second updates:

./stock_monitoring -source coinbase -symbols BTC-USD -interval 30s -duration 1h

Data Sources

Coinbase

  • Uses both REST API and WebSocket for real-time updates
  • Provides cryptocurrency prices
  • Format: {CRYPTO}-{CURRENCY} (e.g., BTC-USD, ETH-USD)

Yahoo Finance

  • Uses REST API for price updates
  • Provides stock market data
  • Format: Standard stock symbols (e.g., AAPL, GOOGL)

Output Format

The application outputs price updates in the following format:

{Source} Update: {Symbol: "symbol", Price: price}

Error messages are displayed as:

{Source} Error: error message

Termination

The application can be terminated in two ways:

  1. Press Ctrl+C for manual termination
  2. Specify a duration using the -duration flag for automatic termination

Error Handling

  • Connection errors are reported but don't terminate the application
  • Invalid symbols are reported as errors in the output
  • Invalid source names are reported immediately and terminate the application

Contributing

Feel free to submit issues and enhancement requests!

About

Monitor stock price in real time from your terminal

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages