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.

Installation

pip install norgatedata

Upgrades

To receive upgrades/updates

pip install norgatedata --upgrade

Requirements

  • Python 3.5 or above
  • Microsoft Windows
  • Either NumPy or Pandas
  • Active Norgate Data subscription
  • Writable local user folder named .norgatedata (or defined in environment variable NORGATEDATA_ROOT)

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

symbol = 'AMZN'
assetid = norgatedata.assetid(symbol)
assetid = 129769 
symbol = norgatedata.assetid(symbol)
base_type = norgatedata.base_type(symbol)
dopmcile = norgatedata.domicile(symbol)
currency = norgatedata.currency(symbol)
exchange_name = norgatedata.exchange_name(symbol)
exchange_name_full = norgatedata.exchange_name_full(symbol)
security_name = norgatedata.security_name(symbol)
subtype1 = norgatedata.subtype1(symbol)
subtype2 = norgatedata.subtype2(symbol)
subtype3 = norgatedata.subtype3(symbol)
financial_summary = norgatedata.financial_summary(symbol)
business_summary = norgatedata.business_summary(symbol)
last_quoted_date = norgatedata.last_quoted_date(symbol)
second_last_quoted_date = norgatedata.second_last_quoted_date(symbol)

Futures metadata

symbol='CL-'2017X'
lowest_ever_tick_size = norgatedata.lowest_ever_tick_size(symbol)
margin = norgatedata.margin(symbol)
point_value = norgatedata.point_value(symbol)
tick_size = norgatedata.tick_size(symbol)
first_notice_date = norgatedata.first_notice_date(symbol)

Fundamental data

fieldname = 'mktcap'
fieldname = 'ttmepsxlcx'
fieldname = 'peexclxor'
fieldname = 'projepsq'
field = norgatedata.fundamental(symbol,fieldname)

Classifications

schemename = 'NorgateFuturesClassification'
schemename = 'TRBC'
schemename = 'GICS'
classificationresulttype = 'ClassificationId'
classificationresulttype = 'Name'
classification = norgatedata.classification(symbol,schemename,classificationresulttype)
schemename = 'TRBC'
schemename = 'GICS'
classificationresulttype = 'ClassificationId'
classificationresulttype = 'Name'
level = 1
level = 4
classificationatlevel = norgatedata.classification(symbol,schemename,classificationresulttype,level)
indexfamilycode = '$SPX'
indexfamilycode = '$SP1500'
level = 3
indexreturntype = 'PR'
indexreturntype = 'TR'
indexsymbol = norgatedata.corresponding_industry_index(symbol,indexfamilycode,level,indexreturntype):

Other informational functions

norgatedata.last_database_update_time norgatedata.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 an 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


Download files

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

Files for norgatedata, version 1.0.2
Filename, size & hash File type Python version Upload date
norgatedata-1.0.2-py3-none-any.whl (11.9 kB) View hashes Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page