Beispiel #1
0
    def __init__(self, config: object, exchange_manager: object):
        super().__init__(config, exchange_manager)
        self.fix_signal_handler()
        self.fix_logger()
        self.client = cryptofeed.FeedHandler()
        commons_logging.set_logging_level(self.LOGGERS, logging.DEBUG)

        self.callback_by_feed = {
            cryptofeed_constants.TRADES:
            cryptofeed_callbacks.TradeCallback(self.trade),
            cryptofeed_constants.TICKER:
            cryptofeed_callbacks.TickerCallback(self.ticker),
            cryptofeed_constants.CANDLES:
            cryptofeed_callbacks.CandleCallback(self.candle),  # pylint: disable=E1101
            cryptofeed_constants.L2_BOOK:
            cryptofeed_callbacks.BookCallback(self.book),
            cryptofeed_constants.L3_BOOK:
            cryptofeed_callbacks.BookCallback(self.book),
            cryptofeed_constants.FUNDING:
            cryptofeed_callbacks.FundingCallback(self.funding),
            cryptofeed_constants.LIQUIDATIONS:
            cryptofeed_callbacks.LiquidationCallback(self.liquidations),
            cryptofeed_constants.BOOK_DELTA:
            cryptofeed_callbacks.BookUpdateCallback(self.delta),
            cryptofeed_constants.VOLUME:
            cryptofeed_callbacks.VolumeCallback(self.volume),
            cryptofeed_constants.OPEN_INTEREST:
            cryptofeed_callbacks.OpenInterestCallback(self.open_interest),
            cryptofeed_constants.FUTURES_INDEX:
            cryptofeed_callbacks.FuturesIndexCallback(self.futures_index),
            cryptofeed_constants.MARKET_INFO:
            cryptofeed_callbacks.MarketInfoCallback(self.market_info),
            cryptofeed_constants.TRANSACTIONS:
            cryptofeed_callbacks.TransactionsCallback(self.transactions),
        }
Beispiel #2
0
 async def prepare(self) -> None:
     bot_logging.set_logging_level(self.LOGGERS, logging.WARNING)
     ngrok.set_auth_token(
         self.config[services_constants.CONFIG_CATEGORY_SERVICES][
             services_constants.CONFIG_WEBHOOK][
                 services_constants.CONFIG_NGROK_TOKEN])
     try:
         self.webhook_host = os.getenv(
             services_constants.ENV_WEBHOOK_ADDRESS,
             self.config[services_constants.CONFIG_CATEGORY_SERVICES][
                 services_constants.CONFIG_WEBHOOK][
                     services_constants.CONFIG_WEB_IP])
     except KeyError:
         self.webhook_host = os.getenv(
             services_constants.ENV_WEBHOOK_ADDRESS,
             services_constants.DEFAULT_WEBHOOK_SERVER_IP)
     try:
         self.webhook_port = int(
             os.getenv(
                 services_constants.ENV_WEBHOOK_PORT,
                 self.config[services_constants.CONFIG_CATEGORY_SERVICES][
                     services_constants.CONFIG_WEBHOOK][
                         services_constants.CONFIG_WEB_PORT]))
     except KeyError:
         self.webhook_port = int(
             os.getenv(services_constants.ENV_WEBHOOK_PORT,
                       services_constants.DEFAULT_WEBHOOK_SERVER_PORT))
 def __init__(self):
     super().__init__()
     self.telegram_client: telethon.TelegramClient = None
     self.user_account = None
     self.connected = False
     self.tentacle_resources_path = tentacles_manager_api.get_tentacle_resources_path(self.__class__)
     bot_logging.set_logging_level(self.LOGGERS, logging.WARNING)
Beispiel #4
0
    def __init__(self,
                 config: object,
                 exchange_manager: object,
                 timeout: int = 120,
                 timeout_interval: int = 5):
        super().__init__(config, exchange_manager, timeout, timeout_interval)
        commons_logging.set_logging_level(self.LOGGERS, logging.WARNING)

        self.async_ccxt_client = None
        self.ccxt_client = None
        self.use_testnet = self.exchange_manager.is_sandboxed
