• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python quandl.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中quandl.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: load_eur

def load_eur():
    """ Return cash rate for EUR and DEM prior to the introduction of EUR """
    bank_rate = quandl.get(CashFile.GER_BANKRATE.value,
                           api_key=AdagioConfig.quandl_token)

    ww2_data = pd.DataFrame([4.0, 3.5, 5.0],
                            index=[datetime(1936, 6, 30),
                                   datetime(1940, 4, 9),
                                   datetime(1948, 6, 28)])
    ww2_month = pd.date_range('1936-06-01', '1948-06-01', freq='M')
    ww2_month = pd.DataFrame(index=ww2_month)
    ww2_data = pd.concat((ww2_data, ww2_month), axis=1).fillna(method="pad")

    parser = lambda d: date_shift(datetime.strptime(d, "%Y-%m"),
                                  "+BMonthEnd")
    filename = join(DATA_DIRECTORY, 'cash_rate', 'eur', 'BBK01.SU0112.csv')
    discount_rate = pd.read_csv(filename,
                                skiprows=[1, 2, 3, 4], index_col=0,
                                usecols=[0, 1], engine="python", skipfooter=95,
                                parse_dates=True, date_parser=parser)
    ib_rate = DataReader(CashFile.EUR_3M_IB_RATE.value, "fred", START_DATE)
    libor = quandl.get(CashFile.EUR_3M_EURIBOR.value,
                       api_key=AdagioConfig.quandl_token)

    data = (pd.concat((bank_rate[:"1936-06"].fillna(method="pad"),
                       ww2_data,
                       discount_rate[:"1959"].fillna(method="pad"),
                       to_monthend(ib_rate['1960':"1998"].fillna(method="pad")),
                       libor['1999':].fillna(method="pad")),
                      axis=1)
            .sum(axis=1).rename("cash_rate_eur"))
    return data
开发者ID:nekopuni,项目名称:adagio,代码行数:32,代码来源:cash.py


示例2: sample

def sample():
    df1 = quandl.get("FMAC/HPI_AL", authtoken=api_key)
    df2 = quandl.get("FMAC/HPI_AK", authtoken=api_key)

    df1.columns = ['HPI_AL']
    df2.columns = ['HPI_AK']

    print(df1.head())
    print(df2.head())

    joined = df1.join(df2)
    print(joined.head())
开发者ID:JackieWSC,项目名称:Onepiece,代码行数:12,代码来源:pandasLesson7.py


示例3: get_unemployment

def get_unemployment(api_key):
	df = quandl.get("ECPI/JOB_G", trim_start="1975-01-01", authtoken=api_key)
	df.columns = ['unemployment']
	df['unemployment'] = (df['unemployment']-df['unemployment'][0])/df['unemployment'][0]*100.0
	df = df.resample('D').mean()
	df = df.resample('M').mean()
	return df
开发者ID:BeRANDON,项目名称:workgithub,代码行数:7,代码来源:lecture.py


示例4: gdp_data

def gdp_data():
    df = quandl.get("BCB/4385", trim_start="1975-01-01")
    df["Value"] = (df["Value"]-df["Value"][0]) / df["Value"][0] * 100.0
    df=df.resample('M').mean()
    df.rename(columns={'Value':'GDP'}, inplace=True)
    df = df['GDP'] # DataFrame to Series
    return df
开发者ID:ShenXiaoJun,项目名称:Data-Analysis,代码行数:7,代码来源:pandas_additionalEconomic.py


示例5: mortgage_30yr

def mortgage_30yr():
	df = quandl.get('FMAC/MORTG', trim_start="1975-01-01")
	df['Value'] = (df['Value'] - df['Value'][0]) / df['Value'][0] * 100
	df = df.resample('M').mean()
	df.rename(columns={'Value': 'M30'}, inplace=True)
	df = df['M30']
	return df 
