How to use the quandl.get 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 vrishank97 / AlgoTrading / algotrading / backtest / eval_ema.py View on Github external
def test(year, stock, window=10, up=0.05, down=0.05, get_plots=True, verbose=True):
	quandl.ApiConfig.api_key = "FDEDsMbK1E2t_PMf7X3M"
	df = quandl.get('NSE/ZEEL', start_date='2017-01-01', end_date='2017-12-31')
	prices = df["Close"]
	dates = df["Date"]

	agent = EMA_Agent(window, up, down)

	test = Backtest(agent, 10000)

	output = test.run(prices)

	# class Evaluation takes for initialization - prices, output, name of algorithm, name of security

	evaluator = Evaluation(prices, dates, output, "EMA", stock)
	return evaluator.complete_evaluation(get_plots, verbose)
github Prakash2403 / Chase / utils / __init__.py View on Github external
def get_data_from_quandl(stocks, save=True):
    """
    Returned dataframe is indexed by Date. So, no need to externally parse dates and change index column.
    :param stocks: Stocks to be downloaded
    :param save: If True, then save the downloaded stock.
    :return: A list of pandas dataframe containing the details of requested stocks.
    """
    quandl.ApiConfig.api_key = QUANDL_KEY
    df_list = []
    for stock in stocks:
        print("DOWNLOADING {0} DATA".format(stock))
        df = quandl.get(stock, start_date=RETRIEVAL_START_DATE, end_date=RETRIEVAL_END_DATE)
        df = df[REL_DATA_COLUMNS]
        df_list.append(df)
        if save:
            df.to_csv('{0}/{1}.csv'.format(DATA_DIR, stock.split('/')[-1]))
    return df_list
github tg12 / FAIG-Stocks / FAIG_Stocks_FTSE100.py View on Github external
if math.isnan(tmp_var_1):
                tmp_var_1 = 0
            if math.isnan(tmp_var_2):
                tmp_var_2 = 0
            tmp_list.append(float(tmp_var_1))
            tmp_list.append(float(tmp_var_2))
            main_list.append(tmp_list)

        for i in range(len(high_prices)):
            if math.isnan(high_prices[i]):
                high_prices[i] = 0

        main_list = np.asarray(main_list)
        high_prices = np.asarray(high_prices)

        PREDICT_FOR = quandl.get(QUAND_REF, collapse="daily")
        PREDICT_FOR_price_list = data['Low'].values.tolist()
        PREDICT_FOR_volume_list = data['Volume'].values.tolist()
        PREDICT_x = PREDICT_FOR_price_list[-1]
        PREDICT_y = PREDICT_FOR_volume_list[-1]

        print ("PREDICT_x : " + str(PREDICT_x))
        print ("PREDICT_y : " + str(PREDICT_y))

        # Initialize the model then train it on the data
        genius_regression_model = LinearRegression()
        genius_regression_model.fit(main_list,high_prices)
        # Predict the corresponding value of Y for X
        pred_ict = [PREDICT_x,PREDICT_y]
        pred_ict = np.asarray(pred_ict) #To Numpy Array, hacky but good!! 
        pred_ict = pred_ict.reshape(1, -1)
        price_prediction = genius_regression_model.predict(pred_ict)
github ademidun / austrian-quant / amplify / regression.py View on Github external
import quandl, math
import numpy as np
import pandas as pd
from sklearn import preprocessing, cross_validation, svm
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
from matplotlib import style
import datetime
import pickle

style.use('ggplot')

df = quandl.get("WIKI/GOOGL")
df = df[['Adj. Open',  'Adj. High',  'Adj. Low',  'Adj. Close', 'Adj. Volume']]
df['HL_PCT'] = (df['Adj. High'] - df['Adj. Low']) / df['Adj. Close'] * 100.0
df['PCT_change'] = (df['Adj. Close'] - df['Adj. Open']) / df['Adj. Open'] * 100.0

df = df[['Adj. Close', 'HL_PCT', 'PCT_change', 'Adj. Volume']]
forecast_col = 'Adj. Close'
df.fillna(value=-99999, inplace=True)
forecast_out = int(math.ceil(0.1 * len(df)))

