How to use the quandl.get_table function in Quandl

To help you get started, we’ve selected a few Quandl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quandl / quandl-python / test / test_get_table.py View on Github external
def test_get_table_calls_connection_with_params_for_get_request(self, mock):
        params = {'ticker': ['AAPL', 'MSFT'],
                  'per_end_date': {'gte': '2015-01-01'},
                  'qopts': {'columns': ['ticker', 'per_end_date']},
                  'foo': 'bar',
                  'baz': 4
                  }

        expected_params = {'ticker[]': ['AAPL', 'MSFT'],
                           'per_end_date.gte': '2015-01-01',
                           'qopts.columns[]': ['ticker', 'per_end_date'],
                           'foo': 'bar',
                           'baz': 4
                           }

        quandl.get_table('ZACKS/FC', **params)
        expected = call('get', 'datatables/ZACKS/FC', params=expected_params)
        self.assertEqual(mock.call_args, expected)
github quandl / quandl-python / test / test_get_table.py View on Github external
def test_get_table_calls_connection_with_no_params_for_get_request(self, mock):
        quandl.get_table('ZACKS/FC')
        expected = call('get', 'datatables/ZACKS/FC', params={})
        self.assertEqual(mock.call_args, expected)
github hellobiek / smart_deal_tool / visualization / cal.py View on Github external
def get_data(start_date, end_date, selected = ['AAPL']):
    data = quandl.get_table('WIKI/PRICES', ticker = selected,\
           qopts = {'columns': ['date', 'high', 'low', 'open', 'close', 'volume', 'adj_close']},\
           date = {'gte': start_date, 'lte': end_date}, paginate=True)
    data['return_t+1'] = data['adj_close'].pct_change(1).shift(-1) 
    data['return_t+3'] = data['adj_close'].pct_change(3).shift(-3) 
    data = data.iloc[:-5]
    data.index = data.date
    return data
github CapstoneProject18 / Stock-Market-Analysis / visualization / Visualisation / views.py View on Github external
# 		company_details_values['website'] = 'NA'



	# 	return render(request, 'visualisation/company.html', { 'date' : date_json  , 'price' : close_json , 'company' : company,'company_details' : company_details,'company_details_values' : company_details_values})

       
	# else:
	pred = {}
	


	arg = request.GET.get('company_name')
	quandl.ApiConfig.api_key = "23KLyzjn5UvKQog-DZyM"
	company = arg
	data = quandl.get_table('WIKI/PRICES', ticker = company,
		qopts = { 'columns': ['ticker', 'date', 'adj_close' , 'volume'] },
		date = { 'gte': '2015-12-31', 'lte': '2016-12-31' }, 
		paginate=True)
	data = data.set_index('ticker')
	print(type(data))
	date_col = data.ix[:,0]
	date_json = date_col.to_json(orient='records')
	close_col = data.ix[:,1]
	volume = data.ix[:,2]
	print(date_col)
	close_json = close_col.to_json(orient='records')
	print(date_json)
	print(close_json)

	company_excel = pd.read_excel("CompanyData.xlsx")
	compn = company_excel[company_excel.ticker == company]['compnumber']
