def get_prices(ticker, start_date): prices_df = norgatedata.price_timeseries(ticker, start_date=start_date, format=NORGATE_TIMESERIESFORMAT) prices_df['TICKER'] = ticker prices_df.index.rename('DATE', inplace=True) prices_df = drop_columns_from_norgate_dataset(prices_df) return prices_df.groupby(['TICKER', 'DATE']).min()
def load_ng_historical(symbol,startdate=str_to_dt('1970-01-01'),enddate=None,interval="D"): pricedata = ng.price_timeseries( symbol, stock_price_adjustment_setting = ng.StockPriceAdjustmentType.TOTALRETURN, padding_setting=ng.PaddingType.ALLWEEKDAYS, start_date = startdate, end_date = enddate, interval=interval, format='pandas-dataframe' ) return pricedata
def hist_sym(sym, start): #sym: symbol or ticker #start: start date 'yyyy-mm-dd' format priceadjust = norgatedata.StockPriceAdjustmentType.TOTALRETURN padding_setting = norgatedata.PaddingType.NONE timeseriesformat = 'pandas-dataframe' start_date = pd.Timestamp(start) try: dff = norgatedata.price_timeseries( sym, stock_price_adjustment_setting=priceadjust, padding_setting=padding_setting, start_date=start_date, format=timeseriesformat) return (dff) except: return ('no symbol')
def norgate_defined_start(watchlist, start_date, end_date, frequency): symbols = norgatedata.watchlist_symbols(watchlist) df_list = [] for symbol in symbols: norgate_df = norgatedata.price_timeseries(symbol, start_date=start_date, end_date=end_date, interval=frequency, format='pandas-dataframe') # creating a symbol column so that we can identify # what ticker information we're looking at norgate_df['Symbol'] = symbol # appending the dataframes to an empty list to concatenate them after the for loop df_list.append(norgate_df) return df_list
def create_index(start, end, index_ticker): symbol = index_ticker norgate_df = norgatedata.price_timeseries(symbol, start_date=start, end_date=end, interval='D', format='pandas-dataframe') norgate_df.drop([ 'Open', 'High', 'Low', 'Volume', 'Turnover', 'Unadjusted Close', 'Dividend' ], axis=1, inplace=True) # changing name from Close to whatever the ticker is norgate_df.rename({'Close': index_ticker}, inplace=True, axis=1) # return the cumulative pct return over the period we have the data for norgate_df[index_ticker] = np.cumprod( 1 + norgate_df[index_ticker].pct_change()) return norgate_df
from datetime import datetime lookback_period = 60 end_date = datetime.now() watchlistname = 'spy_tlt_gld' symbols = norgatedata.watchlist_symbols(watchlistname) df_list = [] for symbol in symbols: norgate_df = norgatedata.price_timeseries( symbol, end_date=end_date, limit=lookback_period, interval='D', format='pandas-dataframe') # creating a symbol column so that we can identify # what ticker information we're looking at norgate_df['Symbol'] = symbol # appending the dataframes to an empty list to concatenate them after the for loop df_list.append(norgate_df) # joins the dataframes together for all tickers appended_data = pd.concat(df_list) # just keep the closing data and the symbol