Ejemplo n.º 1
0
 def fetch_ticker_ws(self):
     trade = self.__safe_api_recent_trades_ws()[-1]
     ticker = Dotdict(self.ws.get_ticker())
     ticker.datetime = pd.to_datetime(trade['timestamp'])
     self.logger.info(
         "TICK: bid {bid} ask {ask} last {last}".format(**ticker))
     self.logger.info(
         "TRD: price {price} size {size} side {side} tick {tickDirection} ".
         format(**(trade['info'])))
     return ticker, trade
Ejemplo n.º 2
0
 def fetch_ticker(self, symbol=None, timeframe=None):
     symbol = symbol or self.settings.symbol
     timeframe = timeframe or self.settings.timeframe
     book = self.exchange.fetch_order_book(symbol, limit=10)
     trade = self.__safe_api_recent_trades(symbol,
                                           limit=1,
                                           params={"reverse": True})
     ticker = Dotdict()
     ticker.bid, ticker.bidsize = book['bids'][0]
     ticker.ask, ticker.asksize = book['asks'][0]
     ticker.bids = book['bids']
     ticker.asks = book['asks']
     ticker.last = trade[0]['price']
     ticker.datetime = pd.to_datetime(trade[0]['datetime'])
     self.logger.info(
         "TICK: bid {bid} ask {ask} last {last}".format(**ticker))
     self.logger.info(
         "TRD: price {price} size {size} side {side} tick {tickDirection} ".
         format(**(trade[0]['info'])))
     return ticker, trade