Skip to content

Commit

Permalink
Add documentation for WebSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvan2006 committed Jan 3, 2025
1 parent 97efa62 commit 55b4a90
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Yahoo! finance API is intended for personal use only.**
- `Ticker`: single ticker data
- `Tickers`: multiple tickers' data
- `download`: download market data for multiple tickers
- `Market`: get infomation about a market
- `WebSocket`: live streaming data for multiple tickers
- `Market`: get information about a market
- `Search`: quotes and news from search
- `Sector` and `Industry`: sector and industry information
- `EquityQuery` and `Screener`: build query to screen market
Expand Down
9 changes: 9 additions & 0 deletions doc/source/reference/examples/live.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import yfinance as yf

# define callback function
def on_price_update(data):
print(data)

# subscribe to a list of symbols
ws = yf.WebSocket(on_price_update)
ws.subscribe(["AAPL", "MSFT"])
2 changes: 2 additions & 0 deletions doc/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The following are the publicly available classes, and functions exposed by the `
- :attr:`Tickers <yfinance.Tickers>`: Class for handling multiple tickers.
- :attr:`MarketSummary <yfinance.MarketSummary>`: Class for accessing market summary.
- :attr:`Search <yfinance.Search>`: Class for accessing search results.
- :attr:`WebSocket <yfinance.WebSocket>`: Class for streaming live market data
- :attr:`Sector <yfinance.Sector>`: Domain class for accessing sector information.
- :attr:`Industry <yfinance.Industry>`: Domain class for accessing industry information.
- :attr:`download <yfinance.download>`: Function to download market data for multiple tickers.
Expand All @@ -36,6 +37,7 @@ The following are the publicly available classes, and functions exposed by the `
yfinance.analysis
yfinance.marketsummary
yfinance.search
yfinance.websocket
yfinance.sector_industry
yfinance.functions

Expand Down
22 changes: 22 additions & 0 deletions doc/source/reference/yfinance.websocket.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=====================
WebSocket
=====================

.. currentmodule:: yfinance


Class
------------
The `WebSocket` module, allows you to stream live data.

.. autosummary::
:toctree: api/

WebSocket

WebSocket Sample Code
------------------
The `WebSocket` module, allows you to stream live data.

.. literalinclude:: examples/live.py
:language: python

0 comments on commit 55b4a90

Please sign in to comment.