def _fetch_market_ticker(self, market_id):
market_config, _ = config.get_market_by_id(market_id)
exchange, market = market_config['exchange'], market_config['market']
provider = btcwidget.exchanges.factory.get(exchange)
try:
price = provider.ticker(market)
except Exception as e:
print('Failed to update ticker data for {}: {}'.format(market_id, e), file=sys.stderr)
price = None
if price:
price_str = btcwidget.currency.service.format_price(price, market[3:])
print('{} {} ticker: {}'.format(provider.get_name(), market, price_str))
GObject.idle_add(self._main_win.set_current_price, market_id, price_str)
self._check_alarms(exchange, market, price)
self._last_ticer[market_id] = {
'time': time.time(),
'open': price,
'close': price,
}
if market_id in self._graph_data_dict:
graph_data = self._graph_data_dict[market_id]
graph_data.append(self._last_ticer[market_id])
self._update_market_graph(market_id)
self._ticker_threads.pop(market_id, None)
评论列表
文章目录