How to Build Free Stock Market Discord Alerts (Webhooks)

Overview

This post will walk you through setting up a free discord alert system that uses webhooks to send stock market notifications into your Discord server.

  • Create the webhook
  • Connect to the webhook with python
  • Build your algorithm
  • Send alerts into your server

Create the webhook

Go to your Discord server and then click on the channel where you want the alerts to go. Select “channel settings” and then create a new webhook, as well as turn on developer mode. Copy the webhook URL and you are ready to start building with it.

Connect to the webhook with python

Pip install discord, and then initialize your discord python client by importing the following module and calling the discord.Client() function.

At the bottom of your file, add client.run(“webhook_URL”) with the webhook URL you copied from the previous step inside quotations.

Now you are ready to build the loop that runs your algorithm, and sends alerts into the channel. Right click your channel in discord, and copy the channel ID to use in this next step.

This function will start a loop that runs infinitely and connects into a channel. The seconds variable is the pause time in-between each loop, and the client.get_channel is where you paste the numerical ID of the channel ID you just copied. Inside this main loop, you can make calls to the Styvio API to receive a list of all the supported tickers, then loop through it receive data for each stock.

Building your algorithm and sending alerts

This loop shows some code that we used to create our first iteration bot, that loops through every single stock with a 2 second delay, and alerts both discord and twitter if the RSI is low and the SMA just crossed over to positive. It also uses matplotlib to add a yearly chart of the stock with the discord message and tweet.

That is the overall process. At the end, I added some error checking but that goes over the entire logic of how to setup a custom discord alert system for stocks that meet your criteria. Get free access to the styvio API here.