Beispiel #1
0
    async def get(self) -> Set[Symbol]:
        url = 'https://medium.com/_/api/collections/c114225aeaf7/stream'
        response_raw = await self.http.get(url, output=OutputFormat.RAW)
        response_correct = response_raw[response_raw.find('{'):]
        response = ujson.loads(response_correct)
        if not response or not response['success']:
            raise CoinbaseProPartException(url, response)
        posts = response['payload']['references']['Post']

        titles = (
            p['title']
            for _, p in posts.items()
            if 'is launching on coinbase pro' in p['title'].lower()
        )

        symbols = set()
        for i in titles:
            symbols.update(self.REGEX.findall(i))

        return set(
            Symbol(
                symbol,
                CoinSource.SITE,
                'https://blog.coinbase.com/'
            )
            for symbol in symbols
        )
Beispiel #2
0
    async def stream(self) -> AsyncIterable[Set[Symbol]]:
        user_ids = [
            '1058405958626340869',  # bittrexus
            # '16324992',  # richiela
            # '902585667947036672',  # ape36484
        ]

        req = self.client.stream.statuses.filter.post(
            follow=','.join(user_ids))
        async with req as stream:
            async for tweet in stream:
                try:
                    await self.log(tweet)
                except Exception as e:
                    await self.log('unable to log tweet: %s', e)

                if not peony.events.tweet(tweet):
                    continue

                if str(tweet.user.id) not in user_ids:
                    continue

                if not self._has_text(tweet.text):
                    continue

                symbols = self._get_symbols(tweet)
                if not symbols:
                    continue

                yield set(
                    Symbol(
                        symbol, CoinSource.TWITTER,
                        f'https://twitter.com/{tweet.user.screen_name}/status/{tweet.id}'
                    ) for symbol in symbols)
Beispiel #3
0
    async def get(self) -> Set[Symbol]:
        search_words = ('lists', 'list')
        params = dict(
            page=1,
            rows=3,
            lang='en'
        )
        url = f'https://www.binance.com/public/getNotice.html?{urlencode(params)}'

        response = await self.http.post(url)
        if 'data' not in response:
            raise BinancePartException(url, response)

        symbols = set()
        for ann in response['data']:
            ann_title = ann['name'].strip().lower()
            if any(w in ann_title for w in search_words):
                for symbol in self.REGEX.findall(ann_title):
                    symbols.add(symbol.upper())

        return set(
            Symbol(
                symbol,
                CoinSource.SITE,
                url
            )
            for symbol in symbols
        )
Beispiel #4
0
async def cmd_fake_coin(message: types.Message):
    _, *args = message.text.split()
    coin_name = str(args.pop(0))
    coin_name = coin_name.upper()

    trigger_exchange = None
    for e in trigger_mgr.exchanges:
        if e.name == 'telegram':
            trigger_exchange = e
            break
    if not trigger_exchange:
        return

    fake_part = None
    for p in trigger_exchange._parts:
        if p.source == CoinSource.TELEGRAM:
            fake_part = p

    if not fake_part:
        return

    fake_part.coins.add(
        Symbol(coin_name, CoinSource.TELEGRAM, 'http://fake.telegram.url'))

    await message.reply(f'Added {coin_name} to the fake trigger.')
Beispiel #5
0
async def add_symbol(part: TelegramTriggerPart, symbols: Set[str],
                     src: CoinSource, message: types.Message) -> None:
    if not part:
        await message.reply(f'No symbols found for part {part}.')
        return
    for symbol in symbols:
        part.coins.add(Symbol(symbol, src, 'http://from.jayden.channel'))
        await message.reply(f'Added {symbol} for part {part.source}.')
Beispiel #6
0
    async def get(self) -> Set[Symbol]:
        url = 'https://bittrex.com/api/v1.1/public/getmarkets'
        response = await self.http.get(url)
        if not response['success']:
            raise BittrexPartException(url, response)

        return set(
            Symbol(i['MarketCurrency'].upper(), CoinSource.API_PAIR, url)
            for i in response['result'])
Beispiel #7
0
 async def get(self) -> Set[Symbol]:
     url = 'https://api.bithumb.com/public/ticker/ALL'
     response = await self.http.get(url)
     if not response or response['status'] != '0000':
         raise BithumbPartException(url, response)
     return set(
         Symbol(symbol, CoinSource.API_PAIR, url)
         for symbol, data in response['data'].items()
         if isinstance(data, dict))
Beispiel #8
0
    async def get(self) -> Set[Symbol]:
        url = 'https://www.bithumb.com/resources/csv/market_sise.json'
        response = await self.http.get(url)
        if not response or not isinstance(response, list):
            raise BithumbPartException(url, response)

        return set(
            Symbol(i['symbol'], CoinSource.API_UNOFFICIAL, url)
            for i in response)
Beispiel #9
0
    async def get(self) -> Set[Symbol]:
        url = 'https://www.bithumb.com/trade/getAsset/DASH'  # idk why DASH
        response = await self.http.get(
            url, headers={'X-Requested-With': 'XMLHttpRequest'})
        if not response or response['error'] != '0000':
            raise BithumbPartException(url, response)

        return set(
            Symbol(i, CoinSource.API_WALLET, url) for i in response['data'])