开发者ID:ShenXiaoJun,项目名称:Data-Analysis,代码行数:7,代码来源:pandas_additionalEconomic.py


示例6: HPI_Benchmark

def HPI_Benchmark():
    df = quandl.get("FMAC/HPI_USA", authtoken=api_key)
    df.columns = ['United States']
    df["United States"] = (df["United States"]-df["United States"][0]) / df["United States"][0] * 100.0
    pickle_out = open('HPI_bench.pickle','wb')
    pickle.dump(df, pickle_out)
    pickle_out.close() 
开发者ID:avganesh,项目名称:Python-Programming,代码行数:7,代码来源:Tut13.py


示例7: HPI_Benchmark

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()
开发者ID:ShenXiaoJun,项目名称:Data-Analysis,代码行数:7,代码来源:pandas_percentChange_correlation.py


示例8: load_quandl_newsentiment

def load_quandl_newsentiment(dataset, start, end):
    cache_file = 'NS1/ns1-cache.csv'
    quandl_auth = 'T2GAyK64nwsePiJWMq8y'
    #ns1 = pd.DataFrame()
    i=1
    for index, row in dataset.iterrows():
        #ns2[i] = ns1
        ns1 = []
        ns1 = pd.DataFrame()
        stock_cache_file = row['NSCode']+'-cache.csv'
        if not(os.path.exists(stock_cache_file)):
            print(row['NSCode'])
            print ('Downloading news for', row['NSCode'])
            allnews_data = quandl.get(row['NSCode'], authtoken=quandl_auth)
            ns1 = ns1.append(allnews_data)
            ns1.to_csv(stock_cache_file)
        if os.path.exists(stock_cache_file):
            with open(stock_cache_file, 'r') as csvfile:
                csvFileReader = csv.reader(csvfile)
                next(csvFileReader)
                print ('Loading news from cache ', row['NSCode'])
                for rows in csvFileReader:
                    date=int(time_to_num(rows[0]))
                    if date > start and date < end:
                #        print(start,date,end)
                        datens.append(date)
                        sentiment.append(rows[1])
                #print (datens, ' ',sentiment,"\n")
        #ns1.to_csv(cache_file)
    return
开发者ID:fvrljicak,项目名称:AISEBot,代码行数:30,代码来源:aisebot.py


示例9: store_quandl

def store_quandl(code):
    data = quandl.get(code)

    new_entry_c = 0

    print('Storing quandl data for: %s...' % (code), " ", end="")
    # index is the date
    for index, row in data.iterrows():
        date  = index
        value = row['Value']

        exists = db.session.query(db.base.classes.quandl).filter(db.base.classes.quandl.date == date).filter(db.base.classes.quandl.code == code).first()
        
        if exists:
            continue

        new_data = db.base.classes.quandl(p_time=datetime.now(),
                                          date=date,
                                          code=code,
                                          value=value)
   
        

        db.session.add(new_data)
        db.session.commit()
        new_entry_c += 1

    print('added: %s/%s entries' % (new_entry_c, len(data)))
开发者ID:Cightline,项目名称:oil_watch,代码行数:28,代码来源:get_data.py


示例10: load_from_quandl

 def load_from_quandl(self):
     """ Download data from quandl """
     logger.debug('Downloading data from Quandl')
     data = quandl.get(self[keys.quandl_ticker],
                       api_key=AdagioConfig.quandl_token)
     self.check_if_expired(data)
     return data
开发者ID:nekopuni,项目名称:adagio,代码行数:7,代码来源:contract.py


示例11: build_graph

def build_graph(ticker):
    # make a graph of closing prices from previous month

    # Create some data for our plot.
    data = quandl.get('WIKI/' + ticker)
    
    # graph last month's data
    enddate = date.today() - timedelta(1)
    startdate = enddate - relativedelta(months=1)
    wdata = data[startdate:enddate]

    x = wdata.index  # datatime formatted
    y = wdata['Close']  # closing prices

    # Create a heatmap from our data.
    plot = figure(title='Data from Quandle WIKI set',
              x_axis_label='date',
              x_axis_type='datetime',
              y_axis_label='price')

    plot.line(x, y, color='navy', alpha=0.5)

    script, div = components(plot)

    return script, div
