Add Live Stock Data to crewAI using LangChain custom tools and store results in Obsidian
AI Summary
Tutorial Summary: Adding Custom Tools to Crew AI
Custom Tool Integration
- Tool 1: Connect Crew AI to portfolio to retrieve current positions.
- Tool 2: Fetch live market data for the latest stock prices.
- Tool 3: Save data into second brain using markdown tables.
Setup and Testing
- Use Jupyter notebook to test API for real-time stock prices.
- Crew AI agents work together to:
- Retrieve portfolio positions.
- Fetch current stock prices.
- Summarize data in markdown tables.
- Store tables in Obsidian.
Repository and Environment Setup
- Clone tutorial repository from
github.com/bus4a/crewA-ibkr
.- Create and activate a virtual environment.
- Install required packages from
requirements.txt
.Interactive Brokers API
- Use IB in sync wrapper library for API access.
- Ensure you have deposits or subscribe to services for live data.
- Access to both live and paper trading accounts.
- Adjust Global configuration API settings in the trading workstation.
Testing with Jupyter Notebook
- Import packages and connect to trading workstation.
- Fetch portfolio positions and real-time market data.
- Disconnect after testing.
Creating Custom Tools
- Add a Python file
custom_ibkr_tools.py
in the tools directory.- Implement custom functions using the Lang chain tool decorator.
- Functions include getting portfolio positions and fetching live stock prices.
Crew AI Setup and Execution
- Import custom tools and set up agents with specific goals.
- Define tasks and assign them to appropriate agents.
- Use a cheaper GPT model to save on tokens.
- Run the crew with
crew.kickoff
.Results in Obsidian
- New note created with portfolio positions and latest stock prices.
- Markdown table rendered correctly in Obsidian.
Disclaimer
- Information provided for educational purposes, not financial advice.
- Work with simulated accounts for testing.
Call to Action
- Visit the channel for more on multi-agent frameworks and custom functions.
- Subscribe and share comments.
Next Steps
- Add more functionality to Crew AI in future videos.
- Stay tuned for more finance and AI content.