Simple Discord Stock Bot

in python •  6 years ago 

Find this project on my GitLab

Find this project on my Blog

Description

Super simple Discord Bot wrote in Python for displaying the price of a stock, or news about a stock quickly and easily.

Motivation

Google Allo is disappearing in March 2019 so me and my friends who use it for talking about stocks need a replacement. Allo has a feature that allows you to talk to the Google Assitant right in the chat which makes pulling up a news article or a stock quote in chat extremely easy. This bot aims to replace that specific functionality.

Features

The bot checks every message for tickers which can be called by putting a dollar sign in front of the stock symbol like this: $tsla The bot is pretty smart and can handle as many tickers in a message as you put in.

For example the message:

I want to know about $tsla $djia $f $aaxn $baba $amzn

Will output:

Discord-Bot-Stock-Price-Example

The bot can also quickly give you news links about any tickers you need. Simply putting !news in front of your message like this:

!news $tsla

Will output:

Discord-Bot-Stock-News-Example

The news feature also works with as many tickers as you want to put in a message at once for example: !news I want to know about $tsla $amzn

How it works

The most important part of the project is discord.py which is an API wrapper for Discord written in Python. discord.py made this project a breeze.

The other important part is the Bravos API which is used to get the current quote for the provided ticker. The API works perfectly and is free with an account.

The news sources are currently hardcoded, and the code simply puts the stock ticker into a URL where its needed to get a page on that specific ticker. The image of the company that is shown in the embeds are taken from Motley Fool without an official API. There's probably a better way to get the images but I couldn't find one easily.

Installation

  • Follow install instructions for discord.py without full voice support.
  • Follow directions in credentials.py
    • Get Discord Token Here > BOTNAME > Bot > 'copy token'
    • Get Bravos API key Here after you make a free account
  • Run stockBot.py

Contribute

This project probably won't get additional development since I decided to use Telegram instead of Discord for group messaging, but if you would like add anything feel free to make your own clone repo, or you can contact me and maybe get a pull request going. Would also love to hear about all the things I did wrong in my code<3

License

In laymen (not a substitute for the actual license) you can do whatever you want with this project as long as you also share it, and give me credit.

Creative Commons License
by Anson Biggs is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Based on a work at https://gitlab.com/MisterBiggs/simple-discord-stock-bot.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hello @misterbiggs! This is a friendly reminder that you have 3000 Partiko Points unclaimed in your Partiko account!

Partiko is a fast and beautiful mobile app for Steem, and it’s the most popular Steem mobile app out there! Download Partiko using the link below and login using SteemConnect to claim your 3000 Partiko points! You can easily convert them into Steem token!

https://partiko.app/referral/partiko

Congratulations @misterbiggs! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!