Skip to main content

A handy tool to get nasdaq data in python

Project description

Install guide

pip install nasdaq-data

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

  1. Annual
  2. 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

  1. Analyst Target Price and Ratings
  2. PEG Ratio
  3. Momentum Estimate
  4. Earnings Forecast
  5. Earnings Surprise
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nasdaq_data-0.1.1.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

nasdaq_data-0.1.1-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page