Live Market Data from Yahoo! Finance

March 27, 2026 ยท View on GitHub

Python package Upload Python Package PyPI version License: MIT

Get real-time market data from Yahoo! Finance via WebSockets. Lightweight, efficient, and easy to use.

Features

  • Real-time updates: Stream near-instant price changes from Yahoo! Finance.
  • Interactive Dashboard: A full-screen terminal UI with live charts and status monitoring.
  • Robust Connectivity: Built-in automatic reconnection and keep-alive (heartbeats).
  • Modern Support: Fully compatible with Protobuf 4.x/5.x/7.x.
  • Data Analysis Ready: Optional pandas integration and background CSV export.
  • Comprehensive Data: Includes price, volume, change, day high/low, and more.

Setup

Basic Installation

pip install yliveticker

๐Ÿบ Homebrew (macOS/Linux)

brew tap yahoofinancelive/yliveticker
brew install yliveticker

๐Ÿ–ฅ๏ธ Full Experience (CLI & Data Analysis)

To get the interactive dashboard and pandas support:

pip install yliveticker[cli,pandas]

Usage Examples

1. Interactive Dashboard (CLI)

The easiest way to watch stocks. It provides a real-time, color-coded dashboard with sparklines and live status updates.

# Watch multiple symbols and export to CSV
yliveticker watch AAPL MSFT TSLA BTC-USD --export my_data.csv

How it looks:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                Yahoo! Finance Live Dashboard | 01:50:56                  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Symbol   โ”ƒ     Price โ”ƒ Day Change       โ”ƒ Trend                          โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ AAPL     โ”‚    234.12 โ”‚ +1.45 (+0.62%)   โ”‚      โ–‚โ–ƒโ–…โ–†โ–ˆ                     โ”‚
โ”‚ BTC-USD  โ”‚  98,450.00โ”‚ -120.50 (-0.12%) โ”‚  โ–ˆโ–‡โ–†โ–…โ–„โ–ƒ                        โ”‚
โ”‚ NVDA     โ”‚    177.62 โ”‚ +2.42 (+1.38%)   โ”‚          โ–ˆโ–‚                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Status: โ— Connected | Updates: 18 | Tickers: 3 | Press Ctrl+C to Quit    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

2. Basic Ticker (Blocking)

This is the simplest way to print live updates to the console.

import yliveticker

# this function is called on each ticker update
def on_new_msg(ws, msg):
    print(msg)

yliveticker.YLiveTicker(on_ticker=on_new_msg, ticker_names=["BTC-USD", "AAPL", "EURUSD=X"])

2. Time Series and OHLCV (Pandas)

Use YTimeSeries to collect data into a structured format for analysis.

import yliveticker
from yliveticker import YTimeSeries

ts = YTimeSeries()

# Collect data (press Ctrl+C to stop and see results)
try:
    yliveticker.YLiveTicker(on_ticker=ts.on_ticker, ticker_names=["BTC-USD"])
except KeyboardInterrupt:
    pass

# Get raw collected data as a pandas DataFrame
df = ts.get_dataframe()
print(df.head())

# Get 1-minute OHLCV candles
ohlcv = ts.get_ohlcv(interval='1Min')
for symbol, data in ohlcv.items():
    print(f"\n--- {symbol} ---")
    print(data)

3. Time Series Database (TSDB) & Grafana

Store and visualize live ticker data using high-performance time-series databases and Grafana.

Installation

Install the necessary drivers for your chosen database:

# For all supported databases
pip install yliveticker[all]

# Or individually
pip install yliveticker[influxdb]
pip install yliveticker[timescaledb]
pip install yliveticker[clickhouse]
pip install yliveticker[questdb]
pip install yliveticker[timestream]

Supported Sinks

  • InfluxDB: Native Flux support with tag/field mapping.
  • TimescaleDB: Automated hypertable creation and bulk inserts.
  • ClickHouse: High-throughput columnar storage.
  • QuestDB: Ultra-fast ingestion via InfluxDB Line Protocol (ILP).
  • Amazon Timestream: AWS-native serverless time-series database.

Quick Start with Docker & Grafana

We provide a pre-configured environment with InfluxDB and Grafana.

  1. Start the stack:
    cd docker
    docker-compose up -d
    
  2. Run the example script:
    python examples/tsdb_example.py
    
  3. Visualize: Open http://localhost:3000 (User: admin, Pass: admin) to see the live "Yahoo Finance Live Ticker" dashboard.

Configuration

The YLiveTicker constructor accepts several parameters for fine-tuning:

ParameterDefaultDescription
on_tickerNoneCallback function f(ws, msg) called on each update.
ticker_names["AMZN"]List of Yahoo Finance symbols to subscribe to.
reconnect5Delay in seconds before attempting to reconnect on failure.
ping_interval15Interval in seconds to send WebSocket pings.
ping_timeout10Timeout in seconds to wait for a pong response.
enable_socket_traceFalseSet to True to see raw WebSocket frames.

Note on Trading Hours

If you don't observe any live metrics, please check the trading hours for your specific market. Many traditional stock symbols will only provide updates during market hours. Crypto symbols (like BTC-USD) usually stream 24/7.

License

Distributed under the MIT License. See LICENSE for more information.