Beispiel #1
0
def regular_download(start=None):
  """
  Download last month of data for all symbols, to update the database regularly
  """
  symbols = stock_helper.load_symbol_dic()
  
  for item in symbols:
    if start == None:
      stk = stock(item)
    else:
      stk = stock(item,start)
    try:
      stk.get_historical()
      update_summary_table(stk._symbol)
      update_data(stk)
      print 'updated %s' %item
    except:
      continue
  return
Beispiel #2
0
def full_download(start):
  """
  Download all the data from yahoo.finance from start to today
  (takes several days)
  """
  symbols = stock_helper.load_symbol_dic()

  con = sqlite3.connect('/home/gilles/projects/trading/quant_trading/database/market.db')
  cur = con.cursor()
  cur.execute('SELECT name FROM sqlite_master WHERE type="table"')
  tables = cur.fetchall()

  for key in symbols.keys():
    if '^' in key or '/' in key:
      del symbols[key]
      continue
#    if (key,) in tables:
#      cur.execute('SELECT COUNT(*) FROM %s' %key)
#      entries = cur.fetchall()
#      pdb.set_trace()
#      if entries[0][0] > 0:
#        del symbols[key]
  print len(symbols)

#  sys.exit()
  for item in symbols:
    stk = stock(item,start)
    try:
      stk.get_historical()
    except:
      continue

    try:
      update_summary_table(stk._symbol)
      update_data(stk)
    except:
      continue
    print '%s completed' %stk._symbol
  return