Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/bot.py
5925 views
from twitchio.ext import commands1import twitch_creds2import client34bot = commands.Bot(5token=twitch_creds.TMI_TOKEN,6client_id=twitch_creds.CLIENT_ID,7nick=twitch_creds.BOT_NICK,8prefix=twitch_creds.BOT_PREFIX,9initial_channels=[twitch_creds.CHANNEL]10)111213@bot.command(name='sell')14async def sell(ctx, ticker):15# send signal to sell16if client.get_figi(ticker) in client.get_current_stocks():17try:18client.sell(ticker)19await ctx.send(f'{ctx.author.name} {ticker.upper()} sold')20except:21await ctx.send(f'{ctx.author.name} *ошибка*')22else:23await ctx.send(f'{ctx.author.name} Чтобы продать {ticker.upper()} - нужно иметь его в портфеле')242526@bot.command(name='buy')27async def buy(ctx, ticker):28# send signal to buy29try:30client.buy(ticker)31await ctx.send(f'{ctx.author.name} {ticker.upper()} bought')32except:33await ctx.send(f'{ctx.author.name} *ошибка*')343536if __name__ == '__main__':37bot.run()383940