A handy tool to get nasdaq data in python
Project description
How to
First import and create an instance of your nasdaq data grabber object
from nasdaq_data import nasdaq_grabber as ng
my_ng = ng()
Get Top Stocks by Market Cap
Call nasdaq_stocks and input the number of tickers you want and you will get info on stocks in order of Market Cap
my_ng.nasdaq_stocks(10)
symbol | name | lastsale | netchange | pctchange | marketCap | url | |
---|---|---|---|---|---|---|---|
0 | AAPL | Apple Inc. Common Stock | $150.43 | -2.31 | -1.512% | 2,608,056,056,200 | /market-activity/stocks/aapl |
1 | MSFT | Microsoft Corporation Common Stock | $237.92 | -3.06 | -1.27% | 1,774,381,634,186 | /market-activity/stocks/msft |
2 | GOOG | Alphabet Inc. Class C Capital Stock | $99.17 | -1.40 | -1.392% | 1,293,573,480,000 | /market-activity/stocks/goog |
3 | GOOGL | Alphabet Inc. Class A Common Stock | $98.74 | -1.40 | -1.398% | 1,287,964,560,000 | /market-activity/stocks/googl |
4 | AMZN | Amazon.com, Inc. Common Stock | $113.78 | -3.53 | -3.009% | 1,157,926,339,396 | /market-activity/stocks/amzn |
5 | TSLA | Tesla, Inc. Common Stock | $275.33 | -13.26 | -4.595% | 862,738,307,490 | /market-activity/stocks/tsla |
6 | BRK/A | Berkshire Hathaway Inc. | $404485.25 | -889.76 | -0.219% | 594,946,837,609 | /market-activity/stocks/brk/a |
7 | BRK/B | Berkshire Hathaway Inc. | $267.77 | -0.74 | -0.276% | 590,783,995,813 | /market-activity/stocks/brk/b |
8 | UNH | UnitedHealth Group Incorporated Common Stock (DE) | $513.61 | -3.85 | -0.744% | 480,421,913,683 | /market-activity/stocks/unh |
9 | JNJ | Johnson & Johnson Common Stock | $166.72 | 0.54 | 0.325% | 438,336,872,094 | /market-activity/stocks/jnj |
Get Historical Prices
Pass a start date and end date in ISO format along with your ticker to nasdaq_historical_price to get historical prices
from dateutil.relativedelta import relativedelta
import time
import datetime as dt
#today
t = dt.date.today().replace(day=1)
#one year ago
t0 = t - relativedelta(years=1)
#isoformat
iso_t0, iso_t = t0.isoformat(), t.isoformat()
my_ng.nasdaq_historical_price('AAPL', iso_t0, iso_t)
date | close | volume | open | high | low | |
---|---|---|---|---|---|---|
0 | 09/01/2022 | $157.96 | 74,229,900 | $156.64 | $158.42 | $154.67 |
1 | 08/31/2022 | $157.22 | 87,991,090 | $160.305 | $160.58 | $157.14 |
2 | 08/30/2022 | $158.91 | 77,906,200 | $162.13 | $162.56 | $157.72 |
3 | 08/29/2022 | $161.38 | 73,313,950 | $161.145 | $162.9 | $159.82 |
4 | 08/26/2022 | $163.62 | 78,960,980 | $170.57 | $171.05 | $163.56 |
... | ... | ... | ... | ... | ... | ... |
248 | 09/08/2021 | $155.11 | 74,420,210 | $156.98 | $157.04 | $153.975 |
249 | 09/07/2021 | $156.69 | 82,278,260 | $154.97 | $157.26 | $154.39 |
250 | 09/03/2021 | $154.3 | 57,866,070 | $153.76 | $154.63 | $153.09 |
251 | 09/02/2021 | $153.65 | 71,171,320 | $153.87 | $154.72 | $152.4 |
252 | 09/01/2021 | $152.51 | 80,313,710 | $152.83 | $154.98 | $152.34 |
253 rows × 6 columns
Get Stocks Financal Data
Call nasdaq_financals and pass in a frequency you desire
- Annual
- Semi Annual
my_ng.nasdaq_financals('AAPL', 1)
symbol | tabs.incomeStatementTable | tabs.balanceSheetTable | tabs.cashFlowTable | tabs.financialRatiosTable | incomeStatementTable.headers.value1 | incomeStatementTable.headers.value2 | incomeStatementTable.headers.value3 | incomeStatementTable.headers.value4 | incomeStatementTable.headers.value5 | ... | cashFlowTable.headers.value3 | cashFlowTable.headers.value4 | cashFlowTable.headers.value5 | cashFlowTable.rows | financialRatiosTable.headers.value1 | financialRatiosTable.headers.value2 | financialRatiosTable.headers.value3 | financialRatiosTable.headers.value4 | financialRatiosTable.headers.value5 | financialRatiosTable.rows | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | AAPL | Income Statement | Balance Sheet | Cash Flow | Financial Ratios | Period Ending: | 9/25/2021 | 9/26/2020 | 9/28/2019 | 9/29/2018 | ... | 9/26/2020 | 9/28/2019 | 9/29/2018 | [{'value1': 'Net Income', 'value2': '$94,680,0... | Period Ending: | 9/25/2021 | 9/26/2020 | 9/28/2019 | 9/29/2018 | [{'value1': 'Liquidity Ratios', 'value2': '', ... |
1 rows × 29 columns
Get Other Data
Calling the nasdaq_data function and supplying type to any of the numbers below will get you
- Analyst Target Price and Ratings
- PEG Ratio
- Momentum Estimate
- Earnings Forecast
- Earnings Surprise
- EPS
#analysts ratings
my_ng.nasdaq_data('AAPL',1)
symbol | historicalConsensus | consensusOverview.lowPriceTarget | consensusOverview.highPriceTarget | consensusOverview.priceTarget | consensusOverview.buy | consensusOverview.sell | consensusOverview.hold | |
---|---|---|---|---|---|---|---|---|
0 | aapl | [{'z': {'buy': 19, 'hold': 5, 'sell': 0, 'date... | 136.0 | 220.0 | 183.45 | 23 | 1 | 4 |
#PEG Ratio
my_ng.nasdaq_data('AAPL',2)
pegr.label | pegr.text | pegr.pegValue | per.peRatioChart | per.label | per.text | per.dataProvider | gr.peGrowthChart | gr.title | |
---|---|---|---|---|---|---|---|---|---|
0 | Forecast 12 Month Forward PEG Ratio | Investors are always looking for companies wit... | 1.95 | [{'x': '2021 Actual', 'y': 26.81}, {'x': '2022... | Price/Earnings Ratio | Price/Earnings Ratio is a widely used stock ev... | <b>Data Provider:</b> Zacks Investment Research | [{'z': 'Growth', 'x': '2022', 'y': 8.8}, {'z':... | Forecast P/E Growth Rates |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nasdaq_data-0.1.0.tar.gz
.
File metadata
- Download URL: nasdaq_data-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d337c3771475c809dffb00d890a22c0bfa64b89a5b7de62b353293acceb2392 |
|
MD5 | 9e96b00f84bfa04af732f143e36b295f |
|
BLAKE2b-256 | 1773fb8b9be23b6196770c493a0f08cbac91d6253ad711fa2aee2490e3da00e5 |
File details
Details for the file nasdaq_data-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: nasdaq_data-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bad6bac57b1953e89df4475779544af876c5250457106a2bf5d543b999ba2ff8 |
|
MD5 | eb41fdad5fd9ba53eb8cf9f2b1e6af42 |
|
BLAKE2b-256 | b5dde57de73ef72376c3b752d13f8008d5a3573ddf420285d61d0fdd6f2ba5e1 |