Package: norgatedata
Python interface to financial market data provided byNorgate Data.Table of ContentsBasicsRequirementsInstallationUpgradesUsagePrice and Volume DataExamplesDatetime formatsDividend NotesTime Series DataIndex ConstituentsMajor Exchange ListedBlank Check CompanyCapital EventDividend YieldPadding StatusUnadjusted CloseSingle Value DataMetadataSecurity informationClassificationsFutures metadataFundamental dataSecurity listsWatchlistsDatabasesOther informational functionsAdditional notesAccessing data by assetid instead of symbolError HandlingMultithreading / Multiprocessing compatibilityPython Quant/Backtesting Package IntegrationZiplineBacktraderpybacktestTensorflowKerasMore Python Quant/Backtesting/Machine Learning/Neural Network PackagesSupportRecent Version HistoryBasicsRequirementsPython 3.5+ (has been tested with 3.5, 3.6, 3.7, 3.8, 3.9, 3.10)Microsoft WindowsPackages: pandas, numpy, requests and logbook (these will be installed by pip, or you can install them prior to installing this package)ActiveNorgate DatasubscriptionNorgate Data Updater software installed and runningWritable local user folder named .norgatedata - ie. C:\Users<your username>.norgatedata (or you can specify your own folder using environment variable NORGATEDATA_ROOT)Note: The "Norgate Data Updater" application (NDU) is a Windows-only application. NDU must be running for this Python package to work.InstallationpipinstallnorgatedataUpgradesTo receive upgrades/updatespipinstallnorgatedata--upgradeUsageimportnorgatedataPrice and Volume DataPrice 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 and end_date can be provided as a string (YYYY-MM-DD or YYYYMMDD format),# datetime, Pandas Timestamp, or NumPy datetime64.  All types work!start_date='1990-01-01'# If not specified, the start date is the start of the history for that symbolend_date='2000-01-01'# If not specified, the end date is todaylimit=50# This provides the last X records, by date in descending order.  If not specified, all records are returnedinterval='D'# D=Daily, W=Weekly, M=Monthly - Note: the date given is the last date of the intervalPrice & Volume adjustment allows you to adjust historical stock prices and volumes to account for the effect of capital events and dividends.priceadjust=norgatedata.StockPriceAdjustmentType.NONEpriceadjust=norgatedata.StockPriceAdjustmentType.CAPITALpriceadjust=norgatedata.StockPriceAdjustmentType.CAPITALSPECIALpriceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURN# DefaultDate padding allows you to repeat the prior close on days where no price record would otherwise exist.padding_setting=norgatedata.PaddingType.NONE# Defaultpadding_setting=norgatedata.PaddingType.ALLMARKETDAYSpadding_setting=norgatedata.PaddingType.ALLWEEKDAYSpadding_setting=norgatedata.PaddingType.ALLCALENDARDAYS# This can be useful to obtain an end-of-motnh or end-of-quarter valueColumns returned include Date, Open, High, Low, and Close.    For certain instruments, additional columns are provided where applicable including: Volume (Stocks, some Indices, some Indicators, Futures), Turnover (Stocks, some Indices, some Indicators), Unadjusted Close (Stocks), Dividend (Stocks), Open Interest (Futures, ASX Exchange Traded Options), Delivery Month (Continuous Futures).Examplesimportnorgatedatapriceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEsymbol='AAPL'start_date='1990-01-01'timeseriesformat='numpy-recarray'# Provides data on GOOG from 1990 until today in# a NumPy recarray format, with explicitly set stock price# adjustment and padding settingspricedata_recarray=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,timeseriesformat=timeseriesformat,)# Now in a Pandas-compatible formatimportpandasaspdtimeseriesformat='pandas-dataframe'start_date=pd.Timestamp('1900-01-01')# we can also provide dates as a Pandas Timestamppricedata_dataframe=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,timeseriesformat=timeseriesformat,)# Weekly data insteadtimeseriesformat='pandas-dataframe'start_date=pd.Timestamp('1900-01-01')# we can also provide dates as a Pandas Timestamppricedata_dataframe=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,timeseriesformat=timeseriesformat,interval='W')# Now in a Numpy Ndarrayimportnumpyasnptimeseriesformat='numpy-ndarray'start_date=np.datetime64('1900-01-01')# we can also provide dates as a Numpy datetime64pricedata_ndarray=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,timeseriesformat=timeseriesformat,)# Now limiting results to final 500 barspricedata_dataframe=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,limit=500,timeseriesformat=timeseriesformat,)# Now limiting results to a specific date rangeend_date='1999-12-31'pricedata_dataframe=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,end_date=end_date,timeseriesformat=timeseriesformat,)# Now using a numerical unchanging assetid instead of a symboltimeseriesformat='pandas-dataframe'assetid=136817pricedata_dataframe=norgatedata.price_timeseries(assetid,limit=500,timeseriesformat=timeseriesformat,)Datetime formatsBy default, NumPy ndarray and recarray provides datetime64 formattted as '<M8[D]' (daily dates) as timezone naive.  Pandas dataframes default to use datetime64 formattted as '[ns]' to match Pandas Timestamp, as timezone naive.These can be altered with the following parameters:datetimeformat='<desired format>'allowed values are:'datetime' : Provides Python datetime.datetime objects'date' : Provides Python datetime.date objects'datetime64ns': Provides timezone-naive NumPy datetime64 in 'datetime64[ns]' format'datetime64ms': Provides timezone-naive NumPy 'datetime64[ms]' format'm8d': Provides timezone-naive NumPy datetime64 in '<M8[D]' formattimezone='<desired timezone>'This will allocate the dates into the timezone as shown on any of the time series functions. Times will still be shown as 00:00:00.
Accepts a string with valid timezones such as 'UTC', 'US/Eastern' etc.Dividend NotesDividends shown in the price_timeseries Dividend column depending on whether or not they have already been accounted for in the data by the "Price Adjustment" method.If the data is adjusted for capital reconstructions only, then the sum of both special and ordinary dividends for that day are shown.If the data is adjusted for capital reconstructions and special dividends, then only the sum of ordinary dividends for that day are shown.If the data is adjusted for capital reconstructions, special dividends and ordinary dividends, then no information is shown.Dividend/Distribution information is shown as of the day before the ex-date - i.e. if you are holding the security at the close, you will be entitled to the dividend/distribution.Time Series DataIndex ConstituentsTo 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.Note: Access to historical index constituents requires a Norgate Data Stocks subscription at the Platinum or Diamond level.symbol='AAPL'indexname='Russell 3000'indexname='S&P 500'# Can also be an index symbol, such as $SPX, $RUI etc.idx=norgatedata.index_constituent_timeseries(symbol,indexname,timeseriesformat="numpy-recarray",)# Timeseries against a specific symbol starting from start_date in numpy-ndarray formatidx=norgatedata.index_constituent_timeseries(symbol,indexname,padding_setting=padding_setting,start_date=start_date,timeseriesformat="numpy-ndarray",)# Timeseries against a specific symbol starting from start_date in pandas dataframe formatidx=norgatedata.index_constituent_timeseries(symbol,indexname,padding_setting=padding_setting,start_date=start_date,timeseriesformat="pandas-dataframe",)# Let's pass in data from a recarray for TWTRimportnorgatedataimportpandasaspdpriceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEsymbol='TWTR'timeseriesformat='numpy-recarray'priceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEpricedata_recarray=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,timeseriesformat=timeseriesformat,)# and now make the call to index_constituent_timeseriespricedata_recarray2=norgatedata.index_constituent_timeseries(symbol,indexname,padding_setting=padding_setting,numpy_recarray=pricedata_recarray,timeseriesformat=timeseriesformat,)# Alternative using pandas dataframes instead:importnorgatedataimportpandasaspdpriceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEsymbol='TWTR'timeseriesformat='pandas-dataframe'priceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEpricedata_df=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,timeseriesformat=timeseriesformat,)# and now make the call to index_constituent_timeseriespricedata_df2=norgatedata.index_constituent_timeseries(symbol,indexname,padding_setting=padding_setting,pandas_dataframe=pricedata_df,timeseriesformat=timeseriesformat,)Major Exchange Listedmajexch=norgatedata.major_exchange_listed_timeseries(symbol,timeseriesformat="numpy-recarray")Provides indication about US stocks on whether they are listed on a major exchange (e.g. NYSE, Nasdaq, NYSE American, NYSE Arca, Cboe BZX, IEX) (value = 1) or as an OTC/Pink Sheet stock (value = 0) for each trading date is available for all Equities and ETPs.Note:  Data is only available for this item from 2000 onwards.Note: Access to major exchange listing requires a Norgate Data Stocks subscription at the Platinum or Diamond level.Blank Check Companymajexch=norgatedata.blank_check_company_timeseries(symbol,timeseriesformat="numpy-recarray")Show periods when the company is regarded to be a blank check company.Note: Access to blank check company requires a Norgate Data Stocks subscription at the Platinum or Diamond level.Capital Eventcapevent=norgatedata.capital_event_timeseries(symbol,timeseriesformat="numpy-recarray")This indicator will show when a capital event occurred. Effective on holding the security at the close on the day prior to the ex-date. Events include splits, reverse splits, bonus issues, stock dividends (dividends paid as stock) and complex reorganizations of capital (value = 1, otherwise if there is no event, value = 0)Dividend Yielddivyield=norgatedata.dividend_yield_timeseries(symbol,timeseriesformat="numpy-recarray",)This indicator uses a trailing 12 month sum of all split-adjusted ordinary dividends and is calculated daily against the close price. New dividends are incorporated on the entitlement date (the trading day prior to the ex-dividend date) after which the trailing 12 month sum of dividends is recalculated. Special dividends, distributions and spin-offs are not included. The lookback period is adaptive to take into account slight variations in ex-dividend dates from year-to-year.Padding Statuspaddingstatus=norgatedata.padding_status_timeseries(symbol,timeseriesformat="numpy-recarray",)This indicator will show when a price record has been padded in accordance with the Date Padding setting. If the Date Padding is set to "No padding" then this indicator will not return any values.Unadjusted CloseThis is not normally needed, as Unadjusted Close is provided in the price timeseries.It is provided here to be used as a helper routine for other Python libraries such
as zipline-norgatedata.unadjclose=norgatedata.unadjusted_close_timeseries(symbol,timeseriesformat="numpy-recarray",)Single Value DataMetadataSecurity informationAssetid / Symbol Translationsymbol='AMZN'assetid=norgatedata.assetid(symbol)Provides a unique unchanging ID generated by Norgate.assetid=129769symbol=norgatedata.symbol(assetid)Translates assetid to the current symbol.Domiciledomicile=norgatedata.domicile(symbol)Provides the country code for the domicile of the company.Currencycurrency=norgatedata.currency(symbol)Currency that the security trades in.Short Exchange Nameexchange_name=norgatedata.exchange_name(symbol)Short name of the exchange for the security (e.g. NYSE, Nasdaq, NYSE Arca, NYSE American, ASX etc.)Full Exchange Nameexchange_name_full=norgatedata.exchange_name_full(symbol)Provides long name of the exchange (e.g. New York Stock Exchange, Australian Securities Exchange etc.)Security Namesecurity_name=norgatedata.security_name(symbol)Provides the name of the security.  e.g. GE would return General Electric Co Common.Base Typebase_type=norgatedata.base_type(symbol)Provides the base type of a security.    Values include Stock Market, Futures Market, Commodity Cash & Forwards, Foreign Exchange, Economic.Subtype1subtype1=norgatedata.subtype1(symbol)Provides subtype1 of the security.    Values include Equity, Hybrid, Derivative, Debt, Exchange Traded Product, Business Activity, Employment, Prices, Money, National Accounts, Index, Currency Cross, Bullion Cross, Cryptocurrency.Subtype2subtype2=norgatedata.subtype2(symbol)Provides subtype2 of the security. Values include Operating/Holding Company, Investment Company, Special Purpose Company, Exchange Traded Note, Structured Product, Exchange Traded Fund, Exchange Traded Managed Fund, Third Party Trust Preferred, Corporate Unit, Convertible Corporate Unit, Convertible Preferred, Preferred, Convertible Debt, Exchange Traded Option, Right, Company Option, Warrant, Senior Debt, Junior Debt, Coin, Token.Subtype3subtype3=norgatedata.subtype3(symbol)Provides subtype3 of the security.   Values include Master Limited Partnership, Royalty Trust, Infrastructure Fund, Closed End Fund, Other Listed Managed Investment, Business Development Company/Pooled Development Fund, Other Listed Investment Vehicle, Absolute Return Fund, Equity Unit, Right, Contingent Value Right, Litigation Trust, Liquidation Trust, Special Purpose Acquisition Company.Financial Summaryfinancial_summary=norgatedata.financial_summary(symbol)Provides a few paragraphs summarising the current financial status of the company.Business Summarybusiness_summary=norgatedata.business_summary(symbol)Provides a few paragraphs summarising the operations of the company.First Quoted Datefirst_quoted_date=norgatedata.first_quoted_date(symbol)first_quoted_date=norgatedata.first_quoted_date(symbol,datetimeformat='iso')first_quoted_date=norgatedata.first_quoted_date(symbol,datetimeformat='pandas-timestamp')first_quoted_date=norgatedata.first_quoted_date(symbol,datetimeformat='numpy-datetime64')first_quoted_date=norgatedata.first_quoted_date(symbol,datetimeformat='datetime')Provides a date for the first day the security traded.By default the datetimeformat is an ISO string (YYYY-MM-DD), but you can also specify other formats too.Last Quoted Datelast_quoted_date=norgatedata.last_quoted_date(symbol)last_quoted_date=norgatedata.last_quoted_date(symbol,datetimeformat='iso')last_quoted_date=norgatedata.last_quoted_date(symbol,datetimeformat='pandas-timestamp')last_quoted_date=norgatedata.last_quoted_date(symbol,datetimeformat='numpy-datetime64')last_quoted_date=norgatedata.last_quoted_date(symbol,datetimeformat='datetime')Provides a date for the last day of trading that have a finite lifespan (such as futures).  For delisted instruments, this provides the final day of trading.  By default the format is an ISO string (YYYY-MM-DD), but you can also specify other formats too.
Will provide None if there is no last quoted date.Second Last Quoted Datesecond_last_quoted_date=norgatedata.second_last_quoted_date(symbol)second_last_quoted_date=norgatedata.second_last_quoted_date(symbol,datetimeformat='iso')second_last_quoted_date=norgatedata.second_last_quoted_date(symbol,datetimeformat='pandas-timestamp')second_last_quoted_date=norgatedata.second_last_quoted_date(symbol,datetimeformat='numpy-datetime64')second_last_quoted_date=norgatedata.second_last_quoted_date(symbol,datetimeformat='datetime')Provides a date for the second last day of trading that have a finite lifespan (such as futures).  For delisted instruments, this provides the trading day prior to the last quoted day.
Will provide None if there is no last quoted date.ClassificationsMechanisms are provided to obtain the most detailed classification, classification at a level and an industry index that corresponds to the given symbol.Classificationschemename='NorgateDataFuturesClassification'schemename='TRBC'schemename='GICS'classificationresulttype='ClassificationId'classificationresulttype='Name'classification=norgatedata.classification(symbol,schemename,classificationresulttype,)Provides the classification for a given security as a string.    Returns None if there is no classification available.Classification At Levelschemename='TRBC'schemename='GICS'classificationresulttype='ClassificationId'classificationresulttype='Name'level=1level=4classificationatlevel=norgatedata.classification_at_level(symbol,schemename,classificationresulttype,level,)Provides the classification for a given security, at a given level of the classification scheme as a string.  Returns None if there is no classification available.Corresponding Industry Indexsymbol='GE'indexfamilycode='$SPX'indexfamilycode='$SP1500'level=3indexreturntype='PR'indexreturntype='TR'indexsymbol=norgatedata.corresponding_industry_index(symbol,indexfamilycode,level,indexreturntype,)Provides the symbol of a corresponding index, at a given level of the classification scheme.  Returns None if there is no classification for the current symbol or no currently-trading index that matches.Shares Outstanding / Shares Floatsymbol='GE'sharesout,sharesoutdate=norgatedata.sharesoutstanding(symbol)sharesout,sharesoutdate=norgatedata.sharesoutstanding(symbol,datetimeformat='iso')sharesout,sharesoutdate=norgatedata.sharesoutstanding(symbol,datetimeformat='pandas-timestamp')sharesout,sharesoutdate=norgatedata.sharesoutstanding(symbol,datetimeformat='numpy-datetime64')sharesout,sharesoutdate=norgatedata.sharesoutstanding(symbol,datetimeformat='datetime')Provides the number of shares outstanding and date on which this was last modified for a given security.  By default, the date is provided as a string in YYYY-MM-DD format, but other date formats can be specified.symbol='GE'sharesfloat,sharesfloatdate=norgatedata.sharesfloat(symbol)sharesfloat,sharesfloatdate=norgatedata.sharesfloat(symbol,datetimeformat='iso')sharesfloat,sharesfloatdate=norgatedata.sharesfloat(symbol,datetimeformat='pandas-timestamp')sharesfloat,sharesfloatdate=norgatedata.sharesfloat(symbol,datetimeformat='numpy-datetime64')sharesfloat,sharesfloatdate=norgatedata.sharesfloat(symbol,datetimeformat='datetime')Provides the number of free float shares and date on which this was last modified for a given security.  By default, the date is provided as a string in YYYY-MM-DD format, but other date formats can be specified.Futures metadataTick sizeProvides the current tick value (i.e. the change in value of one contract for a single tick that the futures contract moves.) for a given market.symbol='CL-2017X'tick_size=norgatedata.tick_size(symbol)Point Valuesymbol='CL-2017X'point_value=norgatedata.point_value(symbol)Provides the point value (i.e. the change in value of one contract for whole point that the futures contract moves.) for a given futures market.Marginsymbol='CL-2017X'margin=norgatedata.margin(symbol)Provides the current margin for a given futures contract, futures market session symbol or futures market symbol.First Notice Datesymbol='CL-2017X'first_notice_date=norgatedata.first_notice_date(symbol)first_notice_date=norgatedata.first_notice_date(symbol,datetimeformat='iso')first_notice_date=norgatedata.first_notice_date(symbol,datetimeformat='pandas-timestamp')first_notice_date=norgatedata.first_notice_date(symbol,datetimeformat='numpy-datetime64')first_notice_date=norgatedata.first_notice_date(symbol,datetimeformat='datetime')For deliverable commodity contracts that permit delivery prior to the end of trading, this is the first date that delivery notices can be provided for a given futures contract.
For futures contracts that are not deliverable (or only deliverable at the end of trading) then None is provided.Lowest Ever Tick Sizesymbol='CL-2017X'lowest_ever_tick_size=norgatedata.lowest_ever_tick_size(symbol)Provides the lowest ever tick size for a given futures market.Session Typesymbol='FDAX-2019Z'sessiontype=norgatedata.session_type(symbol)# Returns "Electronic"symbol='FDAX9-2019Z'sessiontype=norgatedata.session_type(symbol)# Returns "Electronic (Last)"session_symbol='FDAX9'sessiontype=norgatedata.session_type(session_symbol)# Returns "Electronic (Last)"Returns the session type for a given symbol or session symbol.Market Namemarket_symbol='CL'marketname=norgatedata.futures_market_name(market_symbol)# Returns "Crude Oil"Provides the name of the futures marketFutures Market Session Namesession_symbol='FDAX9'session_name=norgatedata.futures_market_session_name(session_symbol)# Returns "DAX (L)"Provides the name of the futures market sessionFutures Market Session Symbolsymbol='FDAX9-2020Z'session_symbol=norgatedata.futures_market_session_symbol(symbol)# Returns "FDAX9"Provides the session symbol for a given futures contractFutures Market Symbolsymbol='FDAX9-2020Z'session_symbol=norgatedata.futures_market_symbol(symbol)# Returns "FDAX"Provides the market symbol for a given futures contract.Futures Market Session Contractssession_symbol='FDAX9'session_symbol=norgatedata.futures_market_session_contracts(session_symbol)# Returns a list ['FDAX9-2005Z', 'FDAX9-2006H', ..., 'FDAX9-2021M']Provides all contracts (active and expired) for a given futures session symbol.Futures Market Symbolsmarket_symbols=norgatedata.futures_market_symbols()# Returns a list ['6A', '6B', ... 'FCE', 'FDAX', 'FESX', 'FGBL',  ... 'ZT', 'ZW']'Provides a list of all futures market symbols.Futures Market Session Symbolssession_symbols=norgatedata.futures_market_session_symbols()# Returns a list ['6A', '6B', ... 'FCE', 'FDAX', 'FDAX9', 'FESX', 'FEX9', 'FGBL',  ...  'ZT', 'ZW']'Provides a list of all futures market session symbols.NotesNote:  For all futures metadata the "symbol" can be individual futures contract, a continuous contract symbol, the futures market session symbol or the futures market symbol.  (e.g. FDAX9-2019Z, &FDAX9, FDAX9, FDAX respectively).  The only exception to this is any date-related metadata, which can only be performed on the individual futures contract.Fundamental datasymbol='GE'# A selection of field examples - many more are availablefieldname='mktcap'fieldname='ttmepsxlcx'fieldname='peexclxor'fieldname='projepsq'fieldname='sharesoutstanding'fieldname='sharesfloat'fundavalue,fundadate=norgatedata.fundamental(symbol,fieldname)fundavalue,fundadate=norgatedata.fundamental(symbol,fieldname,datetimeformat='iso')fundavalue,fundadate=norgatedata.fundamental(symbol,fieldname,datetimeformat='pandas-timestamp')fundavalue,fundadate=norgatedata.fundamental(symbol,fieldname,datetimeformat='numpy-datetime64')fundavalue,fundadate=norgatedata.fundamental(symbol,fieldname,datetimeformat='datetime')Provides thecurrent fundamentalsReturns the field and the date applicable to the field (e.g. the last day of the quarter to which it applies, or for current ratios the most recent date of change).  By default, the date is provided as a string in YYYY-MM-DD format, but other date formats can be specified.Returns None,None if the fieldname is not available for that security.Security listsWatchlistsPython can retrieve the contents of any watchlist that exists inNDU's WatchList LibraryWhen you create a watchlist, you can make it as broad or narrow as you like. To have a dynamic watchlist for the entire "Stock Market", don't apply any filters.The symbols of a watchlist can be retrieved into a Python list using the watchlist_symbols() and watchlist() functions.Watchlist Symbolswatchlistname='S&P 500'symbols=norgatedata.watchlist_symbols(watchlistname)watchlistname='Russell 3000 Current & Past'symbols=norgatedata.watchlist_symbols(watchlistname)Watchlist SecuritiesIf you want the symbol, assetid and name of each security, use the watchlist functionwatchlistname='Russell 3000 Current & Past'wlcontents=norgatedata.watchlist(watchlistname)Available WatchlistsTo retrieve the names of all of the watchlists within Norgate Data's watchlist library, use  the watchlists() functionallwatchlistnames=norgatedata.watchlists()DatabasesPython can retrieve the contents of any database available in a subscription. You can see which databases are available by opening NDU and clicking on the "Database" tab.As an example, a subscriber to US Stocks at the Platinum level should see the following databases in the "Database List":
'US Equities', 'US Equities Delisted', 'US Indices', 'World Indices','Economic', 'Forex Spot', and 'Futures Continuous'.Database Symbolsdatabasename='US Equities'symbols=norgatedata.database_symbols(databasename)databasename='World Indices'symbols=norgatedata.database_symbols(databasename)Database SecuritiesIf you want the symbol, assetid and name of each security provided, use the database function:databasename='AU Equities'databasecontents=norgatedata.database(databasename)Available DatabasesTo retrieve the names of all available databases, use the databases() function.alldatabasenames=norgatedata.databases()Futures SymbolsSee Futures Market Symbols and Futures Market Session Symbols above.Other informational functionsnorgatedata.last_database_update_time(database) - returns a datetime object when price-related information was updated for a given database, where database is the shortened form for each database.  Database names include au, aueto, auwarrant, auindex, ca, caindex, us, usindex, cashcommodity, economic, future, forex, contfuture, worldindex.  The datetime object provided is the local PC time when the database was last updated (it does not refer to the latest price date in the databse).norgatedata.last_price_update_time(symbol) datetime when price-related information was last updated for the given symbol.  The datetime object provided is the local PC time when the database was last updated (it does not refer to the latest price date in the databse).norgatedata.status() - shows whether NDU is running (returns True if running, or False if not)Additional notesAccessing data by assetid instead of symbolInstead of using a security's symbol, you can obtain its unique Norgate-provided identity known as assetid.  This is an unchanging number and is therefore useful when storing positions/orders into data files where the symbol may change in the future.All of the calls above that reference 'symbol' (as a string) can also take an assetid (as an integer).  For example, symbol MSFT = assetid 134016.  symbol AMZN = assetid 129769.Error HandlingIf an invalid symbol or invalid parameters are specified, then the ValueError exception will be raised.The logger module will also output human-interpretable detail relating to the error.If there is no data available (for example, a informational or fundamental field that is not reported for that company), then None is returned, except in the case where multiple values are expected eg. (None, None).Multithreading / Multiprocessing compatibilityThe norgatedata package is compatible with multithreading and multiprocessing libraries/packages, to take advantage of multiple CPU cores.  This can result in a significant reduction in runtime by running operations in parallel, depending upon workload.Python Quant/Backtesting Package IntegrationAll of the routines developed in this module provide the data that can be used for backtesting/scanning of data.  There are many backtesting packages developed that use Python.  In this section, we provide more information about how to use with popular backtesting python packages with sample code and/or links to Norgate-developed integration packages.ZiplineThe package:zipline-norgatedataprovides a tight integration betweenZiplineandNorgate DataKey FeaturesSurvivorship bias-free bundlesIncorporates time series data such as historical index membership and dividend yield into Zipline's Pipeline mechanismNo modifications to the Zipline code base (except to fix problems with installation and obsolete calls that crash Zipline)Simple bundle creationEasy ingestion of equities data into Zipline with a simple list of symbols you want to incorporate and/or import your own symbol lists and/or use pre-built or user-created watchlists from Norgate DataEasy ingestion of futures data into Zipline with a simple list of symbols you want to incorporate, futures market sessions you want to incorporate,  and/or use pre-built or user-created watchlists from Norgate DataBacktraderBacktraderis a Python framework for backtesting and trading.To create a "data feed" of a given symbol:importbacktraderasbtimportnorgatedata# ... your code here ...cerebro=bt.Cerebro()# create a "Cerebro" engine instance# ... your code here ...# Obtain a Pandas dataframe for a given security from Norgate Datapriceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEsymbol='AAPL'start_date='2010-01-01'timeseriesformat='pandas-dataframe'pricedata_dataframe=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,timeseriesformat=timeseriesformat,)# Rename columns to suit Backtraderpricedata_dataframe.rename(columns={'Open':'open','High':'high','Low':'low','Close':'close','Volume':'volume','Open Interest':'open interest'},inplace=True)# Backtrader can convert this dataframe into its own internal format with:data=bt.feeds.PandasData(dataname=pricedata_dataframe)cerebro.adddata(data)# Add the data feed# ... your code here ...pybacktestpybacktestis a backesting package for simple backtests against a single security.  It is no longer maintained by its author but it is still functional.Pre-requisites:Python 3.5-3.9GitVirtual Environment (e.g. Anaconda)Here's how we installed it:Install the 64 bitMiniCondaorAnaconda Distribution.Install the 64 bit version ofGitand used all default options at install time.Start an Anaconda (base) prompt, create an environment and install the appropriate versions of packages as follows:conda create -n pybacktest39 python=3.9
conda activate pybacktest39
pip install git+https://github.com/ematvey/pybacktest.git
pip install pandas_datareader
pip install norgatedataHere's a sample piece of code that uses data from Norgate data.importnorgatedataimportpybacktestimportpandas# Obtain data from Norgate Data first, in Pandas dataframe formatpriceadjust=norgatedata.StockPriceAdjustmentType.TOTALRETURNpadding_setting=norgatedata.PaddingType.NONEsymbol='AAPL'start_date='2010-01-01'timeseriesformat='pandas-dataframe'ohlc=norgatedata.price_timeseries(symbol,stock_price_adjustment_setting=priceadjust,padding_setting=padding_setting,start_date=start_date,timeseriesformat=timeseriesformat,)# Change column namesohlc.rename(columns={'Open':'O','High':'H','Low':'L','Close':'C','Volume':'V'},inplace=True)# sample pybacktest code:ms=ohlc.C.rolling(50).mean()ml=ohlc.L.rolling(100).mean()buy=cover=(ms>ml)&(ms.shift()<ml.shift())sell=short=(ms<ml)&(ms.shift()>ml.shift())backtestresults=pybacktest.Backtest(locals())TensorflowTensorflowUse the convert_to_tensor() function to convert a Numpy Array for use with theTensorFlow machine learning platformAlso:TF Quant FinanceKerasKerasUse the tensorflow.keras.backend.variable() to convert a Numpy Array for use with theKeras deep learning libraryMore Python Quant/Backtesting/Machine Learning/Neural Network PackagesHere is a list of Python packages that might be worthwhile examining to incoroporate data from Norgate Data.  Some of these might be abandonware too.  Let us know if there's more worthy of integration.AlephNullalphatoolsanalzyer- fork of UltrafinanceatspyAuquan ToolboxbacktestingbtbulbeaclairvoyantDX AnalyticsEliteQuant_Pythonempyricalfinmarketpypossibly by extendinghttps://github.com/cuemacro/findatapygeminiibridgepyLeanmfinlabpandas-tapandas-talibPerformance Analytics- port of the RPinkfishpressoProfitPyProphetPyAlgoTradePyfoliopytipyqstratpysystemtradeQSForexQSTraderQTPyLibquantQuantSoftware ToolkitQuantdomQuantibRQalphasktimestock_backtestertata_backtestTA-Libtalibtia: Toolkit for integration and analysistslearnTrading with PythonUltra-Finance- Also see analyzer abovevector-btvisualize-wealthSupportNorgate Data supportRecent Version Historyv1.0.57 20210421 Fix typo on capitalevent parameter
v1.0.58 20210421 Fix datetime decode
v1.0.59 20210427 Fix timezone routines on Pandas dataframes
v1.0.60 20210918 Fix datetime conversion routines, and provide error on unknown type
v1.0.61 20220204 Bump to documentation to show Python 3.10 compatibility (no other changes)
v1.0.62 20220422 Handle version check file with unparseable json
v1.0.63 20221027 Better docs
v1.0.64 20221129 Fix datetimeformat=date/datetime in pandas-dataframe from being returned as a tupled object due to astype changes in numpy
v1.0.65 20230207 Better checking of .norgatedata storage folder and error message
v1.0.66 20230310 Use random filename during init routines to prevent multiple instances from having an issue
v1.0.67 20230501 Make decode_date have a default parameter for timezone of UTC, but tz=None can be passed in to make it naive.  This is an enhancement to support datetime changes in Zipline 2.4
v1.0.68 20230619 Documentation fixes - hyperlinks test
v1.0.69 20230619 Documentation fixes - pypi hyperlinks now work!
v1.0.70 20230619 Documentation fixes - pypi hyperlinks now work!!
v1.0.71 20230619 Documentation fixes - pypi hyperlinks now work!!!
v1.0.72 20230619 Documentation fixes - pypi hyperlinks now work!!!!
v1.0.73 20230710 Documentation now includes recent change log and upgrade warning is made more visible
v1.0.74 20231004 Blank Check Company Time Series added