Пример #1
0
def stock(message_data, bot):
    result = urlopen('http://www.google.com/ig/api?stock=' + message_data["parsed"])
    root = ElementTree.fromstring(result.read())
    finance = root.find('finance')
    company = finance.find('company').get('data')
    currency = finance.find('currency').get('data')
    last = finance.find('last').get('data')
    change = finance.find('change').get('data')
    perc_change = finance.find('perc_change').get('data')
    trade_timestamp = finance.find('trade_timestamp').get('data')
    string = company + ' - '
    string += last + ' '
    string += currency + ' '
    change_string = change + ' (' + perc_change + ')'
    if change:
      if change[0] == '-':
          string += irc.color(change_string, 'brown')
      else:
          string += irc.color(change_string, 'green')
      string += ' as of '
      string += trade_timestamp
    return string
Пример #2
0
def btc_price(message_data, bot):
    tick = get_btc_price()
    return "Current price: $" + irc.color(str(tick['last']), 'orange') + " - High: $" + irc.color(str(tick['high']), 'orange') + " - Low: $" + irc.color(str(tick['low']), 'orange') + " - Volume: " + str(tick['volume']) + "BTC"