AI-powered stock analysis and investment recommendations using Langchain, Anthropic Claude, and real-time market data. Built with FastAPI and designed for both REST API and Agent-to-Agent (A2A) communication via the NEST framework.
- Natural Language Processing: Query stocks using company names or natural language
- Real-time Market Data: Current prices, volume, and 6-month historical data via Yahoo Finance
- AI-Powered Analysis: Investment recommendations with confidence scores using Claude
- Comprehensive Logging: Full audit trails and performance monitoring
- Agent Registry: Discoverable agent capabilities and information
- A2A Communication: NEST framework integration for agent-to-agent interactions
- REST API: Full-featured REST endpoints with OpenAPI documentation
- Python 3.9+ (Python 3.10+ recommended for MCP support)
- Anthropic API key
- Git
- Clone the repository:
git clone https://github.com/DataSup-Engineer/nasdaq-agent.git
cd nasdaq-agent- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # On macOS/Linux
# or
venv\Scripts\activate # On Windows- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp .env.example .env
nano .env # Edit with your configuration- Set required environment variables:
# Required
ANTHROPIC_API_KEY=sk-ant-your-api-key-here
ANTHROPIC_MODEL=claude-3-haiku-20240307
# Optional - NEST A2A
NEST_ENABLED=true
NEST_PORT=6000
NEST_PUBLIC_URL=http://localhost:6000- Run the application:
python main.pyThe API will be available at http://localhost:8000
Analyze a stock:
curl -X POST http://localhost:8000/api/v1/analyze \
-H "Content-Type: application/json" \
-d '{"query": "What do you think about Apple stock?"}'Check health:
curl http://localhost:8000/healthView API documentation:
Open http://localhost:8000/docs in your browser
When NEST is enabled, the agent can communicate with other agents:
curl -X POST http://localhost:6000/a2a \
-H "Content-Type: application/json" \
-d '{
"role": "user",
"content": {
"type": "text",
"text": "Should I buy Tesla?"
},
"conversation_id": "test-123"
}'Available A2A commands:
/help- Show available commands/status- Check agent status/ping- Test connectivity- Stock queries - Natural language or ticker symbols
- "What do you think about Apple stock?"
- "Should I buy Tesla?"
- "Analyze Microsoft"
- "AAPL"
- "Tell me about NVDA"
All analysis responses include:
- Recommendation: Buy/Hold/Sell
- Confidence Score: 0-100
- Current Price: Real-time market data
- Market Data: Volume, 52-week range, historical performance
- Reasoning: Detailed analysis and key factors
- Risk Assessment: Identified risks and considerations
nasdaq-agent/
├── src/
│ ├── agents/ # LangChain agent implementations
│ ├── api/ # FastAPI application and routers
│ ├── config/ # Configuration management
│ ├── core/ # Core dependencies and utilities
│ ├── mcp/ # Model Context Protocol integration
│ ├── models/ # Data models and schemas
│ ├── nest/ # NEST A2A framework integration
│ └── services/ # Business logic and external services
├── tests/ # Test suite
├── logs/ # Application logs
├── main.py # Application entry point
└── requirements.txt # Python dependencies
Required:
ANTHROPIC_API_KEY- Your Anthropic API keyANTHROPIC_MODEL- Claude model to use (default: claude-3-haiku-20240307)
Application:
HOST- Server host (default: 0.0.0.0)PORT- Server port (default: 8000)DEBUG- Debug mode (default: false)
NEST A2A:
NEST_ENABLED- Enable NEST integration (default: false)NEST_PORT- A2A server port (default: 6000)NEST_PUBLIC_URL- Public URL for A2A endpointNEST_REGISTRY_URL- Agent registry URLNEST_AGENT_ID- Unique agent identifierNEST_AGENT_NAME- Human-readable agent name
See .env.example for complete configuration options.
For production deployment on AWS EC2, see the comprehensive DEPLOYMENT_GUIDE.md.
Quick deployment:
# On EC2 instance
git clone https://github.com/DataSup-Engineer/nasdaq-agent.git
cd nasdaq-agent
sudo ./deploy.shThe deployment script handles:
- System dependencies installation
- Python environment setup
- Service configuration
- Firewall setup
- Log rotation
- Systemd service creation
Docker support is planned for future releases.
# Run all tests
pytest
# Run with coverage
pytest --cov=src
# Run specific test file
pytest tests/test_agent_bridge_a2a.py# Format code
black src/ tests/
# Lint code
flake8 src/ tests/# Run with auto-reload
python main.py # Set DEBUG=true in .env
# Or use uvicorn directly
uvicorn main:main --reload --host 0.0.0.0 --port 8000GET /- API information and available endpointsGET /health- Health checkGET /status- Detailed system statusGET /docs- Interactive API documentation (Swagger UI)GET /redoc- Alternative API documentation (ReDoc)
POST /api/v1/analyze- Analyze a stock with natural language queryGET /api/v1/agent/info- Get agent information and capabilities
POST /a2a- Agent-to-Agent communication endpoint
Application logs are stored in logs/:
analyses.jsonl- Stock analysis requests and responseserrors.jsonl- Error logs
# Quick health check
./health_check.sh
# Detailed status
curl http://localhost:8000/statusWhen NEST is enabled, monitor A2A communication:
# Check NEST status
./scripts/monitor_nest.sh
# View A2A logs
tail -f logs/nest_a2a.logService won't start:
- Check
ANTHROPIC_API_KEYis set correctly - Verify port 8000 is not in use:
lsof -i :8000 - Check logs:
tail -f logs/errors.jsonl
NEST A2A not working:
- Verify
NEST_ENABLED=truein.env - Check port 6000 is open in firewall
- Ensure
python-a2ais installed:pip show python-a2a - Check NEST logs for errors
Import errors with python-a2a:
- Ensure you're using python-a2a 0.5.10+
- Verify imports use
run_servernotserve - Reinstall:
pip install --upgrade python-a2a
# Validate environment configuration
./validate_env.sh .env
# Test API endpoints
curl http://localhost:8000/health
curl http://localhost:8000/api/v1/agent/info- FastAPI - Modern web framework
- Uvicorn - ASGI server
- LangChain - LLM orchestration
- Anthropic - Claude AI integration
- yfinance - Market data
- Pydantic - Data validation
- python-a2a - NEST A2A framework (requires Python 3.10+)
- mcp - Model Context Protocol (requires Python 3.10+)
See requirements.txt for complete dependency list.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
[Add your license here]
For issues, questions, or contributions:
- Check the DEPLOYMENT_GUIDE.md for deployment issues
- Review logs in
logs/directory - Open an issue on GitHub
- Built with LangChain
- Powered by Anthropic Claude
- Market data from Yahoo Finance
- A2A communication via NEST Framework