Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

How I Built a Telegram AI Stock Assistant Using Llama 3 Groq Tool Use

1 min read

Watercolor illustration of a laptop and phone chat with stock charts for an AI stock assistant

In this post, I’ll show how I built a Telegram AI stock assistant, StockBot, as a follow-up to our Telegram bots course, using the Llama 3 Groq tool use models. The project uses fine-tuned AI models to give real-time stock market information through plain-language chat. You can watch the complete demonstration in the video linked below.

The StockBot uses the Llama 3 Groq models, specifically the llama3-groq-70b-8192-tool-use-preview model, known for its high performance on the Berkeley Function Calling Leaderboard. These models are designed for fast and efficient conversational AI, making them ideal for integration into messaging platforms like Telegram. This entire project was built using ChatGPT-4 and Claude 3.5 Sonnet.

Setting Up the Telegram AI Stock Assistant

Step 1: Choosing the Model

I opted for the llama3-groq-70b-8192-tool-use-preview model due to its superior performance and speed, which is particularly beneficial for short and fast conversations typically conducted on Telegram.

AI Bootcamp 2.0 for traders and investors

AI FOR TRADERS

AI Bootcamp 2.0 for traders and investors

Use ChatGPT, Claude and AI agents for research, coding and automation in your trading workflow.

  • Prompting and agent workflows for markets
  • Build tools without being a full-time coder
  • 6 courses in one bootcamp
See the bootcamp →by Marketcalls

Step 2: Creating the Bot

The bot, named “openstox” (Telegram bot ID: @openstoxbot), can be found on Telegram. Users can interact with it using natural language to request various stock-related information. The bot processes these queries using the Llama 3 Groq models to provide accurate and timely responses.

Features and Capabilities

Basic Commands

The bot can handle simple requests such as:

  • “Get me the Reliance stock price.”
  • “What was the Reliance stock price yesterday?”

It provides the current stock price, historical prices, and performance metrics based on the user’s query.

Advanced Queries

StockBot can also handle more detailed requests. For example:

  • “Get me the Apple intraday charts.”
  • “Show me the Tesla daily chart for the last 5 years in candlestick format.”

These commands retrieve and display comprehensive stock performance data and historical charts.

Handling Complex Queries

The bot is capable of processing complex queries that involve multiple stocks and customized charting. Users can specify parameters for technical indicators like EMA (Exponential Moving Average) and RSI (Relative Strength Index). For instance:

  • “Tesla daily chart for the last 5 years in candlestick format with EMA 10, EMA 30, and RSI 25.”

Multiple Stock Queries

Users can request information on multiple stocks simultaneously. For example:

  • “Get me the stock price of TCS, Infy, Apple, and Tesla.”

The bot quickly fetches and displays the current prices and performance data for all specified stocks.

Error Handling

While the bot generally handles queries smoothly, some stocks might not fetch data correctly on the first try. These cases usually work when queried individually.

The StockBot project shows how AI models like Llama 3 Groq can make stock market analysis simpler through natural language queries. With the bot inside Telegram, users can get quick, detailed stock information.

I hope this guide gives you ideas for using AI to automate your own financial analysis tasks. For a detailed demonstration, check out the video linked above. Feel free to reach out with any questions or comments.

Python Elite membership

MEMBERSHIP

Python Elite membership

15 Python, AI and algo trading programs in one plan, including QuantFlow and AI Bootcamp live mentorship.

  • Python from fundamentals to trading apps
  • Backtesting, broker APIs and OpenAlgo
  • Live QuantFlow and AI Bootcamp sessions
View Python Elite →by Marketcalls

Learn by watching: free videos every week

Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More