Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. 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. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

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

1 min read

In this post, I’ll walk you through the process of creating an intelligent Telegram AI assistant, StockBot, using the Llama 3 Groq tool use models. This project showcases the power of fine-tuned AI models in providing real-time stock market insights through natural language interaction. You can watch the complete demonstration in the video linked below.

The StockBot leverages 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 StockBot

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.

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.

Building Stock Market-Based Telegram Bots using Python

Build Python-powered bots using Claude and ChatGPT

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 demonstrates how powerful AI models like Llama 3 Groq can simplify and enhance stock market analysis through natural language processing. By integrating this bot into Telegram, users can get quick, detailed stock information effortlessly.

I hope this guide inspires you to explore the potential of AI in automating and enhancing your financial analysis tasks. For a detailed demonstration, check out the video linked above. Feel free to reach out with any questions or comments.

Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. 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. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

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