Exemplo n.º 1
0
 async def main(self):
     self.loginfo('[+] Re-Poster is ready!')
     while True:
         await asyncio.sleep(self.itter_time)
         job = Job()
         job.message_type = MessageTypes.REPOST
         self.message_queue.put(job)
Exemplo n.º 2
0
    async def main(self):
        await self.cache_usdt_trades()
        while True:
            while not self.sync.can_fetch_data:
                await asyncio.sleep(0.1)
            target_time = dt.utcnow() + timedelta(minutes=5)
            total_sell_amount = 0
            total_buy_amount = 0
            total_sell_price = 0
            total_sell_number = 0
            total_buy_price = 0
            total_buy_number = 0
            self.loginfo('[+] Checking for new data from gate.io ..')
            # new_usdt_trades = await self.get_new_usdt_trades()
            async for new_usdt_trades in self.get_new_usdt_trades():
                for trade in new_usdt_trades:
                    if trade['type'] == 'sell':
                        total_sell_amount += float(trade['amount'])
                        total_sell_price += float(trade['rate'])
                        total_sell_number += 1
                    elif trade['type'] == 'buy':
                        total_buy_amount += float(trade["amount"])
                        total_buy_price += float(trade['rate'])
                        total_buy_number += 1
                if dt.utcnow() < target_time:
                    await asyncio.sleep(self.trades_check_time)
                    continue
                break
            liquidity = total_buy_amount - total_sell_amount
            if total_sell_price == 0:
                average_Sell_price = "There were no Sell Orders in the last 5 minutes!"
            else:
                average_Sell_price = total_sell_price / total_sell_number
            if total_buy_price == 0:
                average_buy_price = "There were not Buy Orders in the last 5 minutes!"
            else:
                average_buy_price = total_buy_price / total_buy_number
            data = await self.coingecko.get_data()
            current_price = data['current_price']
            circles = get_circles(liquidity)
            liq_msg = f'Liquidity added/removed : {liquidity} GTH\n{circles}'
            timestamp = dt.utcnow().strftime("%H:%M")
            message = f'**Exchange : ** {self.exchange_name}\n\n**{liq_msg}**\n\n**Current Price :** {current_price}\n\n**Average Buy Price :** {average_buy_price}\
\n\n**Total Number of Buy Trades :** {total_buy_number}\n\n**Average Sell Price :** {average_Sell_price}\n\n**Total Number of Sell Trades :** {total_sell_number}\n\n**Timestamp :** {timestamp}'

            job = Job()
            job.message_type = MessageTypes.TEXT_MESSAGE
            job.message = message
            signal = Signal(Threads.GATE)
            signal.is_data_ready = True
            self.signals_queue.put(signal)
            while not self.sync.all_data_ready:
                await asyncio.sleep(0.1)
            self.queue.put(job)
            signal = Signal(Threads.GATE)
            signal.is_data_sent = True
            signal.is_data_ready = True
            self.signals_queue.put(signal)
            self.loginfo('[+] Gate API data added to the queue!')
