Skip to main content

A collection of stock analysis functions and api wrappers

Project description

lukhed_stocks

A collection of stocks analysis utility functions and API wrappers. Repo is in development. Please note that you are responsible for how you access and use the data. See the responsible data usage section for more info.

Installation

pip install lukhed-stocks

TOC

Available Functions
Available Wrappers
Responsible Data Usage

Available Functions

Available Wrappers

  • CAT Wrapper - Conolidated Audit Trail (CAT) for exchange data provided by CAT Webpage
  • Wikipedia Stocks - For obtaining various stock data from Wikipedia (various pages)
  • Schwab Wrapper - Wrapper for schwab-py wrapper. Adds key management and convenience functions to the unopinionated wrapper which provides auth, quotes, history, options, account info and more.

Ticker Functions

Tickers Import

from lukhed_stocks import tickers

Get Tickers By Exchange

Provides a list of stock data for the given exchange. Each function can optionally be called with 'tickers_only' parameter to return a list of strings only. These functions utilize CAT data by default and do not require an API key.

nasdaq = tickers.get_nasdaq_stocks()
nyse = tickers.get_nyse_stocks(tickers_only=True)
otc = tickers.get_otc_stocks()
iex = tickers.get_iex_stocks(tickers_only=True)
Function Default Source
tickers.get_nasdaq_stocks CAT
tickers.get_nyse_stocks CAT
tickers.get_otc_stocks CAT
tickers.get_iex_stocks CAT

Get Tickers By Index

Provides a list of stock data for the given index. Each function can optionally be called with 'tickers_only' parameter to return a list of strings only. The default source for each function does not require an API key.

sp500 = tickers.get_sp500_stocks()
djia = tickers.get_dow_stocks(tickers_only=True)
otc = tickers.get_russell2000_stocks()
Function Default Source
tickers.get_sp500_stocks Wikipedia
tickers.get_dow_stocks Wikipedia
tickers.get_russell2000_stocks TradingView

Get Company Logo by Ticker

logo_url = tickers.get_company_logo('ALLT')
logo_url_with_download = tickers.get_company_logo('WAY', output_file='way.png')
Function Default Source
tickers.get_company_log Synth

CAT Wrapper

Documentation coming soon.

Wikipedia Stocks

Documentation coming soon.

Schwab Wrapper

Setup

Setup the API auth once and use it across hardware. To setup, instantiate with schwab_api_setup=True. By default, your private github repo is used for key mangement (you will need a github account and token). Setup will ask for your Schwab developer app key, secret, and callback url, then take you through authenticating with Schwab.

Note: this wrapper uses schwab-py for actual Schwab auth. See the documentation there for any issues or questions in setting up your schwab account.

#Github setup
schwab = SchwabPy(schwab_api_setup=True)
#Local setup (won't work across hardware)
schwab = SchwabPy(schwab_api_setup=True, key_management='local')

Usage Examples After Setup

schwab = SchwabPy()
quotes = schwab.get_stock_quote(['allt', 'way', 'pplt', 'impuy'])
price = schwab.get_stock_price('allt')
low = schwab.get_stock_52w_low('gld')
percent_below_high = schwab.get_percent_below_52w_high('aapl')

Cache Option

If prices are stale when using this wrapper (e.g., after market) or realtime price is not needed for your analysis, you can use cache to speed up calls.

schwab = SchwabPy(use_ticker_cache=True)
quotes = schwab.get_stock_quote(['allt', 'way', 'pplt', 'impuy'])   # 'allt' in cache
price = schwab.get_stock_price('allt')  # retrieve price from cache

Utilizing schwab-py

My wrapper is built for key management, advanced analysis, and ease of use. The exposed methods are recommended when using my wrapper, but you can access any of the endpoints available from schwab-py like below.

schwab.api.get_price_history_every_minute("ALLT")

Responsible Data Usage

  • Each method or wrapper in the documentation lists the source that is utilized by default
  • Below is information related to data retrieval and usage for each source

CAT Data Usage

CAT Data is pulled from this page. They provide a legal notice here.

Wikipedia Data Usage

Wikipedia content is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. For more details on the terms of use, please refer to the Wikimedia Foundation's Terms of Use.

Synth

Full Synth terms are found here. This library provides access to synth:

  • Images, free to use if attribution is provided (please confirm with synthfinance.com or the terms above)

Tradingview Data Usage

I am currently trying to remove trading view as a source, as their policy is restrictive and confusing. Please read trading view policies here

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

lukhed_stocks-0.1.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

lukhed_stocks-0.1.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file lukhed_stocks-0.1.0.tar.gz.

File metadata

  • Download URL: lukhed_stocks-0.1.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for lukhed_stocks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 356ca0a3981f87ab1c3e21332f0936e09f71a1c1b18abd5726aa9b9a541facf7
MD5 0fa63a48c301026e118a43af49542d19
BLAKE2b-256 6a89ebf5f3a5dcfaf05ee59dae775a0ede5236d311d37f5b49c5632b94f3df27

See more details on using hashes here.

File details

Details for the file lukhed_stocks-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lukhed_stocks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for lukhed_stocks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 945bbe8a6599ef3145cbb596433d44b30b3f5c776db8aa5ede65a2d7a776a73e
MD5 34c3ec8f3d3fde94ae0a94f5a4c84970
BLAKE2b-256 91d19c6298d3306397fabfdb2e37e76688b912a039a88392d8a39be5b018eb16

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