\documentclass[11pt, a4paper]{article}
\usepackage[a4paper, top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
% --- PDFLATEX COMPATIBLE FONT PACKAGES --- \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} % Provides a clean Latin Modern font
% --- REQUIRED PACKAGES --- \usepackage{amsmath} % For mathematical equations \usepackage{setspace} % For line spacing adjustments \usepackage{hyperref} % For clickable links (must be last in this section)
\begin{document}
\begin{center} {\LARGE \textbf{Adaptive Quant Co-Pilot}} \[0.2cm] {\Large \textit{A Safety-First Agentic Trading Assistant}} \end{center}
\vspace{0.5cm}
\section*{Inspiration} Picture this: You are resting between heavy sets at the gym, your phone buzzes with a market alert, and suddenly you are trying to calculate position sizing on a phone calculator. The predictable result? Emotional trades, missed exit points, and completely ignoring the strict risk rules you established when your mind was calm.
Sticking to a trading strategy in real-time is incredibly difficult when balancing a busy life. Furthermore, conducting deep equity research takes hours of sifting through market noise that most people simply do not have. I wanted to solve this by building an agentic trading co-pilot to act as an institutional risk desk and quant analyst sitting right in your pocket.
The goal was to build a system that acts as an immutable psychological anchor. It keeps you disciplined, summarizes relevant stock news in seconds (saving massive amounts of time), and ensures zero math mistakes during distracted moments.
\section*{What it does} Adaptive Quant Co-Pilot is a Telegram-based, safety-first trading assistant. It audits simulated equity trades against an immutable risk contract, explains the result, and tracks your trading habits using behavioral telemetry.
It never auto-trades. Instead, it acts as a conversational gatekeeper and a psychological mirror. Every action, audit, and market snapshot is securely recorded in a chat-scoped SQLite journal. By analyzing this behavioral data, the bot can spot your worst habits and strategy drift. For example, if you ask for a behavioral report, the assistant can query your journal and reply: \textit{``You have overridden the risk engine on 5 stocks this month. On average, those overridden trades performed 10\% worse than the trades strictly approved by your strategy.''}
When you attempt to make a trade, the bot intercepts the command and runs a deterministic risk audit. It checks the live quote, calculates the Average True Range (ATR) stop, validates momentum, and ensures the position fits within predefined portfolio caps. Only if the trade mathematically complies with your static \texttt{vault.json} contract will it generate an Alpaca Paper order---and even then, it requires explicit double-confirmation from the user.
\section*{How I built it} During development, I heavily utilized next-generation AI coding tools to accelerate my workflow. I used \textbf{Codex 5.5 SOL} for the initial architectural planning and system design, while relying on \textbf{Terra} primarily for the heavy lifting of writing the code.
The architecture relies on a strict separation of concerns between fast AI classification, deterministic financial execution, and bounded LLM reasoning. Rather than giving a language model direct access to brokerage APIs, the information flows through a strictly gated loop:
\begin{enumerate}
\item \textbf{User Input (Telegram):} The user sends a natural language message (e.g., Buy 10 shares of AAPL'' orWhy is TSLA dropping?'').
\item \textbf{Fast Classification:} A lightweight model (\texttt{GPT-4o-mini}) instantly categorizes the user's intent (e.g., audit request, behavioral report, news breakdown) without ever accessing account credentials.
\item \textbf{Parallel Data Gathering (MCP):} Based on the intent, the Python orchestration layer concurrently pulls read-only evidence:
\begin{itemize}
\item \textbf{Quant Engine:} Fetches live Alpaca quotes and historical bars to compute technical indicators deterministically.
\item \textbf{Equity & News Specialist:} A local Model Context Protocol (MCP) agent retrieves quarterly fundamentals and recent headlines from \texttt{yfinance}, filtering out noise to extract concrete catalysts.
\item \textbf{Journal Database:} Pulls recent chat-scoped behavioral telemetry from SQLite.
\end{itemize}
\item \textbf{Main Brain Synthesis:} The main reasoning model (\texttt{GPT-4o}) receives this compact, request-scoped packet. It synthesizes the technicals, fundamentals, and strategy rules into a concise Telegram explanation. It never receives direct order-placement capabilities.
\item \textbf{Deterministic Audit:} If a trade is requested, Python deterministically checks the live broker data against the hard risk rules. If compliant, a risk card is sent to Telegram requiring explicit confirmation before a Paper order is submitted.
\end{enumerate}
\section*{Challenges I ran into} The biggest challenge was architecting the ``Zero-Trust'' LLM boundary. Initially, the temptation with AI agents is to give the model access to all broker APIs and database tables.
However, language models frequently hallucinate numbers and struggle with strict boundary conditions. I had to design a parallel read manager in Python that gathers market context concurrently and feeds \textit{only} the necessary facts to the reasoning model. Preventing the LLM from silently resizing orders or attempting to bypass a failed vault condition required strict state-machine enforcement. Furthermore, parsing natural language into bounded watchlist mutations without writing brittle Regex rules required heavy prompt engineering and schema validation.
\section*{Accomplishments that I'm proud of} More than anything, I am incredibly proud of the simple fact that \textbf{it actually works and is genuinely useful}. In the world of AI agents, it is very easy to build a fragile prototype, but building a system that is accurate, reliable, and safe enough to use daily was a huge milestone for me.
I successfully implemented the Model Context Protocol (MCP) to isolate the AI's reasoning from the broker's execution, ensuring zero hallucinations in the math. Turning 45 minutes of manual news and chart research into a 5-second, highly accurate Telegram audit is a massive quality-of-life improvement that I can start using immediately.
\section*{What I learned} Building this reinforced my belief that the future of agentic AI in finance relies on strict tool-calling boundaries. \begin{itemize} \item \textbf{AI explains, Python executes:} Keeping execution deterministic prevents rogue trades while keeping the user experience conversational. \item \textbf{Telemetry cures bad habits:} Tracking non-Euclidean user behavior in a simple SQLite journal proved to be incredibly effective. Seeing hard data on how your emotional overrides underperform your own strategy is a powerful psychological deterrent against undisciplined trading. \end{itemize}
\section*{What's next for Adaptive Quant Co-Pilot} My immediate roadmap includes: \begin{itemize} \item \textbf{Dynamic Strategy Suggestions:} Currently, the \texttt{vault.json} strategy is static. I plan to expand the system to detect shifting market regimes. If a particular situation arises (e.g., high market-wide volatility where the current momentum strategy is expected to perform poorly), the co-pilot will proactively suggest optimized, alternative strategies to load into the vault. \item \textbf{Next-Gen Native Reasoning:} Direct integration with native reasoning models (like the incoming \texttt{o4} or \texttt{GPT-5.6} APIs) to further sharpen the analytical brain without altering the risk code. \item \textbf{Multi-Broker Auth:} Expanding the MCP risk boundary beyond Alpaca to support secure OAuth flows for live brokers like Interactive Brokers. \end{itemize}
\end{document}
Built With
- api
- llm
- mcp
- python
Log in or sign up for Devpost to join the conversation.