Ejemplo n.º 1
0
async def stock(*symbol: str):
    """Get a stock quote. Only works for stocks and ETFs"""
    if len(symbol) == 0:
        await bot.say(stocks.get_stocks())
        return
    out = stocks.get_quote(symbol[0])
    await bot.say(out)
Ejemplo n.º 2
0
def main():

    # Get today's weather
    zipcodes = importZips()  # For city/state lookup
    weather = getWeather(27607, zipcodes)
    print weather

    #  Get headlines
    headlines = getHeadlines()
    for headline in headlines:
        print headline + "\n"

    # Get a few stock quotes:
    for symbol in ("GOOG", "MSFT", "AAPL", "RHT"):
        print "{0}: {1}".format(symbol, stocks.get_quote(symbol))
Ejemplo n.º 3
0
def add(ticker):
  print('add XF')
  try:
    stock = Stock()
    stock['name'] = ticker
    stock['symbol'] = ticker
    try:
      stock['last_price'] = float(stocks.get_quote(ticker))
    except:
      print("lookup failed for %s" % ticker)
    print('presave')
    try:
      stock.save()
    except:
      print('stock failed to save')
    print("Created %s Successfully" % stock['name'])
    return render_template('add.html', ticker=ticker)
  except:
    return render_template('uhoh.html')
Ejemplo n.º 4
0
def update(logger):
    db = get_db()
    user = db.user
    stocklist = Stock.objects()

    for stock in stocklist:
        price = stocks.get_quote(stock.symbol)
        logger.info("Got latest price for {0}:{1}".format(
            stock.symbol,
            price
            )
        )
        try:
            stock.last_price = price
            stock.update(**{"set__last_price":price})
            logger.info("Updated data for {0}:{1}\n".format(
                stock['name'],
                stock['last_price']
                )
            )
        except Exception as e:
            logger.error("Error upating stock {}\n".format(stock['name']))
            logger.error(e.message)