Skip to main content

Gets the live price of stocks and cryto. Also has graphing capabilities.

Project description

Live Stocks

This package can get the current price of cryptocurrencies and stocks, graph live price movements, graph historical price data, and retrieve historical price dictionaries. It also includes functions for converting between stock/crypto names and symbols.


⚠️ Requires an active internet connection

All price and history data is retrieved live.

⚠️ Symbols must be valid tickers

Misspelled or invalid symbols will fail unless autocorrect is enabled.

⚠️ Graphing functions require valid price/history functions

draw_graph and graph_history must receive valid data sources.


Table of Contents


Quick Start

Installation

pip install live-stocks

Minimal Example

from live_stocks import get_price

print(get_price(symbol="AAPL"))

Features

  • Get the current price of any stock or cryptocurrency.
  • Draw live‑updating price graphs.
  • Retrieve historical price data as a dictionary using get_history().
  • Graph historical price data using graph_history().
  • Convert from company/crypto names to symbols.
  • Convert from symbols to company/crypto names.

Usage

Getting Prices

from live_stocks import get_price

price = get_price(symbol="AAPL")
print(price)

Drawing Live Graphs

from live_stocks import get_price, draw_graph

draw_graph(
    price_func=lambda: get_price(symbol="AAPL"),
    stock_name="Apple",
    max_points=200,
    update_time=1.0,
    show_timestamps=True
)

Getting Historical Data

The get_history() function returns a dictionary mapping timestamps → prices if show_time_stamps is True. If show_time_stamps is False, then the get_history() function returns a list of prices.

As a dictionary (show_time_stamps = True)

from live_stocks import *

history = get_history(
    symbol="AAPL",
    length=LENGTH_ONE_MONTH,
    interval=INTERVAL_ONE_DAY,
    show_time_stamps = True
)

print(history)

Example output structure:

{
    "2024-01-01 09:30:00": 187.23,
    "2024-01-02 09:30:00": 189.10,
    ...
}

As a list (show_time_stamps = False)

from live_stocks import *

history = get_history(
    symbol="AAPL",
    length=LENGTH_ONE_MONTH,
    interval=INTERVAL_ONE_DAY,
    show_time_stamps = False
)

print(history)

Example output structure:

[
    187.23,
    189.10,
    ...
]

Supported lengths:
1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max

Supported intervals:
1m, 2m, 5m, 15m, 30m, 1h, 90m, 4h, 1d, 5d, 1wk, 1mo, 3mo


Graphing Historical Data

The graph_history() function graphs historical price data using matplotlib.

Static history graph:

from live_stocks import graph_history

graph_history(
    symbol="AAPL",
    length="5y",
    interval="1mo",
    live=False
)

Draws a graph with the history and does not update as the price changes.

Live‑updating history graph:

graph_history(
    symbol="AAPL",
    length="1y",
    interval="1d",
    live=True
)

Draws a graph with the history and keeps on updating every interval.


Symbol and Name Conversion

Name → Symbol

from live_stocks import name_to_symbol

symbol = name_to_symbol(company_name="Apple", autocorrect=True)
print(symbol)

Symbol → Name

from live_stocks import symbol_to_name

name = symbol_to_name(company_name="AAPL", autocorrect=True)
print(name)

Versions

Version 0.0.1: Base code with primary functions added.
Version 0.0.2: Documentation for crypto functions added and more parameters for draw_graph.
Version 0.0.3: Documentation for stock functions added.
Version 0.0.4: Symbol → Name and Name → Symbol conversion added.
Version 0.0.5: Added getting and graphing historical data; merged crypto/stock price functions.
(Latest) Version 0.0.6: Updated README


Coming Soon

Version 0.0.7: Add get_latest_news function for stocks and crypto

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

live_stocks-0.0.6.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

live_stocks-0.0.6-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file live_stocks-0.0.6.tar.gz.

File metadata

  • Download URL: live_stocks-0.0.6.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for live_stocks-0.0.6.tar.gz
Algorithm Hash digest
SHA256 401e6819a1c79f0e2b9da67e458996315b5c41569f3730efa1a007d34df895c8
MD5 84616d38cffd3d61bc837063a7d97f51
BLAKE2b-256 9ff0a7168eca7240d5b4ac3f728407d495e07ceefd1c38acd2712c4dc37e5f30

See more details on using hashes here.

File details

Details for the file live_stocks-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: live_stocks-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for live_stocks-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 861e36032877a8f913542665dc6f3356088868c2cb29831220d3a6e737bc56fe
MD5 f7c7482d9a2aa75ef1999741bbfeaf56
BLAKE2b-256 afdc6dd0b64f7d089bb1f4f6e33cd884482445f40f759069cf82b9ab60e0b70e

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