-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
47 lines (39 loc) · 1.77 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from discord.ext import commands
import random
from bsedata.bse import BSE
b = BSE()
print(b)
b = BSE(update_codes = True)
bot = commands.Bot(command_prefix='!')
@bot.command(name="bluechip", help="Recommends bluechip investments")
async def test(ctx):
bluechip = ['TCS', 'Infosys', 'Reliance', 'M&M', 'Wipro', 'Bajaj Companies', 'MRF', 'Asian Paints']
recommend = f'Try investing in {random.choice(bluechip)}'
await ctx.send(recommend)
await ctx.send("Also check out the some of the Sensex Companies")
@bot.command(name="growth", help="Recommends growth stocks")
async def growth(ctx):
risky = ['Adani Ent', 'Adani Ports', 'Adani Power', 'Alkyl Amine', 'Navin Fluorine', 'Balaji Amines', 'Apollo Hospital', 'Britannia', 'Titan Company', 'HAL']
recommend = f'Try investing in {random.choice(risky)}'
await ctx.send(recommend)
await ctx.send("Also check out the rest of the Nifty MidCap 100 Companies")
@bot.command(name="returns", help="Enter the bought price then the CMP to get Profit%. <x>=bought <y>=cmp")
async def returns(ctx, x, y):
x = float(x)
y = float(y)
profit = y - x
percent = (profit / x) * 100
await ctx.send("Your return on this investment is: " + str(percent) + "%")
@bot.command(name="price", help="Enter the BSE stock code to get the price, change%. <code>=stock code")
async def returns(ctx, code):
quote = b.getQuote(code)
current = quote["currentValue"]
share = quote["companyName"]
change_percent = quote["pChange"]
await ctx.send(share +" : " + str(current))
await ctx.send("Change % today: " + str(change_percent) + "%")
await ctx.send("Price updated on: " + quote["updatedOn"])
with open("BOT_TOKEN.txt", "r") as token_file:
TOKEN = token_file.read()
print("Token file read")
bot.run(TOKEN)