import os
import discord
import requests
from discord.ext import commands
from dotenv import load_dotenv
import trade

# Discord bot token

# Alpha Vantage API key

# Define intents
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True

# Initialize the bot with intents
bot = commands.Bot(command_prefix='!', intents=intents)

async def on_ready():
    print(f'We have logged in as {client.user}')

About this template

The bot requires certain permissions to function properly. These include the ability to read message history, send messages, and react to messages. The bot will generate stats such as This bot will provide ticker stats, commodity stats, Stock News and other AI Stock Trading Advice Please provide the Discord bot token in the Env Secrets tab under the name 'DISCORD_BOT_TOKEN' and your API Key for the Alpha Advantage

Introduction to the Stock AI Advice Discord Bot Template

This template provides a comprehensive solution for creating a Discord bot that can offer stock advice, generate stock charts, compare stocks, and execute a Bollinger Band strategy. It's designed to help users make informed decisions about stock trading by providing real-time data and visualizations directly within Discord.

Getting Started with the Template

To begin using this template, click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy or paste any code manually.

Initial Setup: Adding Environment Secrets

Before you can use the bot, you'll need to set up some environment secrets within the Lazy Builder. These are necessary for the bot to interact with the Discord API and the Alpha Vantage API for stock data.

  • DISCORD_BOT_TOKEN: This is the token you receive from Discord when you create a new bot. You can obtain it from the Discord Developer Portal.
  • ALPHA_VANTAGE_API_KEY: This is the API key for accessing Alpha Vantage's stock data. You can get this key by signing up on the Alpha Vantage website.

To add these environment secrets:

  1. Go to the Environment Secrets tab within the Lazy Builder.
  2. Click on "Add Secret" and enter 'DISCORD_BOT_TOKEN' as the name and paste your Discord bot token as the value.
  3. Repeat the process for 'ALPHA_VANTAGE_API_KEY' using your Alpha Vantage API key.

Test: Pressing the Test Button

Once you have set up the environment secrets, press the "Test" button in the Lazy Builder. This will deploy your application and launch the Lazy CLI. The CLI will prompt you for any required user input.

Entering Input: Filling in User Input

If the bot requires user input, such as a stock symbol or an interval for the Bollinger Band strategy, you will be prompted to provide this information through the Lazy CLI after pressing the "Test" button.

Using the App

After deployment, the bot will be live on Discord. You can interact with it using the commands specified in the code, such as:

  • !stockadvice [symbol] - to get advice on a specific stock symbol.
  • !chart - to generate a stock chart.
  • !EOD - to get end-of-day stock information.
  • !compare - to compare two stocks.
  • !bollinger - to apply the Bollinger Band strategy to a stock.

When you use these commands, the bot will respond with the requested information or actions directly in the Discord channel.

Integrating the App

If you wish to integrate this bot into an existing service or frontend, you may need to add the bot's server link provided by Lazy to your service. For example, if you have a web application that you want to send commands to the bot from, you would use the server link as the endpoint for your HTTP requests.

Remember to respect the command prefix and structure when sending requests to the bot. Additionally, ensure that the bot has the necessary permissions in your Discord server to read messages, send messages, and react to messages.

By following these steps, you can successfully set up and integrate the Stock AI Advice Discord Bot into your Discord server, providing valuable stock trading insights and tools to your community.

Last published
June 15, 2024

More templates like this

PDF Data Extraction and Excel Transfer

An app for extracting name, phone number, and email data from PDF files and transferring it to Excel.


Discord Ticketbot Template

A simple Discord Ticketbot for your Discord Support Department. This Template and Bot is fully customizable but already build so that you can use it right away. You need a bot token from for your bot to work. These are the steps needed to get your token: "1. 🌐 Go to the Discord Developer Portal. 🌐\n" + "2. 🆕 Create a new application and navigate to the 'Bot' section. 🤖\n" + "3. 📋 Under the 'TOKEN' section, click 'Reset Token' to get your Discord bot token and confirm by clicking 'Yes, do it'. 🔑\n" + "4. 🤖 If your bot will have any ability to read/reply to messages, then under the 'BOT' section, enable the slider titled 'Message Content Intent' ✅" + "5. 🔐 Set the 'DISCORD_BOT_TOKEN' in the Env Secrets tab with your bot token from step 3. 🔐\n" + "For bot permissions, it's recommended to start with basic permissions and adjust as needed for your app's functionality.🚀") If you encounter any bugs, please tell Lazy to fix them and report them on the Official Lazy AI Discord to @D4vidG4merLP. Credits: @meow - the Discord bot slash command template @mrlazy.notlazy - supporting me And the Biggest Thank you. You for using this template ❤️


GPT-4 Exam Generator

This app uses GPT-4 to generate a PDF of a new exam based on an uploaded PDF of a past exam.

Stock AI Advice