Exemplo n.º 3
0
    async def main(self):
        await self.cache_trades()
        while True:
            while not self.sync.can_fetch_data:
                await asyncio.sleep(0.2)
            target_time = dt.utcnow() + timedelta(minutes=5)
            total_buy = 0
            total_sell = 0
            total_buy_prices = float(0)
            total_sell_prices = float(0)
            total_buy_number = float(0)
            total_sell_number = float(0)
            self.loginfo('[+] Checking for new data from bithumb.com ...')
            async for new_trades in self.get_new_trades():
                for trade in new_trades:
                    gth_qty = trade['v']
                    if trade['s'] == 'buy':
                        # Bought GTH
                        total_buy += float(gth_qty)
                        total_buy_prices += float(trade['p'])
                        total_buy_number += 1
                    elif trade['s'] == 'sell':
                        total_sell += float(gth_qty)
                        total_sell_prices += float(trade['p'])
                        total_sell_number += 1
                if dt.utcnow() < target_time:
                    await asyncio.sleep(self.trades_check_time)
                    continue
                break
            liquidity = total_buy - total_sell
            data = await self.coingecko.get_data()
            current_price = data['current_price']
            if total_sell_prices == 0:
                average_Sell_price = "There were no Sell Orders in the last 5 minutes!"
            else:
                average_Sell_price = total_sell_prices / total_sell_number
            if total_buy_prices == 0:
                average_Buy_price = "There were no Buy Orders in the last 5 minutes!"
            else:
                average_Buy_price = total_buy_prices / total_buy_number
            circles = get_circles(liquidity)
            liq_msg = f'Liquidity added/removed : {liquidity} GTH\n{circles}'
            timestamp = dt.utcnow().strftime("%H:%M")
            message = f'**Exchange : ** {self.exchange_name}\n\n**{liq_msg}**\n\n**Current Price :** {current_price}\n\n**Average Buy Price :** {average_Buy_price}\
\n\n**Total Number of Buy Transactions :** {total_buy_number}\n\n**Average Sell Price :** {average_Sell_price}\n\n**Total Number of Sell Transactions :** {total_sell_number}\n\n**Timestamp :** {timestamp}'

            job = Job()
            job.message_type = MessageTypes.TEXT_MESSAGE
            job.message = message
            signal = Signal(Threads.BITHUMB)
            signal.is_data_ready = True
            self.signals_queue.put(signal)
            while not self.sync.all_data_ready:
                await asyncio.sleep(0.1)
            self.queue.put(job)
            signal = Signal(Threads.BITHUMB)
            signal.is_data_sent = True
            signal.is_data_ready = True
            self.signals_queue.put(signal)
Exemplo n.º 4
0
 async def main(self):
     self.driver.get(self.target_addr)
     while True:
         self.logger('[+] Reloading website ...')
         self.driver.refresh()
         dark_mode = False
         while not dark_mode:
             theme_change = self.driver.find_element_by_class_name(
                 'theme-exchange-component')
             theme_change.click()
             classes = theme_change.get_attribute('class').split(' ')
             if 'dark' in classes:
                 dark_mode = True
             await asyncio.sleep(0.5)
         try:
             frame = WebDriverWait(self.driver, 30).until(
                 EC.presence_of_element_located(
                     (By.TAG_NAME, 'iframe'))
             )
         except:
             continue
         frame = self.driver.find_element_by_tag_name('iframe')
         self.driver.switch_to.frame(frame)
         try:
             chart = WebDriverWait(self.driver, 30).until(
                 EC.presence_of_element_located(
                     (By.CLASS_NAME, 'chart-page'))
             )
         except:
             continue
         try:
             time_buttons = WebDriverWait(self.driver, 30).until(
                 EC.presence_of_all_elements_located(
                     (By.CLASS_NAME, "dropdown-menu-item"))
             )
         except:
             continue
         time_buttons = self.driver.find_elements_by_class_name(
             'dropdown-menu-item')
         for btn in time_buttons:
             attr = btn.get_attribute('data-title')
             if attr == '30M':
                 btn.click()
                 break
         await asyncio.sleep(3)
         if os.path.exists(self.screenshot):
             os.remove(self.screenshot)
         data = chart.screenshot_as_png
         ss = open(self.screenshot, 'wb')
         ss.write(data)
         ss.close()
         self.logger('[+] Graph Captured!')
         job = Job()
         job.graph_location = self.screenshot
         job.message_type = MessageTypes.GRAPH
         self.graph_queue.put(job)
         await asyncio.sleep(self.itter_time)
Exemplo n.º 5
0
 def on_status(self, status):
     self.loginfo('Found a new tweet')
     username = status._json['user']['screen_name']
     usersList = list(self.config.get("TARGET_TWITTER_ACCOUNTS"))
     if f'@{username}' in usersList:
         tweet_text = status._json["text"]
         name = status._json['user']['name']
         tweet_id = status._json['id']
         tweet_link = f'https://twitter.com/i/web/status/{tweet_id}'
         message = f'**{name} just Tweeted!** \n{tweet_text}\n\n[See Full Tweet Here!]({tweet_link})'
         job = Job()
         job.message = message
         job.message_type = MessageTypes.TEXT_MESSAGE
         self.queue.put(job)
         self.loginfo('Tweet added to the queue!')
