Giter Site home page Giter Site logo

data-link-python's Introduction

Nasdaq Data Link Python Client

This is the official documentation for Nasdaq Data Link's Python Package. The package can be used to interact with the latest version of the Nasdaq Data Link's RESTful API. This package is compatible with python v3.7+.

Installation

The installation process varies depending on your python version and system used. However in most cases the following should work:

pip install nasdaq-data-link

Alternatively on some systems python3 may use a different pip executable and may need to be installed via an alternate pip command. For example:

pip3 install nasdaq-data-link

Configuration

Option Explanation Example
api_key Your access key tEsTkEy123456789
use_retries Whether API calls which return statuses in retry_status_codes should be automatically retried True
number_of_retries Maximum number of retries that should be attempted. Only used if use_retries is True 5
max_wait_between_retries Maximum amount of time in seconds that should be waited before attempting a retry. Only used if use_retries is True 8
retry_backoff_factor Determines the amount of time in seconds that should be waited before attempting another retry. Note that this factor is exponential so a retry_backoff_factor of 0.5 will cause waits of [0.5, 1, 2, 4, etc]. Only used if use_retries is True 0.5
retry_status_codes A list of HTTP status codes which will trigger a retry to occur. Only used if use_retries is True [429, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511]

By default, SSL verification is enabled. To bypass SSL verification (not recommended), simply:

nasdaqdatalink.ApiConfig.verify_ssl = False

Environment Variables

You may use environment variables to configure the Data Link SDK to avoid any inline boilerplate.

Env Description
NASDAQ_DATA_LINK_API_KEY The SDK will configure itself to use the given API Key
NASDAQ_DATA_LINK_BASE_DOMAIN The SDK will configure itself to use the provided domain

Local API Key Environment Variable

If you wish to store your API as an environment variable, you can do so by setting NASDAQ_DATA_LINK_API_KEY. If set, NASDAQ_DATA_LINK_API_KEY will take precedence over the API Key file mentioned below.

Local API Key file

The default configuration file location is ~/.nasdaq/data_link_apikey. The client will attempt to load this file if it exists. Note: if the file exists and empty, a ValueError will be thrown.

Alternative API Key file location

Since 1.0.1, the nasdaq-data-link module will attempt to autoload your API Key. If you prefer to store it in another location, you must explicitly call read_key() with a custom path. See below:

import nasdaqdatalink
nasdaqdatalink.read_key(filename="/data/.corporatenasdaqdatalinkapikey")

Retrieving Data

There are two methods for retrieving data in Python: the Quick method and the Detailed method. The latter is more suitable to application programming. Both methods work with Nasdaq Data Link's two types of data structures: time-series (dataset) data and non-time series (datatable).

The following quick call can be used to retrieve a dataset:

import nasdaqdatalink
data = nasdaqdatalink.get('NSE/OIL')

This example finds all data points for the dataset NSE/OIL and stores them in a pandas dataframe. You can then view the dataframe with data.head().

A similar quick call can be used to retrieve a datatable:

import nasdaqdatalink
data = nasdaqdatalink.get_table('ZACKS/FC', ticker='AAPL')

This example retrieves all rows for ZACKS/FC where ticker='AAPL' and stores them in a pandas dataframe. Similarly you can then view the dataframe with data.head().

Note that in both examples if an api_key has not been set you may receive limited or sample data. You can find more details on these quick calls and others in our Quick Method Guide.

Logging

Currently, Nasdaq Data Link debug logging is limited in scope. However, to enable debug logs you can use the following snippet.

import nasdaqdatalink
import logging

logging.basicConfig()
# logging.getLogger().setLevel(logging.DEBUG)  # optionally set level for
everything.  Useful to see dependency debug info as well.

data_link_log = logging.getLogger("nasdaqdatalink")
data_link_log.setLevel(logging.DEBUG)

Detailed Usage

Our API can provide more than just data. It can also be used to search and provide metadata or to programmatically retrieve data. For these more advanced techniques please follow our Detailed Method Guide.

Local Development

Setup

If you wish to work on local development please clone/fork the git repo and use pip install -r requirements.txt to setup the project.

Testing

We recommend the following tools for testing any changes:

  • nose for running tests.
  • tox for testing against multiple versions of python.
  • flake8 for syntax checking.
  • virtualenv for use with tox virtualization.

The following are instructions for running our tests:

  1. Make sure a version of 3.x is installed locally in your system. To avoid permission issues on OSX we recommend installing the packages from: https://www.python.org/downloads/
  2. Install virtualenv and tox using: pip install tox virtualenv
  3. Run following command (you may notice slow performance the first time): python setup.py install
  4. Run the following command to test the plugin in all versions of python we support: tox