Beispiel #5
0
    def __init__(self, config: object, exchange_manager: object):
        super().__init__(config, exchange_manager)
        self.channels = []

        self.callbacks = {}
        self.candle_callback = None

        self.filtered_pairs = []
        self.filtered_timeframes = []
        self.min_timeframe = None

        self._fix_signal_handler()

        # Manage cryptofeed loggers
        self.client_logger = logging.getLogger(
            f"WebSocketClient - {self.name}")
        self.client_logger.setLevel(logging.WARNING)
        self._fix_logger()

        self.client = None
        commons_logging.set_logging_level(self.CRYPTOFEED_LOGGERS,
                                          logging.WARNING)

        self.callback_by_feed = {
            cryptofeed_constants.TRADES:
            cryptofeed_callbacks.TradeCallback(self.trade),
            cryptofeed_constants.TICKER:
            cryptofeed_callbacks.TickerCallback(self.ticker),
            cryptofeed_constants.CANDLES:
            cryptofeed_callbacks.CandleCallback(self.candle),  # pylint: disable=E1101
            # cryptofeed_constants.L2_BOOK: cryptofeed_callbacks.BookCallback(self.book),
            # cryptofeed_constants.L3_BOOK: cryptofeed_callbacks.BookCallback(self.book),
            # cryptofeed_constants.FUNDING: cryptofeed_callbacks.FundingCallback(self.funding),
            # cryptofeed_constants.LIQUIDATIONS: cryptofeed_callbacks.LiquidationCallback(self.liquidations),
            # cryptofeed_constants.BOOK_DELTA: cryptofeed_callbacks.BookUpdateCallback(self.delta)
            # cryptofeed_constants.OPEN_INTEREST: cryptofeed_callbacks.OpenInterestCallback(self.open_interest),
            # cryptofeed_constants.FUTURES_INDEX: cryptofeed_callbacks.FuturesIndexCallback(self.futures_index),
            # cryptofeed_constants.MARKET_INFO: cryptofeed_callbacks.MarketInfoCallback(self.market_info),
        }
        self._set_async_callbacks()

        # Create cryptofeed FeedHandler instance
        self._create_client()

        # Creates cryptofeed exchange instance
        self.cryptofeed_exchange = cryptofeed_exchanges.EXCHANGE_MAP[
            self.get_feed_name()](config=self.client.config)
Beispiel #6
0
    async def prepare(self):
        if not self.telegram_api:
            self.chat_id = self.config[services_constants.CONFIG_CATEGORY_SERVICES][services_constants.CONFIG_TELEGRAM][
                self.CHAT_ID]
            self.telegram_api = telegram.Bot(
                token=self.config[services_constants.CONFIG_CATEGORY_SERVICES][services_constants.CONFIG_TELEGRAM][
                    services_constants.CONFIG_TOKEN])

        if not self.telegram_updater:
            self.telegram_updater = telegram.ext.Updater(
                self.config[services_constants.CONFIG_CATEGORY_SERVICES][services_constants.CONFIG_TELEGRAM][
                    services_constants.CONFIG_TOKEN],
                use_context=True,
                workers=1
            )

        bot_logging.set_logging_level(self.LOGGERS, logging.WARNING)
