예제 #1
0
 def __init__(self,
              throttler: Optional[AsyncThrottler] = None,
              trading_pairs: List[str] = None,
              api_factory: Optional[WebAssistantsFactory] = None):
     super().__init__(trading_pairs)
     self._throttler = throttler or self._get_throttler_instance()
     self._api_factory = api_factory or build_api_factory()
     self._rest_assistant = None
     self._snapshot_msg: Dict[str, any] = {}
 def __init__(self,
              bitmart_auth: BitmartAuth,
              throttler: Optional[AsyncThrottler] = None,
              trading_pairs: Optional[List[str]] = None,
              api_factory: Optional[WebAssistantsFactory] = None):
     super().__init__()
     self._api_factory = api_factory or bitmart_utils.build_api_factory()
     self._rest_assistant = None
     self._ws_assistant = None
     self._bitmart_auth: BitmartAuth = bitmart_auth
     self._trading_pairs = trading_pairs or []
     self._current_listen_key = None
     self._listen_for_user_stream_task = None
     self._throttler = throttler or self._get_throttler_instance()
예제 #3
0
 def __init__(
     self,
     bitmart_api_key: str,
     bitmart_secret_key: str,
     bitmart_memo: str,
     trading_pairs: Optional[List[str]] = None,
     trading_required: bool = True,
 ):
     """
     :param bitmart_api_key: The API key to connect to private BitMart APIs.
     :param bitmart_secret_key: The API secret.
     :param trading_pairs: The market trading pairs which to track order book data.
     :param trading_required: Whether actual trading is needed.
     """
     super().__init__()
     self._api_factory = bitmart_utils.build_api_factory()
     self._rest_assistant = None
     self._trading_required = trading_required
     self._trading_pairs = trading_pairs
     self._bitmart_auth = BitmartAuth(api_key=bitmart_api_key,
                                      secret_key=bitmart_secret_key,
                                      memo=bitmart_memo)
     self._throttler = AsyncThrottler(CONSTANTS.RATE_LIMITS)
     self._order_book_tracker = BitmartOrderBookTracker(
         throttler=self._throttler, trading_pairs=trading_pairs)
     self._user_stream_tracker = BitmartUserStreamTracker(
         throttler=self._throttler,
         bitmart_auth=self._bitmart_auth,
         trading_pairs=trading_pairs)
     self._ev_loop = asyncio.get_event_loop()
     self._shared_client = None
     self._poll_notifier = asyncio.Event()
     self._last_timestamp = 0
     self._in_flight_orders = {
     }  # Dict[client_order_id:str, BitmartInFlightOrder]
     self._order_not_found_records = {
     }  # Dict[client_order_id:str, count:int]
     self._trading_rules = {}  # Dict[trading_pair:str, TradingRule]
     self._status_polling_task = None
     self._user_stream_event_listener_task = None
     self._trading_rules_polling_task = None
     self._last_poll_timestamp = 0
     self._real_time_balance_update = False