Beispiel #10
0
    async def get(self) -> Set[Symbol]:
        url = f'https://s3.ap-northeast-2.amazonaws.com/crix-production/crix_master?nonce={self.nonce()}'
        response = await self.http.get(url)
        if not isinstance(response, list):
            raise UpbitPartException(url, response)

        return set(
            Symbol(i['baseCurrencyCode'].upper(), CoinSource.API_PAIR, url)
            for i in response if i['quoteCurrencyCode'].upper() == 'BTC')
Beispiel #11
0
    async def get(self) -> Set[Symbol]:
        search_words = ('상장 및', )
        ARTICLE_TITLE = 2
        url = 'https://cafe.bithumb.com/boards/43/contents'

        post_form_data = {
            'draw': 1,
            'columns[0][data]': 0,
            'columns[0][name]': None,
            'columns[0][searchable]': True,
            'columns[0][orderable]': False,
            'columns[0][search][value]': None,
            'columns[0][search][regex]': False,
            'columns[1][data]': 1,
            'columns[1][name]': None,
            'columns[1][searchable]': True,
            'columns[1][orderable]': False,
            'columns[1][search][value]': None,
            'columns[1][search][regex]': False,
            'columns[2][data]': 2,
            'columns[2][name]': None,
            'columns[2][searchable]': True,
            'columns[2][orderable]': False,
            'columns[2][search][value]': None,
            'columns[2][search][regex]': False,
            'columns[3][data]': 3,
            'columns[3][name]': None,
            'columns[3][searchable]': True,
            'columns[3][orderable]': False,
            'columns[3][search][value]': None,
            'columns[3][search][regex]': False,
            'columns[4][data]': 4,
            'columns[4][name]': None,
            'columns[4][searchable]': True,
            'columns[4][orderable]': False,
            'columns[4][search][value]': None,
            'columns[4][search][regex]': False,
            'start': 0,
            'length': 15,
            'search[value]': None,
            'search[regex]': False
        }

        response = await self.http.post(url, data=post_form_data)
        if 'data' not in response:
            raise BithumbPartException(url, response)
        data = response['data']

        filtered = (i[ARTICLE_TITLE] for i in data
                    if any(w in i[ARTICLE_TITLE] for w in search_words))

        symbols = set()
        for i in filtered:
            symbols.update(self.REGEX.findall(i))

        return set(Symbol(symbol, CoinSource.SITE, url) for symbol in symbols)
Beispiel #12
0
 async def get(self) -> Set[Symbol]:
     url = 'https://www.binance.com/exchange/public/product'
     response = await self.http.get(url)
     if not response or 'data' not in response:
         raise BinancePartException(url, response)
     return set(
         Symbol(
             i['baseAsset'],
             CoinSource.API_PAIR,
             url
         )
         for i in response['data']
     )
Beispiel #13
0
 async def get(self) -> Set[Symbol]:
     url = 'https://api.binance.com/api/v1/exchangeInfo'
     response = await self.http.get(url)
     if not response or 'symbols' not in response:
         raise BinancePartException(url, response)
     return set(
         Symbol(
             i['baseAsset'],
             CoinSource.API_PAIR,
             url
         )
         for i in response['symbols']
     )
Beispiel #14
0
    async def get(self) -> Set[Symbol]:
        url = 'https://www.binance.com/assetWithdraw/getAllAsset.html'
        response = await self.http.get(url)
        if not response or not isinstance(response, list) or not len(response):
            raise BinancePartException(url, response)

        return set(
            Symbol(
                i['assetCode'],
                CoinSource.API_UNOFFICIAL,
                url
            )
            for i in response
        )
Beispiel #15
0
    async def get(self) -> Set[Symbol]:
        url = 'https://www.binance.com/dictionary/getAssetPic.html'
        response = await self.http.post(url)
        if 'data' not in response:
            raise BinancePartException(url, response)

        return set(
            Symbol(
                i['asset'],
                CoinSource.API_UNOFFICIAL,
                url
            )
            for i in response['data']
        )
Beispiel #16
0
    async def get(self) -> Set[Symbol]:
        await asyncio.sleep(1.0)
        url = 'https://api.pro.coinbase.com/currencies/'
        response = await self.http.get(url)
        if not response or not isinstance(response, list):
            raise CoinbaseProPartException(url, response)

        return set(
            Symbol(
                i['id'].upper(),
                CoinSource.API_WALLET,
                url
            )
            for i in response
        )
Beispiel #17
0
    async def stream(self) -> AsyncIterable[Set[Symbol]]:
        user_ids = [
            '720487892670410753',  # CoinbasePro
            # '902585667947036672',  # ape36484
        ]

        req = self.client.stream.statuses.filter.post(follow=','.join(user_ids))
        async with req as stream:
            async for tweet in stream:
                try:
                    await self.log(tweet)
                except Exception as e:
                    await self.log('unable to log tweet: %s', e)

                if not peony.events.tweet(tweet):
                    continue

                if str(tweet.user.id) not in user_ids:
                    continue

                if self._has_usdc_in_text(tweet):
                    continue

                symbols = self._get_symbols(tweet)
                if not symbols:
                    continue

                await self.log('new coins: %s', symbols)

                yield set(
                    Symbol(
                        symbol,
                        CoinSource.TWITTER,
                        f'https://twitter.com/{tweet.user.screen_name}/status/{tweet.id}'
                    )
                    for symbol in symbols
                )