stockbot-on-groq
StockBot powered by Groq: Lightning Fast AI Chatbot that Responds With Live Interactive Stock Charts, Financials, News, Screeners, and More. Powered by Llama3-70b on Groq, Vercel AI SDK, and TradingView Widgets.
Top Related Projects
The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.
🦜🔗 Build context-aware reasoning applications
JARVIS, a system to connect LLMs with ML community. Paper: https://arxiv.org/pdf/2303.17580.pdf
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Quick Overview
Stockbot-on-Groq is a project that demonstrates how to build a stock trading bot using the Groq API. It showcases the integration of financial data analysis with Groq's language model capabilities to make trading decisions based on market trends and news sentiment.
Pros
- Demonstrates practical application of AI in financial trading
- Utilizes Groq's powerful language model for real-time decision making
- Provides a framework for integrating multiple data sources (market data, news)
- Offers potential for customization and expansion for different trading strategies
Cons
- Limited documentation and setup instructions
- Relies heavily on external APIs and services, which may have usage limits or costs
- Potential for financial risk if used without proper understanding and safeguards
- May require frequent updates to maintain accuracy with changing market conditions
Code Examples
# Example 1: Initializing the Groq client
from groq import Groq
client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)
# Example 2: Generating a trading decision based on market data and news
chat_completion = client.chat.completions.create(
messages=[
{
"role": "system",
"content": "You are an AI stock trading assistant. Analyze the given market data and news to make a trading recommendation.",
},
{
"role": "user",
"content": f"Market Data: {market_data}\nNews: {news}\nMake a trading recommendation for {symbol}.",
}
],
model="mixtral-8x7b-32768",
temperature=0.5,
max_tokens=1000,
top_p=1,
stream=False,
stop=None
)
# Example 3: Executing a trade based on the AI recommendation
if "buy" in recommendation.lower():
execute_buy_order(symbol, quantity)
elif "sell" in recommendation.lower():
execute_sell_order(symbol, quantity)
else:
print("No action taken based on current recommendation.")
Getting Started
-
Clone the repository:
git clone https://github.com/bklieger-groq/stockbot-on-groq.git cd stockbot-on-groq
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
export GROQ_API_KEY=your_groq_api_key export ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key
-
Run the main script:
python main.py
Note: Ensure you have necessary API keys and understand the financial risks before running the bot with real trading capabilities.
Competitor Comparisons
The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.
Pros of chatgpt-retrieval-plugin
- More comprehensive documentation and setup instructions
- Broader application scope for general document retrieval and Q&A
- Active development with frequent updates and contributions
Cons of chatgpt-retrieval-plugin
- More complex setup and configuration required
- Less specialized for stock-related queries and financial data
- Potentially higher resource requirements due to its broader scope
Code Comparison
stockbot-on-groq:
def get_stock_data(symbol):
url = f"https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={symbol}&apikey={API_KEY}"
response = requests.get(url)
data = response.json()
return data["Global Quote"]
chatgpt-retrieval-plugin:
def get_document_by_id(datastore: DataStore, doc_id: str) -> Optional[Document]:
try:
return datastore.get_document(doc_id)
except Exception as e:
logger.error(f"Error getting document {doc_id}: {e}")
return None
The stockbot-on-groq code focuses on retrieving stock data from a specific API, while the chatgpt-retrieval-plugin code is more generic, handling document retrieval from a datastore. This reflects the specialized nature of stockbot-on-groq compared to the more versatile chatgpt-retrieval-plugin.
🦜🔗 Build context-aware reasoning applications
Pros of langchain
- More comprehensive framework for building LLM-powered applications
- Larger community and ecosystem with extensive documentation
- Supports multiple LLM providers and integrations
Cons of langchain
- Steeper learning curve due to its broader scope
- May be overkill for simple, specific use cases like stock analysis
- Requires more setup and configuration
Code Comparison
stockbot-on-groq:
response = groq.chat.completions.create(
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
],
model="mixtral-8x7b-32768",
temperature=0.5,
max_tokens=1000,
top_p=1,
stream=True
)
langchain:
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
llm = OpenAI(temperature=0.5)
prompt = PromptTemplate.from_template("Analyze the stock: {stock}")
chain = prompt | llm
response = chain.invoke({"stock": "AAPL"})
The stockbot-on-groq example shows direct interaction with the Groq API, while the langchain example demonstrates its abstraction layer for working with different LLMs and prompt templates.
JARVIS, a system to connect LLMs with ML community. Paper: https://arxiv.org/pdf/2303.17580.pdf
Pros of JARVIS
- More comprehensive AI assistant framework with broader capabilities
- Larger community and support from Microsoft
- Extensive documentation and examples for implementation
Cons of JARVIS
- More complex setup and configuration required
- Potentially higher resource requirements due to broader scope
- May include unnecessary features for specific use cases like stock trading
Code Comparison
JARVIS (Python):
from jarvis import Jarvis
jarvis = Jarvis()
response = jarvis.process("What's the weather like today?")
print(response)
stockbot-on-groq (Python):
from stockbot import StockBot
bot = StockBot()
prediction = bot.predict_stock("AAPL")
print(prediction)
The JARVIS code snippet demonstrates a more general-purpose AI assistant, while the stockbot-on-groq code is specifically tailored for stock predictions. JARVIS offers a broader range of functionalities, whereas stockbot-on-groq is more focused on its specific use case.
Both projects utilize Python, making them accessible to a wide range of developers. However, JARVIS likely requires more setup and configuration due to its broader scope, while stockbot-on-groq may be more straightforward to implement for stock-related tasks.
Pros of TaskMatrix
- More comprehensive and versatile, designed for a wide range of tasks beyond stock analysis
- Utilizes multiple AI models and tools for enhanced capabilities
- Supports multimodal interactions, including image processing and generation
Cons of TaskMatrix
- More complex setup and dependencies due to its broader scope
- Potentially higher computational requirements and slower execution for simple tasks
- Less specialized for stock-related tasks compared to StockBot on Groq
Code Comparison
TaskMatrix:
def execute_command(self, command):
tool = self.get_tool(command['name'])
if tool:
return tool.run(command['args'])
else:
return f"Tool {command['name']} not found."
StockBot on Groq:
def get_stock_data(symbol):
url = f"https://query1.finance.yahoo.com/v8/finance/chart/{symbol}"
response = requests.get(url)
data = response.json()
return data['chart']['result'][0]['meta']
TaskMatrix offers a more generalized approach to executing various commands using different tools, while StockBot on Groq focuses specifically on retrieving stock data from Yahoo Finance. The TaskMatrix code snippet demonstrates its flexibility in handling different tools, whereas StockBot on Groq's code is tailored for efficient stock data retrieval.
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Pros of DeepSpeed
- Highly optimized for large-scale distributed training of deep learning models
- Supports a wide range of hardware configurations and model architectures
- Extensive documentation and active community support
Cons of DeepSpeed
- Steeper learning curve due to its complexity and advanced features
- Primarily focused on training, with less emphasis on inference optimization
- May be overkill for smaller projects or simpler model deployments
Code Comparison
DeepSpeed:
import deepspeed
model_engine, optimizer, _, _ = deepspeed.initialize(
args=args,
model=model,
model_parameters=params
)
stockbot-on-groq:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-neox-20b")
DeepSpeed focuses on distributed training initialization, while stockbot-on-groq uses standard Hugging Face transformers for model loading. DeepSpeed offers more advanced optimization techniques, but stockbot-on-groq provides a simpler interface for quick model deployment.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
StockBot Powered by Groq: Lightning Fast AI Chatbot that Responds With Live Interactive Stock Charts, Financials, News, Screeners, and More
Overview ⢠Features ⢠Interfaces ⢠Quickstart ⢠Credits
Demo of StockBot providing relevant, live, and interactive stock charts and interfaces
Overview
StockBot is an AI-powered chatbot that leverages Llama3 70b on Groq, Vercelâs AI SDK, and TradingViewâs live widgets to respond in conversation with live, interactive charts and interfaces specifically tailored to your requests. Groq's speed makes tool calling and providing a response near instantaneous, allowing for a sequence of two API calls with separate specialized prompts to return a response.
[!IMPORTANT] Note: StockBot may provide inaccurate information and does not provide investment advice. It is for entertainment and instructional use only.
Features
- ð¤ Real-time AI Chatbot: Engage with AI powered by Llama3 70b to request stock news, information, and charts through natural language conversation
- ð Interactive Stock Charts: Receive near-instant, context-aware responses with interactive TradingView charts that host live data
- ð Adaptive Interface: Dynamically render TradingView UI components for financial interfaces tailored to your specific query
- â¡ Groq-Powered Performance: Leverage Groq's cutting-edge inference technology for near-instantaneous responses and seamless user experience
- ð Multi-Asset Market Coverage: Access comprehensive data and analysis across stocks, forex, bonds, and cryptocurrencies
Interfaces
Description | Widget |
---|---|
Heatmap of Daily Market Performance Visualize market trends at a glance with an interactive heatmap. | |
Breakdown of Financial Data for Stocks Get detailed financial metrics and key performance indicators for any stock. | |
Price History of Stock Track the historical price movement of stocks with customizable date ranges. | |
Candlestick Stock Charts for Specific Assets Analyze price patterns and trends with detailed candlestick charts. | |
Top Stories for Specific Stock Stay informed with the latest news and headlines affecting specific companies. | |
Market Overview Shows an overview of today's stock, futures, bond, and forex market performance including change values, Open, High, Low, and Close values. | |
Stock Screener to Find New Stocks and ETFs Discover new companies with a stock screening tool. | |
Trending Stocks Shows the top five gaining, losing, and most active stocks for the day. | |
ETF Heatmap Shows a heatmap of today's ETF market performance across sectors and asset classes. |
Quickstart
[!IMPORTANT] To use StockBot, you can use a hosted version at groq-stockbot.vercel.app. Alternatively, you can run StockBot locally using the quickstart instructions.
You will need a Groq API Key to run the application. You can obtain one here on the Groq console.
To get started locally, you can run the following:
cp .env.example .env.local
Add your Groq API key to .env.local, then run:
pnpm install
pnpm dev
Your app should now be running on localhost:3000.
Changelog
See CHANGELOG.md to see the latest changes and versions. Major versions are archived.
Credits
This app was developed by Benjamin Klieger at Groq and uses the AI Chatbot template created by Vercel: Github Repository.
Top Related Projects
The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.
🦜🔗 Build context-aware reasoning applications
JARVIS, a system to connect LLMs with ML community. Paper: https://arxiv.org/pdf/2303.17580.pdf
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot