logic.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:btcwidget 作者: rafalh 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号