Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Python library for Nasdaq Data Link's RESTful API

License

NotificationsYou must be signed in to change notification settings

Nasdaq/data-link-python

Repository files navigation

This is the official documentation for Nasdaq Data Link's Python Package. The package can be used to interact with the latest version of theNasdaq 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

OptionExplanationExample
api_keyYour access keytEsTkEy123456789
use_retriesWhether API calls which return statuses inretry_status_codes should be automatically retriedTrue
number_of_retriesMaximum number of retries that should be attempted. Only used ifuse_retries is True5
max_wait_between_retriesMaximum amount of time in seconds that should be waited before attempting a retry. Only used ifuse_retries is True8
retry_backoff_factorDetermines the amount of time in seconds that should be waited before attempting another retry. Note that this factor is exponential so aretry_backoff_factor of 0.5 will cause waits of [0.5, 1, 2, 4, etc]. Only used ifuse_retries is True0.5
retry_status_codesA list of HTTP status codes which will trigger a retry to occur. Only used ifuse_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 anyinline boilerplate.

EnvDescription
NASDAQ_DATA_LINK_API_KEYThe SDK will configure itself to use the given API Key
NASDAQ_DATA_LINK_BASE_DOMAINThe 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 settingNASDAQ_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. Theclient will attempt to load this file if it exists. Note: if the file existsand empty, a ValueError will be thrown.

Alternative API Key file location

Since 1.0.1, thenasdaq-data-link module will attempt to autoload your API Key. If you prefer to store it in another location, you mustexplicitly callread_key() with a custom path. See below:

importnasdaqdatalinknasdaqdatalink.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:

importnasdaqdatalinkdata=nasdaqdatalink.get('NSE/OIL')

This example finds all data points for the datasetNSE/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:

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

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

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

Logging

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

importnasdaqdatalinkimportlogginglogging.basicConfig()# logging.getLogger().setLevel(logging.DEBUG)  # optionally set level foreverything.Usefultoseedependencydebuginfoaswell.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 ourDetailed Method Guide.

Local Development

Setup

If you wish to work on local development please clone/fork the git repo and usepip 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. Installvirtualenv andtox 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-Walwayssetup.py-qtest

Running an individual test

python-munittesttest.[testfilename].[classname].[individualtestname]`

Example:

python-munittest-vtest.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 manipulationin pandas itself.

Seethis link for more information about timeseries in pandas.

Release the Package

To release the package, you can follow the instructions on thispage

Additional Links

License

MIT License

About

A Python library for Nasdaq Data Link's RESTful API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp