def main(): handle = EMF_QuandlAPI_Handle('WIKI','FB') (dates, values) = handle.get_data(columnName='Open') handle.set_extra_parameter('column_index', 1) (dates2, values2) = handle.get_data() assert np.all(dates==dates2) assert np.all(values==values2) print np.vstack((dates, values))
def __download_dataset_singleSeries(self, Q_DATABASE_CODE=None, Q_DATASET_CODE=None, Q_COLUMN_NUM=USE_DEFAULT, Q_COLLAPSE_INSTR=USE_DEFAULT, Q_TRANSFORM_INSTR=USE_DEFAULT, start_date=USE_DEFAULT): ''' TODOS: Only Download data that's necessary (i.e. after latest insert) (checking for updates) ''' # Set Quandl Query Parameters log.info('QUANDL: Downloading Quandl data for (Database|Dataset): ({0}|{1})'.format(Q_DATABASE_CODE,Q_DATASET_CODE)) hndl_Qndl = EMF_QuandlAPI_Handle(Q_DATABASE_CODE, Q_DATASET_CODE) # Set Quandl Query Parameters / Column Index hndl_Qndl.Instr_Col_Idx = Q_COLUMN_NUM # Set Quandl Query Parameters / Collapse hndl_Qndl.Instr_Collapse = Q_COLLAPSE_INSTR # Set Quandl Query Parameters / Transform hndl_Qndl.Instr_Transform = Q_TRANSFORM_INSTR # Set Quandl Query Parameters / Start Date hndl_Qndl.Instr_Start_Date = start_date # Download Quandl Data hndl_Qndl.get_data() try: log.info('QUANDL: Found {0} points from {1} to {2}. Periodicity: {3}' .format(hndl_Qndl.Data_Num_Points, hndl_Qndl.Data_Earliest_Date, hndl_Qndl.Data_Latest_Date, hndl_Qndl.Quandl_Periodicity)) if hndl_Qndl.Data_Num_Columns != 2 and Q_COLUMN_NUM == 1: log.warning('QUANDL: Found more than one column. Ensure you have right column).') except Exception: pass # Return return hndl_Qndl
from lib_EMF import TEMP_MODE, TEST_MODE, QA_MODE, PROD_MODE from util_DB import connect_to_DB # System From...Import from sys import argv import logging as log if __name__ == "__main__": raise NotImplementedError # Read Arguments args = argv[1:] (Q_DATABASE_CODE, Q_DATASET_CODE) = (args[0], args[1]) if len(args) == 2: pass elif len(args) == 3: (Q_DATABASE_CODE, Q_DATASET_CODE, Q_COLUMN_NUM) = (args[0], args[1], args[2]) else: exit(1) try: hndl_Qndl = EMF_QuandlAPI_Handle(Q_DATABASE_CODE, Q_DATASET_CODE) hndl_Qndl.get_data() # hndl_Qndl Now has dates, values, and metadata saved hndl_Data = EMF_DataSeries_Handle(self._hndl_DB, name=db_name, ticker=db_ticker, insertIfNot=True) except Exception, e: log.error("QUANDL_SINGLE: Unspecified Error.") log.error("QUANDL_SINGLE: " + e) exit(1) exit(0)