df['label'] = df[forecast_col].shift(-forecast_out)

X = np.array(df.drop(['label'], 1))
X = preprocessing.scale(X)
X_lately = X[-forecast_out:]
X = X[:-forecast_out]
github nb5hd / markov_stock_analysis / Old_versions / markov_stock_forecasting_model_v2-5.py View on Github external
def get_data(security):
    """
    This function obtains data under certain parameters from Quandl and returns the following information as a Pandas
    DataFrame: date, adjusted closing, and percentage change in adjusted closing from the last week.

    :param security:  Holds information about the requested security
    :return: A Pandas DataFrame with columns: Date, Adjusted Close, and Percentage Change.
    """
    quandl.ApiConfig.api_key = "7NU4-sXfczxA9fsf_C8E"
    name = security.get_name()
    start = security.get_start()
    end = security.get_end()
    period = security.get_period()
    raw_df = quandl.get("YAHOO/" + name, start_date=start, end_date=end, collapse=period)
    adjusted_df = raw_df.ix[:, ['Adjusted Close']]
    adjusted_df["Percentage Change"] = adjusted_df['Adjusted Close'].pct_change() * 100
    return adjusted_df
github doncat99 / StockRecommendSystem / Source / FetchData / Fetch_Data_Stock_HK_Daily.py View on Github external
def getSingleStock(symbol, from_date, till_date):    
    repeat_times = 3
    message = ""
    for _ in range(repeat_times): 
        try:
            data = quandl.get("HKEX/"+symbol, start_date=from_date, end_date=till_date)
            data.index = pd.to_datetime(data.index)
            return data, ""
        except Exception as e:
            message = ", fetch exception: " + str(e)
            continue   
        else:
            time.sleep(0.1)
    return '', message
github WillKoehrsen / Data-Analysis / sentdex_data_analysis / pandas_percentChange_correlation.py View on Github external
def HPI_Benchmark():
	df = quandl.get('FMAC/HPI_USA' , authtoken=api_key)
	df['United States'] = (df['Value'] - df['Value'][0]) / df['Value'][0] * 100.0
	
	pickle_out = open('us_pct.pickle', 'wb')
	pickle.dump(df, pickle_out)
	pickle_out.close()
github cajohnst / Optimized_FX_Portfolio / Pull_Data.py View on Github external
def get_currency_data(currency_list, currency_quandl_list, num_days_regression, end_date , api_key):
	# Calculate dates to begin and end
	start_date = end_date  - timedelta(num_days_regression)

	# Initialize data table
	data_table = None
	# Run through currencies, first assignment is initialized
	# Anything past first currency is joined into table 
	for currency in currency_quandl_list:
		current_column = qdl.get(currency, start_date= start_date, end_date = end_date , authtoken= api_key)
		current_column.columns = [currency]
		if data_table is None:
			data_table = current_column
		else:
			data_table = data_table.join(current_column, how= 'left', rsuffix= '')
	data_table.columns = currency_list 
	if 'USD/MXN' in currency_list:
		data_table['USD/MXN'] = 1 / data_table['USD/MXN']
	return data_table
github QuantLet / DEDA_Class_2017 / DEDA_Projects / DEDA_WebScrapingInCryptocurrencies / Cryptocurriencie_Price_Data.py View on Github external
def crypto_data(chart_exchange):
    # Download and cache Quandl dataseries
    path = '{}.csv'.format(chart_exchange).replace('/', '-')
    df = quandl.get(chart_exchange, returns='pandas')
    df.to_csv(path)
    return df
github WillKoehrsen / Data-Analysis / sentdex_data_analysis / pandas_pickling_sentdex.py View on Github external
import quandl
import pandas as pd

# Not necessary, I just do this so I do not show my API key.
api_key = 'rFsSehe51RLzREtYhLfo'
fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')

main_df = pd.DataFrame()

for abbv in fiddy_states[0][0][1:]:
    query = "FMAC/HPI_"+str(abbv)
    df = quandl.get(query, authtoken=api_key)

    if main_df.empty:
        main_df = df
    else:
        main_df = main_df.join(df)