DEV Community

Derrick Sherrill for WayScript

Posted on

Using WayScript to Automatically Monitor Volatile Stocks

Introduction

The stock market has become all the rage recently, so in this article we’re going to take a look at how to create an automated script that tracks volatile stocks and provides updates of their status. This is a pretty quick and easy script that could result in big returns. Keep reading to learn more!

Building our Script

The first step in this script is adding a Time Trigger module. This module triggers the script to run at a specified time interval. We could set the interval to every minute, ten minutes, and so forth. Since we’re tracking volatile stocks, we’ll set the interval in this example to every minute.

Next, we’ll add a Python module and enter code that gathers information on our stock and passes it. You can find pre-written code on our GitHub for this example, or you can simply clone this script and use the code there. We’ll run through the lines of code so you can see what is occurring.

tutorial step #1

The first three lines of code import the pandas and Alpha Vantage libraries; the Alpha Vantage library is where we’ll pull stock market information from. The next line provides the API code for Alpha Vantage (disclaimer: Alpha Vantage may shut down this API code if you overuse it, so you may need to get your own from their website). The next few lines of code perform some general calculations on the data. The last lines tell the script to create a variable when there’s a 0.5% change in the last minute.

Now that we have this code, when we run it the variable that we created will appear as a stored WayScript variable. We’ll then add a Gmail module. In this module, we’ll link our accounts and then drag this variable into the “Email Body” text box. Once we activate the Time Trigger, the script will send us an email every minute if the stock experiences a 0.5% change within the previous minute.

This is an easy script to make if you want to stay up to date on your stocks without constantly checking your market apps. By getting a notification every time something major happens, you can spend more time focusing on other things. Now, you’ll never miss an opportunity to make informed decisions on your volatile stocks.

Conclusion

Questions about this script or anything else? Join our discord. We're always around to help. If you want to work the full script template, just find it here. To use the code for this script, find it here on our GitHub.

Top comments (0)