github pbharrin / alpha-compiler / alphacompiler / data / load_quandl_sf1.py View on Github external
of dimensions for each field.
    """
    assert len(fields) == len(dimensions)
    quandl_tools.set_api_key()

    # existing = listdir(RAW_FLDR)

    for ticker, sid in tickers.items():
        # if "%d.csv" % sid in existing:
        #     continue
        try:
            query_str = "%s %s" % (DS_NAME, ticker)
            print("fetching data for: {}".format(query_str))

            # df = quandl.get_table(query_str, start_date=START_DATE, end_date=END_DATE)
            df = quandl.get_table(DS_NAME,
                                  calendardate={'gte': START_DATE, 'lte': END_DATE},
                                  ticker=ticker,
                                  qopts={'columns': ['dimension', 'datekey'] + fields})
            df = df.rename(columns={'datekey': 'Date'}).set_index('Date')

            # loop over the fields and dimensions
            series = []
            for i, field in enumerate(fields):
                s = df[df.dimension == dimensions[i]][field]
                series.append(s)
            df = pd.concat(series, axis=1)
            print(df)

            # write raw file: raw/
            df.to_csv(os.path.join(raw_path, "{}.csv".format(sid)))
        except quandl.errors.quandl_error.NotFoundError:
github jiewwantan / StarTrader / data_preprocessing.py View on Github external
def get_adj_close(self, selected):
        """
        Get a 3D dataframe of Adjusted close price from Quandl.
        """
        # get adjusted closing prices of 5 selected companies with Quandl
        quandl.ApiConfig.api_key = 'CxU5-dDyxppBFzVgGG6z'
        data = quandl.get_table('WIKI/PRICES', ticker=selected,
                                qopts={'columns': ['date', 'ticker', 'adj_close']},
                                date={'gte': START_TRAIN, 'lte': END_TRAIN}, paginate=True)
        return data
github ivan-vasilev / atpy / atpy / data / quandl / api.py View on Github external
def mp_worker(f):
        try:
            data = None
            if api_type == __APIType.TIME_SERIES:
                data = quandl.get(**f, paginate=True, api_key=api_k)
                if data is not None:
                    data = data.tz_localize('UTC', copy=False)
                    q.put((f['dataset'], processor(data, **f) if processor is not None else data))
            elif api_type == __APIType.TABLES:
                data = quandl.get_table(**f, paginate=True, api_key=api_k)
                if data is not None:
                    q.put((f['datatable_code'], processor(data, **f) if processor is not None else data))

        except Exception as err:
            data = None
            logging.getLogger(__name__).exception(err)

        if data is None:
            no_data.add(f)

        with lock:
            global_counter['c'] += 1
            cnt = global_counter['c']
            if cnt == len(filters):
                q.put(None)
github CapstoneProject18 / Stock-Market-Analysis / visualization / Visualisation / views.py View on Github external
paginate=True)
	data = data.set_index('ticker')
	print(type(data))
	date_col = data.ix[:,0]
	date_json = date_col.to_json(orient='records')
	close_col = data.ix[:,1]
	volume = data.ix[:,2]
	print(date_col)
	close_json = close_col.to_json(orient='records')
	print(date_json)
	print(close_json)

	company_excel = pd.read_excel("CompanyData.xlsx")
	compn = company_excel[company_excel.ticker == company]['compnumber']
	
	data = quandl.get_table('MER/F1', reportdate='2013-03-31', compnumber=compn ,paginate=True)

	
	if(not data.empty and not compn.empty):
		company_details = {}
		company_details_values = {} 

		data_headers = list(data)
		company_details['company_number'] = data_headers[0]
		company_details['report_date'] = data_headers[4]
		company_details['report_type'] = data_headers[5]
		company_details['currency'] = data_headers[7]	
		company_details['long_name'] = data_headers[9]	
		company_details['short_name'] = data_headers[10]	
		company_details['status'] = data_headers[11]	
		company_details['country_code'] = data_headers[12]
		company_details['region'] = data_headers[13]
github CapstoneProject18 / Stock-Market-Analysis / visualization / Visualisation / views.py View on Github external
def home(request):
	
	quandl.ApiConfig.api_key = "23KLyzjn5UvKQog-DZyM"
	company = 'AIG'
	data = quandl.get_table('WIKI/PRICES', ticker = company,
		qopts = { 'columns': ['ticker', 'date', 'adj_close' , 'volume'] },
		date = { 'gte': '2015-12-31', 'lte': '2016-12-31' }, 
		paginate=True)
	data = data.set_index('ticker')
	print(type(data))
	date_col = data.ix[:,0]
	date_json = date_col.to_json(orient='records')
	close_col = data.ix[:,1]
	volume = data.ix[:,2]
	print(date_col)
	close_json = close_col.to_json(orient='records')
	print(date_json)
	print(close_json)


	data = quandl.get_table('MER/F1', reportdate='2013-03-31', compnumber='372',paginate=True)