Skip to main content

Live market data from Yahoo! Finance websocket

Project description

Live Market Data from Yahoo! Finance

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:

Parameter Default Description
on_ticker None Callback function f(ws, msg) called on each update.
ticker_names ["AMZN"] List of Yahoo Finance symbols to subscribe to.
reconnect 5 Delay in seconds before attempting to reconnect on failure.
ping_interval 15 Interval in seconds to send WebSocket pings.
ping_timeout 10 Timeout in seconds to wait for a pong response.
enable_socket_trace False Set 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yliveticker-0.5.5.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yliveticker-0.5.5-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file yliveticker-0.5.5.tar.gz.

File metadata

  • Download URL: yliveticker-0.5.5.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for yliveticker-0.5.5.tar.gz
Algorithm Hash digest
SHA256 be415dced0ebbdaf848ccbd2298d1bbe76f5ead693e0c1954bbfa4b3621f8c53
MD5 6f1c20a0569acb64ec404668540e1606
BLAKE2b-256 f31eae9304694974e19da3edc05b585475bc86ccb9d122c4d19bc040c5b45247

See more details on using hashes here.

File details

Details for the file yliveticker-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: yliveticker-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for yliveticker-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a1676713bd08dfa5093032442b4f69371176c4815bd6cad19a2f31629737f681
MD5 79e21a0025b6fa3c48751298990cec55
BLAKE2b-256 93301ef896c73defbf30d28db2cc10400675e4d79fd2b0b1fefbeae7afb55347

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page