Skip to main content

Python interface to financial data provided by Norgate Data

Project description

Project description

Interfaces to financial market data provided by Norgate Data.

This is currently in alpha stage testing to selected users of Norgate Data.

Installation

pip install norgatedata

or, if you prefer to use conda:

conda install -c norgatedata norgatedata

Upgrades

To receive upgrades/updates (highly recommended, especially while this is in alpha test):

pip update norgatedata

or, if you prefer to use conda:

conda update norgatedata

Requirements

  • Python 3.5 or above
  • Microsoft Windows
  • Either NumPy or Pandas
  • Active Norgate Data subscription

Usage

import norgatedata

Timeseries data

Price

Price data is provided in multiple formats: NumPy recarray, NumPy ndarray or Pandas DataFrame. This is determined through the format parameter. If not specified, the default is NumPy recarray.

Dates are determined by passing in any (or none) of the following named parameters:

start_date = '1990-01-01'   # Date is in YYYY-MM-DD format
end_date = '2000-01-01'   # If not specified, the end date is today
limit = 50  # This provides the last X records

Price & Volume adjustment allows you to adjust historical stock prices and volumes to account for the effect of capital events and dividends.

stock_price_adjustment_setting = norgatedata.StockPriceAdjustmentType.NONE
stock_price_adjustment_setting = norgatedata.StockPriceAdjustmentType.CAPITAL
stock_price_adjustment_setting = norgatedata.StockPriceAdjustmentType.CAPITALSPECIAL    
stock_price_adjustment_setting = norgatedata.StockPriceAdjustmentType.TOTALRETURN        # Default, if not specified on timeseries calls

Date padding allows you to repeat the prior close on days where no price record would otherwise exist.

padding_setting = norgatedata.PaddingType.NONE   # Default, if not specified on timeseries calls
padding_setting = norgatedata.PaddingType.ALLMARKETDAYS
padding_setting = norgatedata.PaddingType.ALLWEEKDAYS
padding_setting = norgatedata.PaddingType.ALLCALENDARDAYS

Examples

import norgatedata
stock_price_adjustment_setting = norgatedata.StockPriceAdjustmentType.TOTALRETURN 
padding_setting = norgatedata.PaddingType.NONE   
symbol = 'GOOG'
start_date = '1990-01-01'
timeseriesformat = 'numpy-recarray'
# This provides data on GOOG from 1990 until today in a NumPy recarray format, with explicitly set stock price adjustment and padding settings
pricedata_recarray = norgatedata.price_timeseries(symbol,
                          stock_price_adjustment_setting = stock_price_adjustment_setting,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          format=timeseriesformat)

timeseriesformat = 'pandas-dataframe'
pricedata_dataframe = norgatedata.price_timeseries(symbol,
                          stock_price_adjustment_setting = stock_price_adjustment_setting,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          format=timeseriesformat)

timeseriesformat = 'numpy-ndarray'
pricedata_ndarray = norgatedata.price_timeseries(symbol,
                          stock_price_adjustment_setting = stock_price_adjustment_setting,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          format=timeseriesformat)

pricedata_dataframe = norgatedata.price_timeseries(symbol,
                          stock_price_adjustment_setting = stock_price_adjustment_setting,
                          padding_setting = padding_setting,
                          limit=500,
                          format=timeseriesformat)


end_date='1999-12-31'
pricedata_dataframe = norgatedata.price_timeseries(symbol,
                          stock_price_adjustment_setting = stock_price_adjustment_setting,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          end_date = end_date,
                          format=timeseriesformat)

timeseriesformat = 'pandas-dataframe'
assetid = 129769
pricedata_dataframe = norgatedata.price_timeseries(assetid,
						  limit=500,
                          format=timeseriesformat)

index constituent

To determine whether a stock was an index constituent on a particular date, you can use the index constituent timeseries function. You can also pass in an existing NumPy ndarray or Pandas Dataframe and a new column will be added and returned

symbol = 'AAPL'
indexname = 'S&P 500'  # Can also be an index symbol, such as $SPX, $RUI etc.

idx = norgatedata.index_constituent_timeseries(symbol,
                          indexname,
                          format = "numpy-recarray")

idx = norgatedata.index_constituent_timeseries(symbol,
                          indexname,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          limit = -1,
                          format = "numpy-ndarray")

idx = norgatedata.index_constituent_timeseries(symbol,
                          indexname,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          limit = -1,
                          format = "pandas-dataframe")

pricedata_recarray2 = norgatedata.index_constituent_timeseries(symbol,
                          indexname,
                          padding_setting = padding_setting,
                          start_date = start_date,
                          limit = -1,
                          numpy_recarray = pricedata_recarray,
						  format = "numpy-recarray")

Major Exchange Listed

'major_exchange_listed_timeseries'

majexch = norgatedata.major_exchange_listed_timeseries(symbol,
                          format = "numpy-recarray")

Note: Data is only available for this item from 2000 onwards.

Capital Event

'capital_event_timeseries'

capevent = norgatedata.capital_event_timeseries(symbol,
                          format = "numpy-recarray")

Dividend Yield

'dividend_yield_timeseries'

divyield = norgatedata.dividend_yield_timeseries(symbol,
                          format = "numpy-recarray")

Watchlists

The symbols of a watchlist can be retrieved into a python list using the watchlist_symbols function

watchlistname = 'S&P 500'
symbols = norgatedata.watchlist_symbols(watchlistname)

watchlistname = 'Russell 3000 Current & Past'
symbols = norgatedata.watchlist_symbols(watchlistname)

If you want the symbol, assetid and name of each security, use the watchlist function

wlcontents = norgatedata.watchlist(watchlistname)

To retrieve the names of all of the watchlists within Norgate Data's watchlist library, use the watchlists function

allwatchlistnames = norgatedata.watchlists()

Security metadata

TODO: assetid symbol base_type domicile currency exchange_name exchange_name_full security_name subtype1 subtype2 subtype3financial_summary business_summary last_quoted_date second_last_quoted_date

Futures metadata

TODO: 'lowest_ever_tick_size','margin','point_value','tick_size','first_notice_date',

Fundamental data

fundamental

Classifications

classification','classification_at_level','corresponding_industry_index'

Other informational functions

'last_database_update_time','last_price_update_time',

Accessing data by assetid instead of symbol

Instead of using a security's symbol, you can obtain its unique Norgate-provided identity known as assetid. This is a unchanging nuber.

All of the calls above that reference 'symbol' can also take an assetid. For example, MSFT = assetid 134016. AMZN = assetid 129769.

Support

Norgate Data support

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

norgatedata-0.1.48-py3-none-any.whl (10.4 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