Beispiel #1
0
    def __init__(
        self,
        trading_pairs: Optional[List[str]] = None,
        rest_api_url: str = "https://api.dydx.exchange/v1",
        websocket_url: str = "wss://api.dydx.exchange/v1/ws",
        dydx_auth: str = "",
        token_configuration: DydxAPITokenConfigurationDataSource = None,
    ):
        super().__init__(
            DydxAPIOrderBookDataSource(
                trading_pairs=trading_pairs,
                rest_api_url=rest_api_url,
                websocket_url=websocket_url,
                token_configuration=token_configuration), trading_pairs)

        self._order_books: Dict[str, DydxOrderBook] = {}
        self._saved_message_queues: Dict[
            str, Deque[DydxOrderBookMessage]] = defaultdict(
                lambda: deque(maxlen=1000))
        self._order_book_snapshot_stream: asyncio.Queue = asyncio.Queue()
        self._order_book_diff_stream: asyncio.Queue = asyncio.Queue()
        self._order_book_trade_stream: asyncio.Queue = asyncio.Queue()
        self._ev_loop: asyncio.BaseEventLoop = asyncio.get_event_loop()
        self._dydx_auth = DydxAuth(dydx_auth)
        self._token_configuration: DydxAPITokenConfigurationDataSource = token_configuration
        self._active_order_trackers: Dict[
            str, DydxActiveOrderTracker] = defaultdict(
                lambda: DydxActiveOrderTracker(self.token_configuration))
Beispiel #2
0
 def __init__(self, trading_pairs: List[str] = None, rest_api_url="", websocket_url="", token_configuration=None):
     super().__init__(trading_pairs)
     self.REST_URL = rest_api_url
     self.WS_URL = websocket_url
     self._get_tracking_pair_done_event: asyncio.Event = asyncio.Event()
     self.order_book_create_function = lambda: OrderBook()
     self._token_configuration: DydxAPITokenConfigurationDataSource = token_configuration
     self.token_configuration
     self._active_order_tracker: DydxActiveOrderTracker = DydxActiveOrderTracker(self.token_configuration)
Beispiel #3
0
 def active_order_tracker(self) -> DydxActiveOrderTracker:
     if not self._active_order_tracker:
         self._active_order_tracker = DydxActiveOrderTracker(
             self.token_configuration)
     return self._active_order_tracker