An elite, high-performance full-stack portal built with Python FastAPI, SQLAlchemy ORM, Pydantic Validation, and a Bloomberg-inspired, industrial-utilitarian dashboard. This platform implements a decoupled, asynchronous multi-agent orchestration architecture powered by the OpenAI Agents SDK and managed with uv.
Rather than relying on a single monolithic prompt, this system enforces a strict separation of concerns among specialized execution nodes operating in sandboxed contexts. Data flows strictly via immutable message states.
[ USER / OPERATOR ]
β
βΌ
ββββββββββββββββββββββββββββββββ
β Master Trading Desk Router β ββββ [ FastAPI Web Gateway & Session Control ]
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ (Extracts parameters & timeframes)
ββββββββββββββββββββββββββββββββ
β Intraday/Swing Market Analystβ ββββ [ technical metrics, indicators: RSI, EMA ]
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ (Proposes trading parameters)
ββββββββββββββββββββββββββββββββ
β Risk Manager Agent β ββββ [ compliance audits: APPROVED / REJECTED ]
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ (Deterministic Overrides applied)
ββββββββββββββββββββββββββββββββ
β Neon PostgreSQL DB β ββββ [ Persists transaction logs & history ]
ββββββββββββββββββββββββββββββββ
- Role: Conversational Gateway, State Initiator & Interface Controller.
- Objective: Ingests raw user intent, validates asset token parameters, and guides the user through execution preferences.
- Rules: Standardizes tickers (
AAPLfor stocks,BTC-USDfor crypto) and restricts data fetching until both the asset identity and timeframe targets are locked in.
- Role: Quantitative & Technical Signal Synthesizer.
- Objective: Consumes mathematical indicator matrices, calculates moving averages (EMA/SMA), computes momentum vectors, and outputs high-fidelity summaries.
- Rules: Holds zero portfolio execution or transactional decision authority; never outputs buy/sell signals directly.
- Role: Capital Preservation & Compliance Audit Guardrail.
- Objective: Final automated gatekeeper that audits proposed operations against structural safety rules.
- Rules: Prefixes audits with
[APPROVED]or[REJECTED]and appends a single sentence of quantitative compliance justification.
- Premium Bloomberg-Inspired UI: Radial dark slate background (
#0B0F17), sleek panel styling (#131C2E), and absolute neon-accent high-contrast color codes. - Interactive Live SVG Candle Charting: Fetches actual real-time price candlesticks (using
yfinance) and dynamically wicks, scales, and plots candles inside the SVG container with a 10-second polling live update. - Quick-Select Asset Badges: Instantly targets leading tech assets (
AAPL,NVDA,TSLA,MSFT) and cryptocurrencies (BTC-USD,ETH-USD,SOL-USD) at the click of a button. - Strict Parameter Overrides: Integrates real-time compliance blocks. If the Risk Manager issues a
[REJECTED]verdict, the portal forces a strictHOLDoverride and updates position sizing allocations to0%to preserve capital. - State-of-the-Art Langfuse Telemetry: Tracks global traces the moment the user interacts with the desk, nests execution spans for each agent run, and captures final database insertion payloads.
- Secure Operator Portal: Full SQLAlchemy-backed authentication featuring custom-validated sign-ups (Pakistani/International cell validation, flexible 6+ character passwords) and password hashing with
passlib[bcrypt].
Data lookbacks and execution calculations automatically shift based on the strategy selected in the dashboard:
| Strategy Category | Timeframe | Lookback | Data Interval | Primary Indicators | Exit Bounds (Stop Loss / Take Profit) |
|---|---|---|---|---|---|
| Intraday Scalp | 15-Minute (15m) |
7 Days (7d) |
15m |
9-EMA, 21-EMA, RSI (14) | -1.0% / +2.0% |
| Intraday Swing | 1-Hour (1h) |
30 Days (30d) |
1h |
9-EMA, 21-EMA, RSI (14) | -2.5% / +5.0% |
| Medium Swing | 4-Hour (4h) |
60 Days (60d) |
4h |
50-MA, MACD, RSI (14) | -4.0% / +8.0% |
| Macro Position | 1-Day (1d) |
180 Days (180d) |
1d |
50-MA, 200-MA, Macro RSI | -8.0% / +15.0% |
Ensure you have Python 3.12+ and uv installed on your system.
git clone https://github.com/Ahmadthealdo/Automated-Multi-Agentic-Trading-System.git
cd Automated-Multi-Agentic-Trading-SystemRun the following uv command to create the virtual environment and install all web-hosting, validation, and multi-agent libraries:
uv pip install -r pyproject.toml
# Or install explicitly:
uv add fastapi uvicorn "pydantic[email]" "passlib[bcrypt]" psycopg sqlalchemy yfinance openai langfuseCreate a .env file in the root directory:
# Relational Neon PostgreSQL Connection String
DATABASE_URL=postgresql://<user>:<password>@<host>/<database>?sslmode=require
# OpenAI API Key for Multi-Agent Brain
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Langfuse Telemetry Tracing Keys
LANGFUSE_PUBLIC_KEY=pk-lf-xxxxxxxxxxxxxxxxxxxx
LANGFUSE_SECRET_KEY=sk-lf-xxxxxxxxxxxxxxxxxxxx
LANGFUSE_HOST=https://cloud.langfuse.comUpon application startup, FastAPI dynamically verifies relational tables and automatically handles any database column migrations (such as upgrading mobile_number to verified_phone on Neon PostgreSQL), making database setup 100% zero-configuration.
Launch the application locally in reloading development mode:
uvicorn main:app --reloadThe application will boot and host the interactive portal locally at http://127.0.0.1:8000.
Run our end-to-end multi-agent pipeline validation test in your terminal to verify databases, indicators, and agent outputs instantly:
python .agents/brain/8169d2e7-195f-482a-bf14-b5bf777313c9/scratch/validate_system.pyβββ .agents/ # System Agent workspace instructions & skills
βββ static/
β βββ app.js # Scaled SVG candle drawer & client logic
β βββ style.css # Utilitarian Bloomberg layout styles
βββ templates/ # Frontend views
βββ index.html # Core single-page operator dashboard
βββ main.py # FastAPI server routes & multi-agent execution pipeline
βββ schemas.py # Pydantic validation boundaries & schemas
βββ tools.py # yfinance quantitative extraction tools
βββ pyproject.toml # UV dependency declarations
βββ README.md # System documentation
- Abdul Qadeer Khan
- Ahmad Abdullah
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.