Exemplo n.º 6
0
 def on_status(self, status):
     global COUNTER
     COUNTER += 1
     time_now = dt.utcnow()
     print(f'$GTH Mention : {COUNTER}')
     if time_now < self.target_time:
         return True
     fire_emojies = get_fire_emojies(COUNTER)
     message = f'**15 Minute GTH Twitter Mention Report**\n\n**Total $GTH Mentions :** {COUNTER}\n{fire_emojies}'
     job = Job()
     job.message = message
     job.message_type = MessageTypes.TEXT_MESSAGE
     self.queue.put(job)
     COUNTER = 0
     self.target_time = dt.utcnow() + timedelta(minutes=15)
Exemplo n.º 7
0
 async def main(self):
     self.driver.get(self.blog_addr)
     self.latest_date = await self.get_latest_post_date()
     while True:
         self.loginfo('[+] Checking for new blog post ..')
         self.driver.refresh()
         ld = await self.get_latest_post_date()
         if ld == self.latest_date:
             await asyncio.sleep(self.itter_time)
             continue
         new_post = await self.get_new_post()
         message = await self.create_message(new_post)
         job = Job()
         job.message = message
         job.message_type = MessageTypes.TEXT_MESSAGE
         self.message_queue.put(job)
         await asyncio.sleep(self.itter_time)
         continue
Exemplo n.º 8
0
    async def main(self):
        while True:
            self.loginfo('[+] Collecting Hourly Data ...')
            data = await self.coingecko.get_data()
            current_price = data['current_price']
            market_cap = data['market_cap']
            circulating_supply = data['circulating_supply']
            total_supply = data['total_supply']
            holders_data = next(self.get_holders)
            timestamp = dt.utcnow().strftime("%H:%M")
            message = f'{self.fire}**Gather Hourly Status Update**{self.fire}\n\n**Current Price :** {self.dollar} {current_price}\
\n\n**Market Cap : **{market_cap}\n\n**Circulating Supply : **{circulating_supply}\n\n**Total Supply : **{total_supply}\n\n**Holders : **{holders_data}\n\n**Timestamp : ** {timestamp}'

            job = Job()
            job.message_type = MessageTypes.TEXT_MESSAGE
            job.message = message
            self.queue.put(job)
            self.bt_data_buy = 0
            self.bt_data_sell = 0
            await asyncio.sleep(self.itter_time)
Exemplo n.º 9
0
    async def main(self):
        await self.cache_trades()
        while True:
            while not self.sync.can_fetch_data:
                await asyncio.sleep(0.2)
            # The target time when the data will be calculated and sent
            target_time = dt.utcnow() + timedelta(minutes=5)
            total_sell_amount = 0
            total_buy_amount = 0
            total_buy_price = 0
            total_Sell_price = 0
            total_buy_number = 0
            total_sell_number = 0
            self.loginfo('[+] Checking for new data from hoo.com ...')
            async for new_trades in self.get_new_trades():
                for trade in new_trades:
                    order_type = trade['side']
                    if order_type == 1:
                        # The GTH is bought for USDT
                        total_buy_amount += float(trade['amount'])
                        total_buy_price += float(trade['price'])
                        total_buy_number += 1
                    elif order_type == -1:
                        total_sell_amount += float(trade['amount'])
                        total_Sell_price += float(trade['price'])
                        total_sell_number += 1
                if dt.utcnow() < target_time:
                    await asyncio.sleep(self.trade_check_time)
                    continue
                break
            liquidity = total_buy_amount - total_sell_amount
            if total_buy_price == 0:
                average_buy_price = "There were no Buy Orders in the last 5 minutes"
            else:
                average_buy_price = total_buy_price / total_buy_number
            if total_Sell_price == 0:
                average_Sell_price = "There were no Sell Orders in the last 5 minutes!"
            else:
                average_Sell_price = total_Sell_price / total_sell_number
            data = await self.coingecko.get_data()
            current_price = data['current_price']
            circles = get_circles(liquidity)
            liq_msg = f'Liquidity added/removed : {liquidity} GTH\n{circles}'
            timestamp = dt.utcnow().strftime("%H:%M")
            message = f'**Exchange : ** {self.exchange_name}\n\n**{liq_msg}**\n\n**Current Price :** {current_price}\n\n**Average Buy Price :** {average_buy_price}\
\n\n**Total Number Buy Transactions :** {total_buy_number}\n\n**Average Sell Price :** {average_Sell_price}\n\n**Total Number Sell Transactions :** {total_sell_number}\n\n**Timestamp :** {timestamp}'

            job = Job()
            job.message_type = MessageTypes.TEXT_MESSAGE
            job.message = message
            signal = Signal(Threads.HOO)
            signal.is_data_ready = True
            self.signals_queue.put(signal)
            while not self.sync.all_data_ready:
                await asyncio.sleep(0.1)
            self.queue.put(job)
            signal = Signal(Threads.HOO)
            signal.is_data_sent = True
            signal.is_data_ready = True
            self.signals_queue.put(signal)
            self.loginfo('[+] Hoo API data added to the queue!')