开发者ID:keechul,项目名称:quandl-wiki-plot,代码行数:25,代码来源:app.py


示例12: scrapeDailyNews

def scrapeDailyNews():
	url = "http://finance.yahoo.com/q/hp?s=AAPL+Historical+Prices"

	content = urllib2.urlopen(url).read()
	soup = BeautifulSoup(content, "lxml")
	tbl = soup.find("table", {"class": "yfnc_datamodoutline1"}).findNext('table').find_all('tr')[1].find_all('td')
	
	newsDate = datetime.now()

	mydata = quandl.get("AOS/AAPL")

	row = mydata.iloc[-1:]
	avgSent = float(row['Article Sentiment'])
	impactScore = float(row['Impact Score'])

	news = News(
		date = newsDate,
		avgSent = avgSent,
		impactScore = impactScore)

	try:
		news.save()
		print("Saved news object ({})".format(news.objectId))
	except:
		print("News data has already been saved.")
开发者ID:kszela24,项目名称:options-daily,代码行数:25,代码来源:dailyScraper.py


示例13: scrapeDailyOptions

def scrapeDailyOptions():
	url = "http://finance.yahoo.com/q/hp?s=AAPL+Historical+Prices"

	content = urllib2.urlopen(url).read()
	soup = BeautifulSoup(content, "lxml")
	tbl = soup.find("table", {"class": "yfnc_datamodoutline1"}).findNext('table').find_all('tr')[1].find_all('td')
	
	optionDate = datetime.strptime(tbl[0].string, "%b %d, %Y")

	mydata = quandl.get("VOL/AAPL")

	row = mydata.iloc[-1:]
	ivmean10 = float(row['IvMean10'])
	ivmean20 = float(row['IvMean20'])
	ivmean30 = float(row['IvMean30'])
	ivmean60 = float(row['IvMean60'])


	option = Option(
		date = optionDate,
		ivMean10 = ivmean10,
		ivMean20 = ivmean10,
		ivMean30 = ivmean30,
		ivMean60 = ivmean60)

	try:
		option.save()
		print("Save option object ({})".format(option.objectId))
	except:
		print("Option data has already been saved.")
开发者ID:kszela24,项目名称:options-daily,代码行数:30,代码来源:dailyScraper.py


示例14: second_stock

def second_stock():	
	n = app_stock.vars['name']
	ss = "WIKI/" + n + ".4"
	mydata = quandl.get(ss, encoding='latin1', parse_dates=['Date'], dayfirst=True, index_col='Date', trim_start="2016-05-05", trim_end="2016-06-05", returns = "numpy", authtoken="ZemsPswo-xM16GFxuKP2")
	mydata = pd.DataFrame(mydata)
	#mydata['Date'] = mydata['Date'].astype('datetime64[ns]')
	x = mydata['Date']
	y = mydata['Close']
	p = figure(title="Stock close price", x_axis_label='Date', y_axis_label='close price', plot_height = 300, plot_width = 550)
	p.line(x, y, legend="Price in USD", line_width=3, color = "#2222aa")
	
	
	# Configure resources to include BokehJS inline in the document.
    # For more details see:
    #   http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh-embed
	js_resources = INLINE.render_js()
	css_resources = INLINE.render_css()

    # For more details see:
    #   http://bokeh.pydata.org/en/latest/docs/user_guide/embedding.html#components
	script, div = components(p, INLINE)
    
	html = flask.render_template(
		'stockgraph.html',
		ticker = app_stock.vars['name'],
		plot_script=script,
		plot_div=div,
		js_resources=js_resources,
		css_resources=css_resources,
	)
	return encode_utf8(html)
