How sunnysavita10/agentic-trading-bot works
Project type and purpose
• This is a full-stack, AI-driven trading system written in Python.
• It exposes a FastAPI backend (main.py) and a Streamlit frontend (streamlit_ui.py).
• Core responsibilities: fetch real‐time market data, run ingestion pipelines, execute an “agent” workflow (trading logic + LLM prompts), and optionally persist/query embeddings via Pinecone or similar.
File structure
• Top-level:
• Pipfile/requirements.txt, setup.py – dependency & packaging
• main.py (FastAPI app)
• streamlit_ui.py (frontend)
• config/config.yaml & utils/config_loader.py
• Directories by layer:
• data_ingestion/ingestion_pipeline.py – ETL of market data
• data_models/models.py – Pydantic or ORM schemas
• agent/workflow.py – orchestrates decision logic + prompts
• prompt_library/prompt.py – prompt templates
• toolkit/tools.py – utility functions for trading & LLM
• utils/model_loaders.py – loads ML/LLM models or vector stores
• custom_logging & exception – cross‐cutting concerns for logging and errors
• fallback_data – local docs for offline use
• notebook – exploratory experiments (ipynb)
README for architecture hints
• Requires several external API keys (Polygon, Google, TAVILY, GROQ, Pinecone)
• Two entry points:
• uvicorn main:app (backend API)
• streamlit run streamlit_ui.py (frontend)
• Encourages logging, exception capturing, and eventual deployment.
a. Main components:
1. Client & UI Layer:
• Browser / user interacts with Streamlit UI
2. Frontend (Streamlit):
• Calls FastAPI endpoint(s) for data & trades
3. Backend (FastAPI App):
• HTTP API routes in main.py
• Dependency injection of config_loader, logger, exception handlers
4. Core Services:
• Data Ingestion Service
• Agent Workflow Service
• Prompt Library & Toolkit
5. Data Models Layer
6. External Services:
• Market Data APIs (Polygon, Google, TAVILY)
• LLM APIs (GROQ)
• Vector DB / Embeddings (Pinecone)
7. Fallback Data Store (local PDFs/docs) for offline mode
b. Relationships & interactions:
• Streamlit UI → FastAPI (REST calls)
• FastAPI routes → Services (via DI or direct calls)
• Data Ingestion → External Market APIs → normalized by data_models → passed to Agent
• Agent Workflow → prompt_library & toolkit → LLM APIs → receives suggestions/trade signals
• Agent → executes trades or writes results back via FastAPI response
• Optionally Agent or ingestion writes/query embeddings to Pinecone via model_loaders
• All components use custom_logging/my_logger and exception handlers
c. Architectural patterns & design principles:
• Layered (presentation, application, domain, infrastructure)
• Separation of concerns: ingestion vs. workflow vs. storage vs. UI
• Dependency Injection for config, logging, and exceptions
• Pluggable modules: prompt_library and toolkit abstract external LLM calls
d. Key technologies/frameworks:
• Python 3.10, FastAPI, Uvicorn
• Streamlit for UI
• Pydantic (data_models)
• YAML config, custom config_loader
• Third-party APIs (Polygon, GROQ, Pinecone)
• Local fallback docs