def to_string(self, is_complex=False): top = "*(" + self.ticker[:6] + ") " + self.name[:15] + "*" if self.get_amount_usd_token() is not None: top += " - `$" + util.pretty_number(self.get_amount_usd_token()) + "`" bottom = "`" + util.pretty_number(self.amount_owned) + "` " + self.ticker[:6] if self.value_usd is not None: bottom += " - `$" + util.pretty_number(self.value_usd) + "`" return top + '\n' + bottom
def to_string(self): price_usd_pretty = pretty_number(self.price_usd()) emoji = "🤖" * min((round(self.price_usd() * 10) + 1), 30) main_part = "Bot stole <b>" + pretty_number( self.amount_token_pair_stolen ) + ' ' + self.paired_with.ticker + "</b> <code>($" + price_usd_pretty + ")</code>" end = " | " + '<a href="etherscan.io/tx/' + str( self.swap_buy.id ) + '">buy tx</a> - ' + '<a href="etherscan.io/tx/' + str( self.swap_sell.id) + '">sell tx</a>' return emoji + '\n' + main_part + end
def to_string(self, custom_emoji=None): emoji = "💔" if custom_emoji is None else custom_emoji price_usd = pretty_number(self.price_usd()) time_since = time_util.get_minute_diff(self.timestamp) message = emoji + " Removed " + pretty_number(self.token_0[1])[0:6] + ' ' + self.token_0[0] + " and " \ + pretty_number(self.token_1[1])[0:6] + ' ' + self.token_1[0] + " in liquidity" \ + " <code>($" + price_usd[0:6] + ")</code> " \ + str(time_since) + " mins ago." message += " | " + '<a href="etherscan.io/tx/' + str( self.id) + '">view</a>' return message
def to_string_complex(self): price_usd_raw = self.price_usd() price_usd = pretty_number(price_usd_raw) emoji = min((round(self.price_usd() / 300)), 30) * "💔" + "💔" time_since = time_util.get_minute_diff(self.timestamp) first_row = emoji + '\n' main_part = "Removed " + pretty_number(self.token_0[1])[0:6] + ' ' + self.token_0[0] + " and " \ + pretty_number(self.token_1[1])[0:6] + ' ' + self.token_1[0] + " in liquidity" \ + " <code>($" + price_usd[0:6] + ")</code> " \ + str(time_since) + " mins ago." end = " | " + '<a href="etherscan.io/tx/' + str(self.id) + '">view</a>' return first_row + main_part + end
def to_string(self, eth_price): if self.token_0[0] == 'WETH': price_usd = pretty_number(self.token_0[1] * eth_price) else: price_usd = pretty_number(self.token_1[1] * eth_price) time_since = time_util.get_minute_diff(self.timestamp) message = "💔 Removed " + pretty_number(self.token_0[1])[0:6] + ' ' + self.token_0[0] + " and " \ + pretty_number(self.token_1[1])[0:6] + ' ' + self.token_1[0] + " in liquidity" \ + " <code>($" + price_usd[0:6] + ")</code> "\ + str(time_since) + " mins ago." message += " | " + '<a href="etherscan.io/tx/' + str( self.id) + '">view</a>' return message
def generate_telegram_message(trade_info: TradeInfo, gns_helper): updated_trade_info = trade_info.update_current_price(gns_helper) type_name = "Long📈" if updated_trade_info.is_long else "Short📉" price_change_multiplier = -1 if updated_trade_info.is_long else 1 pnl = (updated_trade_info.open_interest_dai_decimaled / updated_trade_info.open_price_decimaled) * ( updated_trade_info.pair.current_price_decimaled - updated_trade_info.open_price_decimaled ) * price_change_multiplier * -1 price_change = ((updated_trade_info.open_price_decimaled - updated_trade_info.pair.current_price_decimaled) / updated_trade_info.open_price_decimaled ) * 100 * price_change_multiplier sl_message = '$' + pretty_number(updated_trade_info.sl_decimaled) if int( updated_trade_info.sl_decimaled) != 0 else "Chad no SL 💪" message = f"""<b>{type_name}: {updated_trade_info.pair.name_from} @ ${pretty_number(updated_trade_info.open_price_decimaled)}</b> <b>Leverage:</b> {updated_trade_info.leverage}x {smiley_leverage(updated_trade_info.leverage)} <b>Collateral:</b> ${pretty_number(updated_trade_info.collateral_size_dai_decimaled)} {smiley_collateral(updated_trade_info.collateral_size_dai_decimaled, "💰")} <b>Size:</b> ${pretty_number(updated_trade_info.open_interest_dai_decimaled)} <b>Current price:</b> ${pretty_number(updated_trade_info.pair.current_price_decimaled)} <b>Price change:</b> {pretty_number(price_change)}% {smiley_price_change(price_change)} <b>Sl:</b> {sl_message} | <b>Tp:</b> ${pretty_number(updated_trade_info.tp_decimaled)} <b>PnL:</b> ${pretty_number(pnl)} ({pretty_number(price_change * updated_trade_info.leverage)}%)""" return message
def to_string(self, eth_price): message = "" time_since = time_util.get_minute_diff(self.timestamp) if self.is_positif(): price_usd = pretty_number(self.buy[1] * eth_price) message += "🟢 Buy " + pretty_number(self.sell[1])[0:9] + " " + self.sell[0] + " for " \ + pretty_number(self.buy[1])[0:9] + " ETH <code>($" + price_usd[0:6] + ")</code> " \ + str(time_since) + " mins ago." else: price_usd = pretty_number(self.sell[1] * eth_price) message += "🔴 Sell " + pretty_number(self.buy[1])[0:9] + " " + self.buy[0] + " for " \ + pretty_number(self.sell[1])[0:9] + " ETH <code>($" + price_usd[0:6] + ")</code> " \ + str(time_since) + " mins ago." message += " | " + '<a href="etherscan.io/tx/' + str( self.id) + '">view</a>' return message
def to_string_complex(self): if self.is_positif(): price_usd_raw = self.buy[1] * self.paired_with.price_usd price_usd = pretty_number(price_usd_raw) # emoji = min(round(self.buy[1]), 30) * "🟢" + "🟢" emoji = min((round(price_usd_raw / 300)), 30) * "🟢" + "🟢" main_part = "Buy <b>" + pretty_number(self.sell[1])[0:9] + " " + self.sell[0] + "</b> for <b>" \ + pretty_number(self.buy[1])[0:9] + ' ' + self.buy[0] + " </b> <code>($" + price_usd[0:6] + ")</code>" else: price_usd_raw = self.sell[1] * self.paired_with.price_usd price_usd = pretty_number(price_usd_raw) # emoji = min(round(self.sell[1]), 30) * "🔴" + "🔴" emoji = min((round(price_usd_raw / 300)), 30) * "🔴" + "🔴" main_part = "Sell <b>" + pretty_number(self.buy[1])[0:9] + " " + self.buy[0] + "</b> for <b>" \ + pretty_number(self.sell[1])[0:9] + ' ' + self.sell[0] + " </b> <code>($" + price_usd[0:6] + ")</code>" first_row = emoji + '\n' end = " | " + '<a href="etherscan.io/tx/' + str(self.id) + '">view</a>' return first_row + main_part + end
def to_string(self, custom_emoji=None, with_date=True): message = "" time_since = time_util.get_minute_diff(self.timestamp) date_msg = str(time_since) + " mins ago." if with_date else "" if self.is_positif(): price_usd = pretty_number(self.buy[1] * self.paired_with.price_usd) emoji = "🟢" if custom_emoji is None else custom_emoji message += emoji + " Buy " + pretty_number(self.sell[1])[0:9] + " " + self.sell[0] + " for " \ + pretty_number(self.buy[1])[0:9] + " " + self.buy[0] + " <code>($" + price_usd[0:6] + ")</code> " \ + date_msg else: emoji = "🔴" if custom_emoji is None else custom_emoji price_usd = pretty_number(self.sell[1] * self.paired_with.price_usd) message += emoji + " Sell " + pretty_number(self.buy[1])[0:9] + " " + self.buy[0] + " for " \ + pretty_number(self.sell[1])[0:9] + " " + self.sell[0] + " <code>($" + price_usd[0:6] + ")</code> " \ + date_msg message += " | " + '<a href="etherscan.io/tx/' + str( self.id) + '">view</a>' return message
def get_balance_wallet(wallet: str, path: str, simple=False): res = requests_util.get_balance_wallet_request(wallet) eth = res['ETH'] eth_token = TokenOwned(name='Ether', ticker='ETH', address='', amount_owned=float(eth['balance']), value_usd=float(eth['price']['rate'])) tokens_that_were_owned = res['tokens'] too_many_tokens = False if len(tokens_that_were_owned) > 250: logging.info("Shitton of shitcoins in this wallet (" + str(len(tokens_that_were_owned)) + ")") tokens_that_were_owned = tokens_that_were_owned[0:250] too_many_tokens = True tokens_owned = [] for token in tokens_that_were_owned: if token['balance'] != 0: maybe_token_descr = token['tokenInfo'] if maybe_token_descr is not None: token_owned_raw = float(token['balance']) if 'decimals' not in maybe_token_descr: pass elif ( maybe_token_descr['decimals'] != 0 and 'name' in maybe_token_descr ): decimals = int(maybe_token_descr['decimals']) amount_owned = token_owned_raw / 10 ** decimals maybe_price_token_unit_usd = get_price_token(maybe_token_descr) actual_token = TokenOwned(name=maybe_token_descr['name'], ticker=maybe_token_descr['symbol'], address=maybe_token_descr['address'], amount_owned=amount_owned, value_usd=maybe_price_token_unit_usd) tokens_owned.append(actual_token) logging.debug("done analyzing tokens") tokens_owned_sorted = [eth_token] + sorted(tokens_owned, key=lambda x: x.get_amount_usd_token(0.0), reverse=True) total_value = eth_token.get_amount_usd_token(0.0) for token in tokens_owned: total_value += token.get_amount_usd_token(0.0) message = "" if too_many_tokens: message = "Too many coins in wallet (" + str( len(tokens_owned_sorted)) + ") limiting view to 250 random tokens. \n" message += "*Total value of wallet:* `$" + util.pretty_number(total_value) + "`\n" if simple: tokens_owned_sorted = [x for x in tokens_owned if x.get_amount_usd_token( 0.0) > 0.01] # For some reasons filtering on the tokens remove the order tokens_owned_sorted = [eth_token] + sorted(tokens_owned_sorted, key=lambda x: x.get_amount_usd_token(0.0), reverse=True) message_top = "Overview of wallet " + wallet[0:10] + "...: \n" else: message_top = "Full view of wallet " + wallet[0:10] + "...: \n" for token in tokens_owned_sorted: message += token.to_string() + "\n" graphs_util.get_piechart(tokens_owned_sorted, path) msg = (message_top + message) return msg.replace("-", "\-").replace("(", "\(").replace(")", "\)").replace(".", "\.")