Beispiel #7
0
    def __init__(self,
                 config: object,
                 exchange_manager: object,
                 api_key: str = None,
                 api_secret: str = None,
                 api_password: str = None,
                 timeout: int = 120,
                 timeout_interval: int = 5):
        super().__init__(config, exchange_manager)
        commons_logging.set_logging_level(self.LOGGERS, logging.WARNING)

        self.exchange = self.exchange_manager.exchange
        self.exchange_id = self.exchange_manager.id

        self.bot_mainloop = asyncio.get_event_loop()

        self.api_key = api_key
        self.api_secret = api_secret
        self.api_password = api_password

        self.timeout = timeout
        self.timeout_interval = timeout_interval
        self.last_ping_time = 0

        # keyword arguments to be given to get_ws_endpoint
        self.endpoint_args = {}

        self.is_connected = False
        self.is_authenticated = False
        self.should_stop = False
        self.use_testnet = False

        self.currencies = []
        self.pairs = []
        self.time_frames = []
        self.channels = []
        self.books = {}

        self.websocket = None
        self._watch_task = None
        self.last_msg = datetime.utcnow()
Beispiel #8
0
    def __init__(self,
                 config: object,
                 exchange_manager: object,
                 timeout: int = 120,
                 timeout_interval: int = 5):
        super().__init__(config, exchange_manager)
        commons_logging.set_logging_level(self.LOGGERS, logging.WARNING)

        self.timeout = timeout
        self.timeout_interval = timeout_interval
        self.last_ping_time = 0

        # keyword arguments to be given to get_ws_endpoint
        self.endpoint_args = {}

        self.is_connected = False
        self.is_authenticated = False
        self.should_stop = False
        self.use_testnet = False

        self.websocket = None
        self._watch_task = None
        self.last_msg = datetime.utcnow()
    def __init__(self, config: object, exchange_manager: object):
        super().__init__(config, exchange_manager)
        self.channels = []

        self.callbacks = {}
        self.candle_callback = None

        self.filtered_pairs = []
        self.watched_pairs = []
        self.filtered_timeframes = []
        self.min_timeframe = None

        self.local_loop = None
        self.is_websocket_restarting = False

        self._fix_signal_handler()

        # Manage cryptofeed loggers
        self.client_logger = logging.getLogger(
            f"WebSocketClient - {self.name}")
        self.client_logger.setLevel(logging.WARNING)
        self._fix_logger()

        self.client = None
        self.client_config = None
        commons_logging.set_logging_level(self.CRYPTOFEED_LOGGERS,
                                          logging.WARNING)

        self.callback_by_feed = {
            # Unauthenticated
            cryptofeed_constants.TRADES:
            cryptofeed_callbacks.TradeCallback(self.trades),
            cryptofeed_constants.TICKER:
            cryptofeed_callbacks.TickerCallback(self.ticker),
            cryptofeed_constants.CANDLES:
            cryptofeed_callbacks.CandleCallback(self.candle),
            cryptofeed_constants.FUNDING:
            cryptofeed_callbacks.FundingCallback(self.funding),
            cryptofeed_constants.OPEN_INTEREST:
            cryptofeed_callbacks.OpenInterestCallback(self.open_interest),
            cryptofeed_constants.LIQUIDATIONS:
            cryptofeed_callbacks.LiquidationCallback(self.liquidations),
            cryptofeed_constants.INDEX:
            cryptofeed_callbacks.IndexCallback(self.index),
            cryptofeed_constants.L2_BOOK:
            cryptofeed_callbacks.BookCallback(self.book),

            # Authenticated
            cryptofeed_constants.ORDER_INFO:
            cryptofeed_callbacks.OrderInfoCallback(self.order),
            cryptofeed_constants.TRANSACTIONS:
            cryptofeed_callbacks.TransactionsCallback(self.transaction),
            cryptofeed_constants.BALANCES:
            cryptofeed_callbacks.BalancesCallback(self.balance),
            cryptofeed_constants.FILLS:
            cryptofeed_callbacks.UserFillsCallback(self.fill),
        }
        self._set_async_callbacks()

        # Create cryptofeed FeedHandler instance
        self._create_client()

        # Creates cryptofeed exchange instance
        self.cryptofeed_exchange = cryptofeed_exchanges.EXCHANGE_MAP[
            self.get_feed_name()](config=self.client_config,
                                  sandbox=self.exchange_manager.is_sandboxed,
                                  **self.EXCHANGE_CONSTRUCTOR_KWARGS)