开发者ID:hhsieh,项目名称:Herokuapp,代码行数:31,代码来源:app.py


示例15: load_stock_datasets

def load_stock_datasets():
    data_file = "stocks.xlsx"
    if os.path.isfile(data_file):
        stocks = pd.read_excel(data_file)
    else:
        quandl.ApiConfig.api_key = 'a5JKbmNDb4k98huTPMcY'
        google = quandl.get('WIKI/GOOGL')
        google["Company"] = "Google"
        facebook = quandl.get('WIKI/FB')
        facebook["Company"] = "Facebook"
        apple = quandl.get('WIKI/AAPL')
        apple["Company"] = "Apple"
        stocks = pd.concat([apple, facebook, google])
        stocks = stocks.reset_index()
        stocks.to_excel(data_file, index=False)
    return stocks
开发者ID:magizbox,项目名称:ml_data_python,代码行数:16,代码来源:finance_dataset.py


示例16: get_quandl_df

def get_quandl_df(label, newlabel, percent_change=False, trim_start=None):
    df = quandl.get(label, authtoken=API_KEY, trim_start=trim_start)
    df.rename(columns={'Value': newlabel}, inplace=True)
    if percent_change:
        # percent change is (new - old) / old
        df[newlabel] = (df[newlabel] - df[newlabel][0]) / df[newlabel][0] * 100.0
    return df
开发者ID:smrkem,项目名称:intro-data-analysis-python-pandas,代码行数:7,代码来源:helpers.py


示例17: grab_initial_state_data

def grab_initial_state_data():
    states = state_list()
    main_df = pd.DataFrame()

    for abbv in states:
        query = "FMAC/HPI_"+str(abbv)
        print(query)
        
        df = quandl.get(query, authtoken=api_key)
        print(df.head())
        df.columns = [abbv]  ### This is the fix ###

        ## doing some manipulation on the DataFrame
        #df = df.pct_change()
        df[abbv] = (df[abbv] - df[abbv][0]) / df[abbv][0] *100
        
        if main_df.empty:
            main_df = df
        else:
            main_df = main_df.join(df)
            #eammain_df = main_df.join(df, lsuffix=abbv)  ### Could also do this ###

    print(main_df.head())
    
    pickle_out = open('fiddy_states3.pickle','wb')  ##write bytes
    pickle.dump(main_df, pickle_out)
    pickle_out.close()        
开发者ID:d80b2t,项目名称:python,代码行数:27,代码来源:PercentChange_Correlation_p8.py


示例18: hpi_benchmark

def hpi_benchmark():
        df= quandl.get("FMAC/HPI_USA",authtoken=api_key)
        df.columns =['usa']
        df['usa'] = (df['usa'] - df['usa'][0]) / df['usa'][0] *100
        print('usa data is ready to analze')
        print(df.head())
        return df
开发者ID:richarddeng88,项目名称:Python,代码行数:7,代码来源:4+pandas+basic+-+pickle,+correlation.py


示例19: api_request

def api_request(data_set):
    import quandl as q

    api_token = config.get("quandl", "api_key")
    data = q.get(data_set, authtoken=api_token).to_json(date_format="iso")
    # print(data)
    return data
开发者ID:skilbjo,项目名称:economics,代码行数:7,代码来源:pipeline.py


示例20: getEsFuturesStockPrice

def getEsFuturesStockPrice(symbol, start, end):
    """
    Adjusted close price from quandle.
    """
    import quandl
    mydata = quandl.get(symbol, start_date=start, end_date=end, authtoken="zYuLi6xBbvDYgsQJApiA")
    return mydata["Close"]
开发者ID:xkeecs,项目名称:udacityCapstone,代码行数:7,代码来源:Capstone_project.py



注:本文中的quandl.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python datastruct.PContract类代码示例发布时间:2022-05-26
下一篇:
Python utils.success函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap