InVaIN
Brief Overview
Real time stock data works either through the Simple API or the Advanced API
Historical data works through the History API
Install
From PyPI with pip:
$ pip install invain
Code Examples
Example: Simple API – Apple Inc. (AAPL)
import invain
#Create Simple API object
api = invain.Simple('HD')
#Get market price
print(api.get_price())
###################
'173.07''
Example: Advanced API Method 1 – Apple Inc. (AAPL), Alphabet Inc. (GOOG), Microsoft Inc. (MSFT)
import invain
#Create Advanced API object with all the tickers provided
api = invain.Advanced('AAPL','GOOG', 'MSFT')
#Use Simple API method to get price
prices = api.get_price()
#Returns dict object with stock as the index
for stock in prices:
print(stock, prices[stock])
###################
'AAPL 173.07'
'GOOG 1047.41'
'MSFT 84.88'
Example: Advanced API Method 2 – Apple Inc. (AAPL), Alphabet Inc. (GOOG), Microsoft Inc. (MSFT)
import invain
#Create Advanced API object with all the tickers provided
api = invain.Advanced('AAPL','GOOG', 'MSFT')
#Add price field to data
api.add_price()
#Fetch custom data set
prices = api.get_customData()
#Returns dict object with stock as the index
for stock in prices:
print(stock, prices[stock])
###################
'AAPL {'price': 173.07}'
'GOOG {'price': 1047.41}'
'MSFT {'price': 84.88}'
Example: History API Method 1 – Apple Inc. (AAPL), Alphabet Inc. (GOOG), Microsoft Inc. (MSFT)
import invain
#Create History API object with all tickers provided.
#This will pull stock data for the past 30 days with an interval of 1 day.
#Note that when creating a History object, historical data is automatically pulled.
#If tickers, start or end dates, or frequency are changed, you will need to run api.update_dataset()
api = invain.History('AAPL','GOOG', 'MSFT')
#Get custom data set
historical_data = api.get_dataset()
#Returns dict object with stock as the index
for stock in historical_data:
print(stock, historical_data[stock])
###################
AAPL{
'Adj Close': [...],
'Close': [...],
'Date': [...],
'High': [...],
'Low': [...],
'Open': [...],
'Volume': [...]
}
GOOG{
'Adj Close': [...],
'Close': [...],
'Date': [...],
'High': [...],
'Low': [...],
'Open': [...],
'Volume': [...]
}
MSFT{
'Adj Close': [...],
'Close': [...],
'Date': [...],
'High': [...],
'Low': [...],
'Open': [...],
'Volume': [...]
}
Available methods
History API
add_ticker(ticker)
add_tickers(tickers) – takes argument as array ([‘ticker1’, ‘ticker2’, …]) or individual parameters (ticker1, ticker2, …)
remove_ticker(tickers)
get_tickers()
get_period()
get_startDate()
get_endDate()
change_period(periods)– takes argument as array ([‘period1’, ‘period2’]) or individual parameters (‘period1’, ‘period2’)
change_startTime(start)
change_endTime(end)
get_dataset()
update_dataset()
change_frequency(frequency, num_between=1) – frequency can be daily, weekly, or monthly. num_between is the step between dates (Not required. Default is 1)
get_date() – if ticker(s) provided only returns data for those ticker(s)
get_open() – if ticker(s) provided only returns data for those ticker(s)
get_high() – if ticker(s) provided only returns data for those ticker(s)
get_low() – if ticker(s) provided only returns data for those ticker(s)
get_close() – if ticker(s) provided only returns data for those ticker(s)
get_adj_close() – if ticker(s) provided only returns data for those ticker(s)
get_volume() – if ticker(s) provided only returns data for those ticker(s)
get_combo(ticker="ticker",field="high") – Either ticker or field MUST be given (both is valid). If no ticker is provided returns data for all tickers. If no field is provided returns data for all fields.
Simple API
change_ticker(ticker)
get_ticker()
get_price()
get_volume()
get_ask()
get_askSize()
get_averageDailyVolume3Month()
get_averageDailyVolume10Day()
get_bid()
get_bidSize()
get_bookValue()
get_currency()
get_earningsTimestamp()
get_earningsTimestampEnd()
get_earningsTimestampStart()
get_epsForward()
get_epsTrailingTwelveMonths()
get_fiftyDayAverage()
get_fiftyDayAverageChange()
get_fiftyDayAverageChangePercent()
get_fiftyTwoWeekHigh()
get_fiftyTwoWeekHighChange()
get_fiftyTwoWeekHighChangePercent()
get_fiftyTwoWeekLow()
get_fiftyTwoWeekLowChange()
get_fiftyTwoWeekLowChangePercent()
get_financialCurrency()
get_forwardPE()
get_fullExchangeName()
get_gmtOffSetMilliseconds()
get_longName()
get_marketCap()
get_marketChange()
get_marketChangePercent()
get_marketDayHigh()
get_marketDayLow()
get_marketOpen()
get_marketPreviousClose()
get_marketTime()
get_postMarketChange()
get_postMarketChangePercent()
get_postMarketPrice()
get_postMarketTime()
get_priceHint()
get_priceToBook()
get_sharesOutstanding()
get_shortName()
get_symbol() – Returns ticker for stock data being fetched
get_tradeable()
get_trailingPE()
get_twoHundredDayAverage()
get_twoHundredDayAverageChange()
get_twoHundredDayAverageChangePercent()
Advanced API
get_customData()
add_ticker(ticker)
add_tickers(tickers) – takes list of tickers as argument (or add_tickers(ticker1,ticker2,…))
get_tickers(tickers)
remove_tickers(tickers)
add_price()
add_volume()
add_ask()
add_askSize()
add_averageDailyVolume3Month()
add_averageDailyVolume10Day()
add_bid()
add_bidSize()
add_bookValue()
add_currency()
add_earningsTimestamp()
add_earningsTimestampEnd()
add_earningsTimestampStart()
add_epsForward()
add_epsTrailingTwelveMonths()
add_fiftyDayAverage()
add_fiftyDayAverageChange()
add_fiftyDayAverageChangePercent()
add_fiftyTwoWeekHigh()
add_fiftyTwoWeekHighChange()
add_fiftyTwoWeekHighChangePercent()
add_fiftyTwoWeekLow()
add_fiftyTwoWeekLowChange()
add_fiftyTwoWeekLowChangePercent()
add_financialCurrency()
add_forwardPE()
add_fullExchangeName()
add_gmtOffSetMilliseconds()
add_longName()
add_marketCap()
add_marketChange()
add_marketChangePercent()
add_marketDayHigh()
add_marketDayLow()
add_marketOpen()
add_marketPreviousClose()
add_marketTime()
add_postMarketChange()
add_postMarketChangePercent()
add_postMarketPrice()
add_postMarketTime()
add_priceHint()
add_priceToBook()
add_sharesOutstanding()
add_shortName()
add_symbol()
add_tradeable()
add_trailingPE()
add_twoHundredDayAverage()
add_twoHundredDayAverageChange()
add_twoHundredDayAverageChangePercent()
Remove for Above Functions
TODO/Future Updates
Historical Data - In Progress (install from clone to use pre-alpha version)
Better Error Handling - After Historical Data is in package release
Add Documentation - Will attempt to do this periodically untill full docs are complete. Any assistance on this would be great :)
Requirements
requests
Feedback, Issues, and Features:
Feedback
Bugs
If you experience any bugs when running the package please submit an issue with a description of the issue. Bugs will take priority over all other issues.
Bad Data
If you experience any problems with returned data please create an issue and include: - Code related to creating, modifiying, and accessing the InVaIN API object - Data Returned - Day and Approximate Time of Access
This will allow me to better identify what is causing the issue. If you’d rather not post this information on github, please email it to the email listed in the feedback section.
New Features
Please don’t hesitate to ask for new features you’d like to see or make suggestions for improvements. You can open an issue here on github and I’ll take a look at it as soon as I can.
Metadata
Release files for invain 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| invain-0.4.0.tar.gz | 14.7 kB | Without provenance | Details for invain-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| invain-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for invain-0.4.0-py3-none-any.whl |
Total release size: 27.7 kB
Release files / invain-0.4.0.tar.gz
| Download URL | invain-0.4.0.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5de8d92df5e51cceceff177319ccef91dfbd0a187e4846fe5aa84e9d43383694
|
|
BLAKE2b-256 checksum How to use checksums |
36de7795aee820dd87a66f6de690f8b00959216ef57c12c3d6d02a3c3b7bae9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Release files / invain-0.4.0-py3-none-any.whl
| Download URL | invain-0.4.0-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73c4c3b1182d33ef617034011fce1dd96de199fc31be18e2b0b89c15c0c12132
|
|
BLAKE2b-256 checksum How to use checksums |
93d5a417f0daa521075fe388689f9bc65b0550eb7b19abb8c32a4f681e03cc54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Security for invain 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.