Once you have all required packages installed, you can run tests locally with:

Running all tests locally

python -W always setup.py -q test

Running an individual test

python -m unittest test.[test file name].[class name].[individual test name]`

Example:

python -m unittest -v test.test_datatable.ExportDataTableTest.test_download_get_file_info

Recommended Usage

We would suggest downloading the data in raw format in the highest frequency possible and performing any data manipulation in pandas itself.

See this link for more information about timeseries in pandas.

Release the Package

To release the package, you can follow the instructions on this page

Additional Links

License

MIT License

data-link-python's People

Contributors

couture-ql avatar dimitryzub avatar ericvautour-quandl avatar runawaycoast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

data-link-python's Issues

Whitespace characters in ApiConfig.api_key cause runtime-errors

When setting ApiConfig.api_key the client does not try hard enough to remove whitespace before setting up the x-api-token http header.

Users that set an apikey in ~/.nasdaq/data_link_apikey tend to copy / paste their API key from their user profile.

It's also possible the environment variable suffers from the same problem. Since ApiConfig is treated as a global variable, and does not .strip() on set, users run into run-time errors.

While pr #11 attempts to fix one use-case for reading from a file, it is possible to run into the same issue using environment variables.

Ensure both use-case strip whitespace before setting the ApiConfig property.

Unable to use api key

I am beginner at coding.

Should I store the api key in a json format file? containing the following statement : api_key = XXXXXXXXXXX (my api key)

AND
import nasdaqdatalink
nasdaqdatalink.read_key(filename="/path")

the path begins where my code is located or should I write the full path of the archive?

Where is list of all ticker symbols

Hi, I want to use this code
data = nasdaqdatalink.Dataset('WIKI/AAPL').data()

Is there a way to get all tickers? I asked Google's BARD and it came up with
import nasdaqdatalink
nasdaq_data_link = nasdaqdatalink.NasdaqDataLink(api_key="YOUR_API_KEY")
tickers = nasdaq_data_link.get_all_tickers()
print(tickers)

Problem is "get_all_tickers" doesnt exist. Using the above example, how can I actually get all ticker symbols?

I have spent hours digging through tutorials and it is not intuitive or clear what the database and ticker values are. A list of each would be helpful.
If I am to loop through this: data = nasdaqdatalink.Dataset('WIKI/AAPL').data()
We need a a list of database and ticker codes

EOD - What tables are available?

Hello,

I have an EOD product subscription, using python and the nasdaqdatalink.get_table(...) function.
I know that exist 'QUOTEMEDIA/TICKERS', 'QUOTEMEDIA/PRICES' and 'QUOTEMEDIA/DAILYPRICES' that I can query.
I'm interested also in like company master data overview, news, dividends important dates, financial's stats that stand behind each separate ticker.

What other tables exists, from where I can pull the data I'm interested in?
Where I can find a detailed and useful documentation on the database (list of tables at least)?
If my current subscription is not enough , what subscription I need?

Best regards,
Valter

No prices for currencies change since 29/11/22

Hello,
Since the 29 November we don't have any values from your api for everything related to the currencies change.

For example nasdaqdatalink.get("ECB/EURGBP", start_date="2022-12-05", api_key=...)
does not return anything.

Can you enlighten me on the subject ?

Regards,

Can I get market prices through this API?

Hello, I hope this message finds you well. I would like to retrieve historical data for Brent Oil, API2 Carbon and Henry Hub gas, also the Exchange rates for dollar, euro and Yuan. I've been trying to read the docs and the tables but it has been difficult for me to find if I can retrieve this information from this API. Could you help me with the table that can fit my request? If it exists... Thank you in advance

Module 'nasdaqdatalink' has no attribute 'get'

Hello,

The below code send me an error code: AttributeError: module 'nasdaqdatalink' has no attribute 'get'

import nasdaqdatalink
data = nasdaqdatalink.get('NSE/OIL')
print(data)

Python version 3.7.3
nasdaq-data-link in /usr/local/lib/python3.7/dist-packages (1.0.4)

Best Regards

Does the free user can only get 28 companies for SP500 index?

Does the free user can only get 28 companies for SP500 index?

sp500com = nasdaqdatalink.get_table('SHARADAR/SP500', action='current')
sp500com
           date   action ticker  ... contraticker contraname  note
None                             ...                              
0    2023-01-20  current    XOM  ...          N/A        N/A  None
1    2023-01-20  current    WMT  ...          N/A        N/A  None
2    2023-01-20  current     VZ  ...          N/A        N/A  None
3    2023-01-20  current    UNH  ...          N/A        N/A  None
4    2023-01-20  current   TSLA  ...          N/A        N/A  None
5    2023-01-20  current    TRV  ...          N/A        N/A  None
6    2023-01-20  current     PG  ...          N/A        N/A  None
7    2023-01-20  current    PFE  ...          N/A        N/A  None
8    2023-01-20  current    NKE  ...          N/A        N/A  None
9    2023-01-20  current   MSFT  ...          N/A        N/A  None
10   2023-01-20  current    MRK  ...          N/A        N/A  None
11   2023-01-20  current    MMM  ...          N/A        N/A  None
12   2023-01-20  current    MCD  ...          N/A        N/A  None
13   2023-01-20  current     KO  ...          N/A        N/A  None
14   2023-01-20  current    JPM  ...          N/A        N/A  None
15   2023-01-20  current    JNJ  ...          N/A        N/A  None
16   2023-01-20  current   INTC  ...          N/A        N/A  None
17   2023-01-20  current    IBM  ...          N/A        N/A  None
18   2023-01-20  current     HD  ...          N/A        N/A  None
19   2023-01-20  current     GS  ...          N/A        N/A  None
20   2023-01-20  current     GE  ...          N/A        N/A  None
21   2023-01-20  current     DD  ...          N/A        N/A  None
22   2023-01-20  current    CVX  ...          N/A        N/A  None
23   2023-01-20  current   CSCO  ...          N/A        N/A  None
24   2023-01-20  current    CAT  ...          N/A        N/A  None
25   2023-01-20  current     BA  ...          N/A        N/A  None
26   2023-01-20  current    AXP  ...          N/A        N/A  None
27   2023-01-20  current   AAPL  ...          N/A        N/A  None

[28 rows x 7 columns]
len(sp500com)
28

DataLinkError: (Status 403) - Cant load data from API

Hi, i am having this issue when i try to load the API table. How can I solve this?


DataLinkError: (Status 403) Something went wrong. Please try again. If you continue to have problems, please contact us at [email protected].


Code:

import nasdaqdatalink

nasdaq_api_key ='my-key'
nasdaqdatalink.read_key(nasdaq_api_key)

df = nasdaqdatalink.get_table('MER/F1', paginate=True)
df

Date Filters Possible for "ZILLOW/DATA" Dataset?

Hi team,

Is it possible to have date filters possible for the "ZILLOW/DATA" dataset?

This is my code right now:

    data = nasdaqdatalink.get_table(
        "ZILLOW/DATA",
        indicator_id="ZALL",
        region_id="62004",
        paginate=True,
    )

I would like to add an additional filter for the date since there can be many records available.

Is this project dead?

The first datasets I'm looking at haven't been updated in 9 months: https://data.nasdaq.com/data/FRED/DGS10-10year-treasury-constant-maturity-rate

There's no way for me to ask about it because all the help links 404 on https://help.data.nasdaq.com/category/339-data-quality-issues which is the page that came up on Google

This library hasn't been updated in 6 mos and looking at the code here makes it quite unclear who should be contacted as it seems the contact info was possibly supposed to be updated months ago and it never happened for some reason: #29

Timeout for hung requests

Sometimes when downloading a lot of data from NasdaqDataLink, I get a hung connection during the ssl handshake. The requests library, which is being used to make requests, can take a timeout parameter, but this is not exposed through the API as far as I can tell.

What's the best way to retry after a timeout?

I noticed that the ApiConfig and Connection have retry parameters, but it still appears to be hanging.

adj_* data information required

Hello to all,
I have some questions regarding the adjusted data.

  1. I understand that the data can vary from broker to broker for a little bit but why nasdaq have in the same row the "regular" data (open, high, low, close) and the adjusted data (adj_open, adj_high, adj_low, adj_close)?
  2. Why the adj_* data exists in first place and how is calculated?
  3. Why for the date before and included 2022-11-08 the adj_* data is so different from the "regular" data?
  4. What data is best to use for further calculation and data manipulation?

Folowing is the data:

     ticker       date    open    high     low   close     volume  dividend  split    adj_open    adj_high     adj_low   adj_close  adj_volume
0       IBM 2022-11-14  142.63  146.08  142.18  144.20  5293453.0      0.00    1.0  142.630000  146.080000  142.180000  144.200000   5293453.0
1       IBM 2022-11-11  141.50  144.13  140.96  143.17  5869298.0      0.00    1.0  141.500000  144.130000  140.960000  143.170000   5869298.0
2       IBM 2022-11-10  140.26  141.37  138.29  141.23  5386540.0      0.00    1.0  140.260000  141.370000  138.290000  141.230000   5386540.0
3       IBM 2022-11-09  137.95  138.90  136.94  137.39  4718328.0      1.65    1.0  137.950000  138.900000  136.940000  137.390000   4718328.0
4       IBM 2022-11-08  139.00  140.93  138.72  140.04  5039458.0      0.00    1.0  137.350475  139.257571  137.073797  138.378133   5039458.0
5       IBM 2022-11-07  136.64  138.70  136.51  138.34  4042576.0      0.00    1.0  135.018481  137.054035  134.890024  136.698307   4042576.0
6       IBM 2022-11-04  135.65  137.73  134.94  136.96  4176645.0      0.00    1.0  134.040229  136.095546  133.338655  135.334684   4176645.0
7       IBM 2022-11-03  136.42  136.48  133.97  134.47  4441075.0      0.00    1.0  134.801092  134.860380  132.380166  132.874233   4441075.0
8       IBM 2022-11-02  137.75  140.17  136.80  136.83  5360222.0      0.00    1.0  136.115309  138.506590  135.176582  135.206226   5360222.0
9       IBM 2022-11-01  138.25  138.65  136.70  138.20  3574815.0      0.00    1.0  136.609375  137.004628  135.077769  136.559968   3574815.0

The upper data was received using:

    data = nasdaqdatalink.get_table('QUOTEMEDIA/PRICES', ticker='IBM',
                                    date={'gte': '2022-11-01', 'lte': '2022-11-14'}, paginate=True)
    print(data)

Thank you in advance for your time and answers and helping me understanding and getting a dipper knowledge of the market data.
Best regards,
Valter

ResourceWarning: unclosed <ssl.SSLSocket

I just purchased a subscription but am getting errors.

Can you also confirm if this is the right way to filter for specific columns?

Code:

import nasdaqdatalink

sharadarKeyFile = './keys/nasdaqdatalinkapikey'

nasdaqdatalink.read_key(filename = sharadarKeyFile)

SHARADAR_TABLE_NAME = 'SHARADAR/SEP'

liveSEP = nasdaqdatalink.get_table(
        SHARADAR_TABLE_NAME,
        date = {'gte': '2022-08-01'},
        paginate = True,
        qopts = {
            'columns': ','.join(['ticker', 'date', 'open', 'close', 'closeadj', 'closeunadj'])
        }
    )

Throws the following exceptions:

Exception ignored in: <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59345), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/site-packages/nasdaqdatalink/model/datatable.py", line 31, in data
    return Data.page(self, **options)
ResourceWarning: unclosed <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59345), raddr=('45.60.150.18', 443)>
Exception ignored in: <ssl.SSLSocket fd=79, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59237), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/re.py", line 291, in _compile
    if isinstance(flags, RegexFlag):
ResourceWarning: unclosed <ssl.SSLSocket fd=79, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59237), raddr=('45.60.150.18', 443)>
Exception ignored in: <ssl.SSLSocket fd=78, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59329), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/re.py", line 291, in _compile
    if isinstance(flags, RegexFlag):
ResourceWarning: unclosed <ssl.SSLSocket fd=78, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59329), raddr=('45.60.150.18', 443)>
Exception ignored in: <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59347), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/site-packages/nasdaqdatalink/model/datatable.py", line 31, in data
    return Data.page(self, **options)
ResourceWarning: unclosed <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59347), raddr=('45.60.150.18', 443)>

Treasury Data Unavailable After January 5th

Though I usually update treasury data every day, and as recently as Friday (2024-01-12), data link code USTREASURY/YIELD is now returning no data past 2024-01-05. Has the data code changed? The python usage example at https://data.nasdaq.com/data/USTREASURY-us-treasury/usage/quickstart/python now sees the quandl package utilized instead of nasdaqdatalink, and with a different data code / endpoint.

I know it seems a bunch of data has become deprecated, but I can't imagine this is the case for Treasury Data. Please let me know what is going on. Thanks

types of network protocols

Hi there,

just a simple question.

Which kind of network protocol are compatible with Nasdaq for messages and order management?
I've found out FIX protocol (used for messages between brokers, investment banks financial advisors etc.) but i would like to know if there are alternatives (maybe own by Nasdaq)

Thanks

How to get available dataset name list?

In the example, need to set dataset name like below.

import nasdaqdatalink
data = nasdaqdatalink.get('NSE/OIL')

'NSE/OIL' seems like a dataset name.
So where is the list of available dataset names?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.