def loadHistoricalPricesFromYahoo(self, secId, fr, to, marketId):
     '''
     Downloads prices from yahoo for one secId over a time period
     '''
     quotes = ystockquote.get_historical_prices(secId, fr.str_yyyymmdd(), 
                                                to.str_yyyymmdd())
     #print quotes
     if "Not Found" in str(quotes[1][0]):
         raise ErrorHandling.MarketDataMissing('%s with pricing date %s' % (secId, fr))
     for quote in quotes:
         #print quote
         if quote[0] == 'Date':
             continue
         year = int(quote[0][0:4])
         month = int(quote[0][5:7])
         day = int(quote[0][8:10])
         mid = float(quote[4])
         equities = Equity.objects.filter(ticker=secId)
         stockPrice = StockPrice()
         stockPrice.pricingDate = Date.Date(day,month,year)
         stockPrice.mid = mid
         stockPrice.equity = equities[0]
         stockPrice.marketId = marketId
         #print 'Saving %s ' % (stockPrice)
         stockPrice.save()
 def priceFromYahoo(self, secId, date):
     """
     Downloads prices from yahoo for one secId over a time period
     """
     #        print 'pre yahoo call for %s' % secId
     quotes = ystockquote.get_historical_prices(secId, date.str_yyyymmdd(), date.str_yyyymmdd())
     #        print 'post yahoo call'
     # print quotes
     if len(quotes) <> 2:
         print "bad quote for %s on %s" % (secId, str(date))
         return -1
         raise ErrorHandling.OtherException("quotes vector has 0 or more than 1 elements")
     if str(quotes[1][0]).find("Not Found") <> -1:
         raise ErrorHandling.MarketDataMissing("%s with pricing date %s" % (secId, date))
     for quote in quotes:
         # print quote
         if quote[0] == "Date":
             continue
         mid = float(quote[4])
     print "quote for %s on %s is %s" % (secId, str(date), str(mid))
     return mid