def btc(self): mt_usd = Mtgox(currency="USD") # mt_cny = Mtgox(currency='CNY') btce = BTCE() btcc = BTCChina() fxbtc = Fxbtc() cn42btc = CN42BTC() list_instance = [mt_usd, btce, btcc, fxbtc, cn42btc] list_thread = [] for instance in list_instance: t = FetcherThread(instance) list_thread.append(t) t.daemon = True t.start() # wait for all thread finish for t in list_thread: t.join() for instance in list_instance: if instance.error: instance = None usd_cny_currency = get_usd_cny_currency() content = u"""比特币实时行情汇总 ---------------- Mtgox价格:$%.2f,合¥%.2f MtGox日交量:%s BTC-E价格:$%.2f,合¥%.2f BTC-E日交量:%.4f BTC BTCChina价格:¥%.2f BTCChina日交量:%.4f BTC FXBTC价格:¥%.2f FXBTC日交量:%.4f BTC 42BTC价格:¥%.2f 42BTC日交量:%.4f BTC """ % ( 0 if mt_usd is None else mt_usd.last_all, mt_usd.last_all * usd_cny_currency, 0 if mt_usd is None else mt_usd.volume, 0 if btce is None else btce.last_all, btce.last_all * usd_cny_currency, 0 if btce is None else btce.volume, 0 if btcc is None else btcc.last_all, 0 if btcc is None else btcc.volume, 0 if fxbtc is None else fxbtc.last_all, 0 if fxbtc is None else fxbtc.volume, 0 if cn42btc is None else cn42btc.last_all, 0 if cn42btc is None else cn42btc.volume, ) return self.response_txt(content)
def btc(self): mt_usd = Mtgox(currency='USD') #mt_cny = Mtgox(currency='CNY') btce = BTCE() btcc = BTCChina() fxbtc = Fxbtc() cn42btc = CN42BTC() list_instance = [mt_usd, btce, btcc, fxbtc, cn42btc] list_thread = [] for instance in list_instance: t = FetcherThread(instance) list_thread.append(t) t.daemon = True t.start() # wait for all thread finish for t in list_thread: t.join() for instance in list_instance: if instance.error: instance = None usd_cny_currency = get_usd_cny_currency() content = u"""比特币实时行情汇总 ---------------- Mtgox价格:$%.2f,合¥%.2f MtGox日交量:%s BTC-E价格:$%.2f,合¥%.2f BTC-E日交量:%.4f BTC BTCChina价格:¥%.2f BTCChina日交量:%.4f BTC FXBTC价格:¥%.2f FXBTC日交量:%.4f BTC 42BTC价格:¥%.2f 42BTC日交量:%.4f BTC """ %\ (0 if mt_usd is None else mt_usd.last_all, mt_usd.last_all * usd_cny_currency, 0 if mt_usd is None else mt_usd.volume, 0 if btce is None else btce.last_all, btce.last_all * usd_cny_currency, 0 if btce is None else btce.volume, 0 if btcc is None else btcc.last_all, 0 if btcc is None else btcc.volume, 0 if fxbtc is None else fxbtc.last_all, 0 if fxbtc is None else fxbtc.volume, 0 if cn42btc is None else cn42btc.last_all, 0 if cn42btc is None else cn42btc.volume) return self.response_txt(content)
def ltc(self): btce_ltcusd = BTCE(coin="ltc_usd") btce_ltcbtc = BTCE(coin="ltc_btc") fx_ltccny = Fxbtc(coin="ltc_cny") fx_ltcbtc = Fxbtc(coin="ltc_btc") list_instance = [btce_ltcusd, btce_ltcbtc, fx_ltccny, fx_ltcbtc] list_thread = [] for instance in list_instance: t = FetcherThread(instance) list_thread.append(t) t.daemon = True t.start() # wait for all thread finish for t in list_thread: t.join() for instance in list_instance: if instance.error: instance = None usd_cny_currency = get_usd_cny_currency() content = u"""利特币实时行情汇总 ----------------- BTC-E价格1:$%.2f,合¥%.2f BTC-E价格2:%.4f BTC BTC-E日交量:%.2f LTC FXBTC价格1:¥%.2f FXBTC价格2:%.4f BTC FXBTC日交量:%.2f LTC""" % ( 0 if btce_ltcusd is None else btce_ltcusd.last_all, btce_ltcusd.last_all * usd_cny_currency, 0 if btce_ltcbtc is None else btce_ltcbtc.last_all, 0 if (btce_ltcusd and btce_ltcbtc) is None else btce_ltcusd.volume + btce_ltcbtc.volume, 0 if fx_ltccny is None else fx_ltccny.last_all, 0 if fx_ltcbtc is None else btce_ltcbtc.last_all, 0 if (fx_ltccny and fx_ltcbtc) is None else fx_ltccny.volume + fx_ltcbtc.volume, ) return self.response_txt(content)
def ltc(self): btce_ltcusd = BTCE(coin='ltc_usd') btce_ltcbtc = BTCE(coin='ltc_btc') fx_ltccny = Fxbtc(coin='ltc_cny') fx_ltcbtc = Fxbtc(coin='ltc_btc') list_instance = [btce_ltcusd, btce_ltcbtc, fx_ltccny, fx_ltcbtc] list_thread = [] for instance in list_instance: t = FetcherThread(instance) list_thread.append(t) t.daemon = True t.start() # wait for all thread finish for t in list_thread: t.join() for instance in list_instance: if instance.error: instance = None usd_cny_currency = get_usd_cny_currency() content = u"""利特币实时行情汇总 ----------------- BTC-E价格1:$%.2f,合¥%.2f BTC-E价格2:%.4f BTC BTC-E日交量:%.2f LTC FXBTC价格1:¥%.2f FXBTC价格2:%.4f BTC FXBTC日交量:%.2f LTC""" %\ (0 if btce_ltcusd is None else btce_ltcusd.last_all, btce_ltcusd.last_all * usd_cny_currency, 0 if btce_ltcbtc is None else btce_ltcbtc.last_all, 0 if (btce_ltcusd and btce_ltcbtc) is None else btce_ltcusd.volume + btce_ltcbtc.volume, 0 if fx_ltccny is None else fx_ltccny.last_all, 0 if fx_ltcbtc is None else btce_ltcbtc.last_all, 0 if (fx_ltccny and fx_ltcbtc) is None else fx_ltccny.volume + fx_ltcbtc.volume) return self.response_txt(content)
def btc(self): mt = Mtgox() btce = BTCE() btcc = BTCChina() fxbtc = Fxbtc() list_instance = [mt, btce, btcc, fxbtc] list_thread = [] for instance in list_instance: t = FetcherThread(instance) list_thread.append(t) t.daemon = True t.start() # wait for all thread finish for t in list_thread: t.join() for instance in list_instance: if instance.error: return self.response_txt(instance.error) content = u"""比特币实时行情汇总 ---------------- MtGox价格:%s MtGox日交量:%s BTC-E价格:$%.2f BTC-E日交量:%.4f BTC BTCChina价格:¥%s BTCChina日交量:%.4f BTC FXBTC价格:¥%.2f FXBTC日交量:%.4f BTC""" %\ (mt.last_all, mt.volume, btce.last_all, btce.volume, btcc.last_all, btcc.volume, fxbtc.last_all, fxbtc.volume) return self.response_txt(content)
def ltc(self): btce_ltcusd = BTCE(coin='ltc_usd') btce_ltcbtc = BTCE(coin='ltc_btc') fx_ltccny = Fxbtc(coin='ltc_cny') fx_ltcbtc = Fxbtc(coin='ltc_btc') list_instance = [btce_ltcusd, btce_ltcbtc, fx_ltccny, fx_ltcbtc] list_thread = [] for instance in list_instance: t = FetcherThread(instance) list_thread.append(t) t.daemon = True t.start() # wait for all thread finish for t in list_thread: t.join() for instance in list_instance: if instance.error: return self.response_txt(instance.error) content = u"""利特币实时行情汇总 ----------------- BTC-E价格1:$%.2f BTC-E价格2:%.4f BTC BTC-E日交量:%.2f LTC FXBTC价格1:¥%.2f FXBTC价格2:%.4f BTC FXBTC日交量:%.2f LTC""" %\ (btce_ltcusd.last_all, btce_ltcbtc.last_all, btce_ltcbtc.volume + btce_ltcbtc.volume, fx_ltccny.last_all, fx_ltcbtc.last_all, fx_ltccny.volume + fx_ltcbtc.volume) return self.response_txt(content)