import asyncio from itertools import groupby from logging import getLogger from aiotg import Bot, logging import db import settings from exchange import exchanges from exchange.base import Pair, BaseApi from exchange.exceptions import BaseExchangeException logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logger = logging.getLogger(settings.BOT_NAME) class CoinChecker: bot = Bot(settings.BOT_TOKEN) channel = bot.channel(settings.CHANNEL_ID) async def check(self): await asyncio.gather(*(self.fetch_api(api_cls) for api_cls in exchanges)) async def fetch_api(self, api_cls): api = api_cls() try: api_pairs = await api.tradable_pairs() except Exception as e: getLogger().exception(e)
import asyncio from aiotg import logging from invoke import task logging.basicConfig(level=logging.INFO) @task(default=True) def run_bot(ctx): from main import run loop = asyncio.get_event_loop() loop.run_until_complete(run(ctx.config))