get 10 values from yahoo, write to 'in' table
In [6]:
import sqlite3
import datetime
from yahoo_finance import Currency
In [7]:
import time
for i in range(100):
print '-----------'
#print i
#Currency('GBPUSD').refresh()
bid = Currency('GBPUSD').get_bid()
rate = Currency('GBPUSD').get_rate()
ask = Currency('GBPUSD').get_ask()
#bid = ask = rate = 1.57
#
trade_datetime = Currency('GBPUSD').get_trade_datetime ()
print bid
#print rate
#print ask
print trade_datetime
in_db = 'in.db'
conn = sqlite3.connect(in_db)
c = conn.cursor()
now = datetime.datetime.now()
iPrice = [ (now, 'wait' , trade_datetime, 'GBPUSD', bid, rate, ask ),]
c.executemany('INSERT INTO iPrice (iDate,status,date,symbol,bid,rate,ask) VALUES (?,?,?,?,?,?,?)', iPrice)
# no audit or market or type
conn.commit()
conn.close()
time.sleep(6)
In [8]:
print 'x'
In [ ]:
In [ ]:
In [ ]:
In [ ]: