def connect(self) -> List[Tuple[AsyncConnection, Callable[[None], None], Callable[[str, float], None]]]: addrs = [] for chan in self.channels if self.channels else self.subscription: for pair in self.symbols if not self.subscription else self.subscription[chan]: if chan == MARKET_INFO: addrs.append(f"{self.address}coins/{pair}?localization=false&tickers=false&market_data=true&community_data=true&developer_data=false&sparkline=false") return [(HTTPPoll(addrs, self.id, delay=self.sleep_time * 2, sleep=self.sleep_time), self.subscribe, self.message_handler)]
def connect(self) -> List[Tuple[AsyncConnection, Callable[[None], None], Callable[[str, float], None]]]: ret = [] if self.address: ret = super().connect() for chan in set(self.channels or self.subscription): if chan == 'open_interest': addrs = [f"{self.rest_endpoint}/openInterest?symbol={pair}" for pair in set(self.symbols or self.subscription[chan])] ret.append((HTTPPoll(addrs, self.id, delay=60.0, sleep=1.0), self.subscribe, self.message_handler)) return ret
def _connect_rest(self): ret = [] for chan in set(self.subscription): if chan == 'open_interest': addrs = [ self.rest_endpoints[0].route( 'open_interest', sandbox=self.sandbox).format(pair) for pair in self.subscription[chan] ] ret.append((HTTPPoll(addrs, self.id, delay=60.0, sleep=self.open_interest_interval, proxy=self.http_proxy), self.subscribe, self.message_handler, self.authenticate)) return ret