def data_extraction(interval, length): x = [] y = [] eur_sek = Currency('EURSEK') for i in range (length): eur_sek.refresh() timestamp = datetime.datetime.now() rate = eur_sek.get_bid() print('Time: ',timestamp) print ('EUR-SEK: ',rate) print ('') x.append(timestamp) y.append(rate) time.sleep(interval) data = pd.DataFrame(x, columns=['Date']) data['Rate'] = y return data
class TestCurrency(TestCase): def setUp(self): self.eur_pln = Currency('EURPLN') def test_eurpln(self): # assert these are float-like float(self.eur_pln.get_bid()) float(self.eur_pln.get_ask()) float(self.eur_pln.get_rate()) def test_eurpln_date(self): eur_pln = Currency('EURPLN') try: datetime.datetime.strptime(eur_pln.get_trade_datetime(), "%Y-%m-%d %H:%M:%S %Z%z") except ValueError as v: if "bad directive" in str(v): raise SkipTest("datetime format checking requires the %z directive.") else: raise
class TestCurrency(TestCase): def setUp(self): self.eur_pln = Currency('EURPLN') def test_eurpln(self): # assert these are float-like float(self.eur_pln.get_bid()) float(self.eur_pln.get_ask()) float(self.eur_pln.get_rate()) def test_eurpln_date(self): eur_pln = Currency('EURPLN') try: datetime.datetime.strptime(eur_pln.get_trade_datetime(), "%Y-%m-%d %H:%M:%S %Z%z") except ValueError as v: if "bad directive" in str(v): raise SkipTest( "datetime format checking requires the %z directive.") else: raise
from yahoo_finance import Currency eur_pln = Currency('EURPLN') print (eur_pln.get_bid())
def _get_euro_exchange_rate(self): eur_brl = Currency('EURBRL') return eur_brl.get_bid()
def _get_dollar_exchange_rate(self): usd_brl = Currency('USDBRL') return usd_brl.get_bid()
# get_year_high() # get_year_low() # get_50day_moving_avg() # get_200day_moving_avg() # get_price_earnings_ratio() # get_price_earnings_growth_ratio() # get_price_sales() # get_price_book() # get_short_ratio() # get_trade_datetime() # get_historical(start_date, end_date) # get_info() # refresh() from yahoo_finance import Currency eur_pln = Currency('EURPLN') print eur_pln.get_bid() print eur_pln.get_ask() print eur_pln.get_rate() print eur_pln.get_trade_datetime() eur_pln.refresh() print eur_pln.get_rate() print eur_pln.get_trade_datetime() # get_bid() # get_ask() # get_rate() # get_trade_datetime() # refresh()
data = data = quandl.get(tickers,start_date=start, end_date=end) data.tail(1).T s=data[["CHRIS/SHFE_AU1 - Close","YAHOO/INDEX_HUI - Adjusted Close","CHRIS/CME_GC1 - Last"]] s.apply(lambda x: (x - np.mean(x)) / (np.max(x) - np.min(x)), axis=0).ix['2014':].plot(color=tableau20) #============================================================================== # #============================================================================== import pandas_datareader.data as web df = web.DataReader("EURUSD=x", 'yahoo', start, end) from yahoo_finance import Currency fx = Currency('EURUSD') fx.get_bid() fx.get_ask() fx.get_rate() fx.get_trade_datetime() fx.get_historical('2014-04-25', '2014-04-29') fx.data_set
from yahoo_finance import Share yahoo = Share('YHOO') yahoo.get_open() yahoo.get_price() yahoo.get_trade_datetime() yahoo.refresh() #Refresh data from market yahoo.get_historical('2014-04-25', '2014-04-29') from yahoo_finance import Currency eur_pln = Currency('EURPLN') eur_pln.get_bid() eur_pln.get_ask() eur_pln.get_rate() eur_pln.get_trade_datetime() eur_pln.refresh() #reading google finance data import pandas_datareader.data as web import datetime start = datetime.datetime(2010, 1, 1) end = datetime.datetime(2013, 1, 27) f = web.DataReader("F", 'google', start, end) f.ix['2010-01-04'] #reading yahoo finance data
from yahoo_finance import Currency eur_sek = Currency('EURSEK') eur_sek.refresh() print(eur_sek.get_bid())
def getchange(fromto='USDCNY'): change = Currency(fromto) bid = change.get_bid() ask = change.get_ask() rate = change.get_rate() return rate