Что такое quandl python

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

quandl / quandl-python Public archive

License

quandl/quandl-python

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Added description about branding change and link to new Github package to encourage users to use the new version.

Git stats

Files

Failed to load latest commit information.

README.md

Quandl is now Nasdaq Data Link

We are excited to announce that the Quandl technology platform is being transformed into a new global solution: Nasdaq Data Link. This development is the first step toward realizing a single, unified data discovery and delivery experience with Nasdaq.

In accordance with this change Nasdaq Data Link has released a new version of this Python Client. Moving forward, we are encouraging user to use this VERSION in order to take advantage of new features.

This is the official documentation for Quandl’s Python Package. The package can be used to interact with the latest version of the Quandl RESTful API. This package is compatible with python v2.7.x and v3.x+.

Deprecation of old package

Please see this readme for more information and upgrade instructions: 2.x series transition notes

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

Читайте также:  Checking data error in php

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

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]
import quandl quandl.ApiConfig.api_key = 'tEsTkEy123456789'

By default, SSL verification is enabled. To bypass SSL verification

quandl.ApiConfig.verify_ssl = False

Save local key to $HOME/.quandl_apikey file

import quandl quandl.save_key("supersecret") print(quandl.ApiConfig.api_key) 

Load the API Key without exposing the key in the script or notebook

import quandl quandl.read_key() print(quandl.ApiConfig.api_key) 

Set a custom location for the API key file, e.g. store the externally outside a docker container

import quandl quandl.save_key("ourcorporateapikey", filename="/srv/data/somecontainer/.corporatequandlapikey") 

and call within the docker container with mount point at /data

import quandl quandl.read_key(filepath="/data/.corporatequandlapikey") 

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 Quandl’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 quandl data = quandl.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 quandl data = quandl.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.

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

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

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.

Читайте также:  Redefinition of unused python

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.

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 python 2.7 or python 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]`
python -m unittest -v test.test_datatable.ExportDataTableTest.test_download_get_file_info

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.

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

Источник

Quandl API for Python

Basic wrapper to return datasets from the Quandl website as Pandas dataframe objects with a timeseries index, or as a numpy array. This allows interactive manipulation of the results via IPython or storage of the datasets using Pandas I/O functions. You will need a familarity with pandas to get the most out of this.

See the Quandl API for more information.

Usage

Usage is simple and mirrors the functionality found at Quandl/API.

A request with a full list of options would be the following.

python data = Quandl.get(‘PRAGUESE/PX’, authtoken=’xxxxxx’, trim_start=’2001-01-01′, trim_end=’2010-01-01′, collapse=’annual’, transformation=’rdiff’, rows=4, returns=’numpy’)

All options beyond specifying the dataset (PRAUGESE/PX) are optional,though it is helpful to specify an authtoken at least once to increase download limits.

You can then view the dataframe with data.head() .

Читайте также:  Php if is home is paged

See the pandas documentation for a wealth of options on data manipulation.

Authtokens are saved as pickled files in the local directory so it is unnecessary to enter them more than once, unless you change your working directory. To replace simply save the new token or delete the authtoken.p file.

Search Example

Using the search function you can search Quandl, specifying what sources to search, and what page you wish to show.

Quandl.search(query = "Search terms", source = "Source you wish to search", page = 1) 

An example of searching for datasets having to do with oil:

python import Quandl datasets = Quandl.search('OIL') datasets[0] 

Get Example

An example of creating a pandas time series for IBM stock data, with a weekly frequency:

python data = Quandl.get(‘GOOG/NYSE_IBM’, collapse=’weekly’) data.head()

No authentication tokens found,usage will be limited Returning Dataframe for GOOG/NYSE_IBM Open High Low Close Volume Date 2013-03-28 209.83 213.44 209.74 213.30 3752999 2013-03-15 215.38 215.90 213.41 214.92 7937244 2013-03-08 209.85 210.74 209.43 210.38 3700986 2013-03-01 200.65 202.94 199.36 202.91 3309434 2013-02-22 199.23 201.09 198.84 201.09 3107976 

Push Example

You can now upload your own data to Quandl through the Python package.

At this time the only accepted format is a date indexed Pandas DataSeries.

Things to do before you upload:

  • Make an account and set your authentication token within the package with the Quandl.auth() function.
  • Get your data into a data frame with the dates in the first column.
  • Pick a code for your dataset — only capital letters, numbers and underscores are acceptable.

Then call the following to push the data:

python Quandl.push(data, code=’TEST’, name=’Test’, desc=’test’)

All parameters but desc are necessary

If you wish to override the existing set at code TEST add override=True .

Uploading a pandas DataSeries with random data:

«`python import pandas import numpy

index = [‘Dec 12 2296’, ‘Dec 21 1998’, ‘Oct 9 2000’, ‘Oct 19 2001’, ‘Oct 30 2003’, ‘Nov 12 2003’] data = pandas.DataFrame(numpy.random.randn(6, 3), index=index, columns=[‘D’, ‘B’, ‘C’]) print Quandl.push(data, code=’F32C’, name=’Test’, desc=’test’, authtoken=’xxxxxx’) «`

Will print the link to your newly uploaded data.

The IPython notebook is an excellent python environment for interactive data work. Spyder is also a superb IDE for analysis and more numerical work.

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

See this link for more information about timeseries in pandas.

Questions/Comments

Please send any questions, comments, or any other inquires about this package to Chris@quandl.com.

Installation

The stable version of Quandl can be installed with pip:

Источник

Оцените статью