Exemplo n.º 10
0
    async def main(self):
        self.loginfo('[+] UniSwap Thread is ready!')
        await self.cache_swaps()
        while True:
            while not self.sync.can_fetch_data:
                await asyncio.sleep(0.2)
            target_time = dt.utcnow() + timedelta(minutes=5)
            # Total_sell_amount will store the total sell values of the orders found in each loop
            total_sell_amount = float(0)
            # Total_buy_amount will store the total buy values of the orders found in each loop
            total_buy_amount = float(0)
            # Total_Sell_Number will store the total number of sells in each loop
            total_sell_transactions = int(0)
            total_sell_price = int(0)
            total_Buy_transactions = int(0)
            total_sell_price = float(0)
            total_buy_price = float(0)
            self.loginfo('[+] Checking for new data from uniswap ..')
            # In the below loop we are gonna store the amounts of all the buy and sell
            # order separatley in total_sell_amount and total_buy_amount.
            async for swaps in self.get_swaps():
                # self.loginfo(f'Got {len(swaps)} new swaps')
                for swap in swaps:
                    if swap['amount0In'] == "0":
                        # ETH is bought and GTH is Sold.
                        gth_value = swap['amount1In']
                        gth_sell_price = swap['amountUSD']
                        total_sell_amount += float(gth_value)
                        total_sell_price += float(gth_sell_price)
                        total_sell_transactions += 1
                    elif swap['amount0Out'] == "0":
                        # It means that ETH is sold and GTH is bought.
                        gth_value = swap["amount1Out"]
                        gth_buy_price = swap['amountUSD']
                        total_buy_amount += float(gth_value)
                        total_buy_price += float(gth_buy_price)
                        total_Buy_transactions += 1
                if dt.utcnow() < target_time:
                    await asyncio.sleep(self.swaps_check_time)
                    continue
                # Synchronize the app time with utc time and go back 6 minutes.
                break
            # Here calculating the liquidity.
            liquidity = total_buy_amount - total_sell_amount
            # self.loginfo(f'Uniswap liquidity : {liquidity}')
            # Here we are getting the coingecko data from coingecko API.
            data = await self.coingecko.get_data()
            current_price = data['current_price']
            if total_sell_amount == 0:
                average_sell_price = "There were no Sell Orders in the last 5 mins"
            else:
                average_sell_price = total_sell_price / total_sell_amount
            if total_buy_amount == 0:
                average_buy_price = "There were no Buy Orders in the last 5 mins"
            else:
                average_buy_price = total_buy_price / total_buy_amount
            circles = get_circles(liquidity)
            liq_msg = f'Liquidity added/removed : {liquidity} GTH\n{circles}'
            self.last_trade_timestamp = dt.utcnow() - timedelta(minutes=5)
            timestamp = dt.utcnow().strftime("%H:%M")
            message = f'Exchange : {self.exchange_name}\n\n**{liq_msg}**\n\n**Current Price :** {current_price}\n\n**Average Buy Price:** {average_buy_price}\
\n\n**Number of Buy Transactions :** {total_Buy_transactions}\n\n**Average Sell Price :** {average_sell_price}\n\n**Number of Sell Transactions :** {total_sell_transactions}\n\n**Timestamp :** {timestamp}'

            job = Job()
            job.message_type = MessageTypes.TEXT_MESSAGE
            job.message = message
            signal = Signal(Threads.UNISWAP)
            signal.is_data_ready = True
            self.signals_queue.put(signal)
            while not self.sync.all_data_ready:
                await asyncio.sleep(0.1)
            self.queue.put(job)
            signal = Signal(Threads.UNISWAP)
            signal.is_data_sent = True
            signal.is_data_ready = True
            self.signals_queue.put(signal)