Project Documentation: TradeMemory An AI-Powered Persistence Layer for Disciplined Trading Tech Stack: MERN + Groq (Qwen-3) + Hindsight Cloud Vector SDK.
Abstract in the high-stakes world of intraday and swing trading, the greatest enemy isn't the market—it’s the "Trader’s Amnesia."
As students of Data Science and Engineering, we know that data is useless unless it is retrievable and actionable. TradeMemory is a full-stack terminal application that solves the behavioral gap in trading. By integrating Large Language Models (LLMs) with a high-performance Vector Database (Hindsight Cloud), we have built a system that doesn't just "log" trades but "remembers" the psychological and technical context of every market move.The Problem Statement: The "Spreadsheet Graveyard "Most retail traders in India use Excel or manual journals. These methods have three critical engineering failures: Zero Searchability: You cannot ask an Excel sheet, "How did I feel the last time I traded Zomato on a Tuesday? "Friction: Manual logging is boring. Traders stop doing it after a losing streak no Feedback Loop: Static data doesn't provide real-time warnings before a trader commits a repetitive mistake. TradeMemory addresses these by providing a "Command Line Interface" (CLI) style terminal that uses Natural Language Processing (NLP) to turn conversational input into structured, vectorized memory.
System Architecture & "The Hooks "The project is built on a decoupled architecture, ensuring that the AI reasoning and the memory storage are independent yet synchronized. A. The "Recall-Process-Store" Pipeline This is the core "Hook" of our backend logic. Unlike standard chatbots that start with a blank slate, TradeMemory follows a three-step execution flow: Semantic Recall (Hindsight SDK): Before the AI responds, the system takes the user's input and performs a vector search in the Hindsight Bank. It retrieves the top $K$ most relevant past experiences. Context Injection (Groq/Qwen): These memories are injected into the System Prompt. The LLM now has "Hindsight." It knows your past wins and your "Lakhs" of losses. Dynamic Storage: After the AI replies, the conversation is analyzed. If the system detects a "Win" or "Loss," it tags the metadata and stores it permanently. B. Silent Reasoning Hook We utilize the Qwen-3 32B model via the Groq API. One specific engineering hook we implemented is "Silent Reasoning." Using Regex filters in agent.js, we strip out blocks. This ensures the user sees a professional, clean "Mentor" response while the model does the heavy lifting of analyzing market psychology in the background.
Key Features & Functionality1. Natural Language Trade Logging instead of filling out 10 columns in a table, the user types: "Just booked 20k profit on Tata Motors, felt very disciplined today." * The Hook: The backend uses string pattern matching and LLM intent recognition to categorize this as a trade_log.2. Live Stats Dashboard (Real-Time Analytics)The frontend features a terminal-style Stats bar. Wins/Losses: Calculated dynamically by filtering the Hindsight bank for metadata tags. Win Rate: A real-time calculation: $WinRate = (\frac{Wins}{Total Trades}) \times 100$.3. "Mental Model" Reflection using the Hindsight Client’s create Mental Model capability, the project can generate a "Trader Persona." It looks at 50 trades and concludes: "User Rajan is profitable on Blue Chip stocks but loses money during mid-cap volatility."
Zero-Exposure Security as B. Tech students, security is a priority. We implemented a strict backend proxy. The Hindsight API Key and Groq Key are never exposed to the client-side (Frontend). All communication happens via a secure Node.js middleware.Technical Implementation (The "Deep Dive")The Frontend (React.js)The UI is designed to look like a high-end trading terminal (Dark Mode, Monospace fonts).Quick actions.jsx: Provides pre-filled prompts to reduce user friction. State Management: Uses React use effect hooks to trigger a refresh stats() call every time a new memory is stored, ensuring the UI is always in sync with the database. The Backend (Node.js & Express)Hindsight SDK Integration: We moved away from manual fetch calls to the official @vectorize-io/hindsight-client. This allows for robust error handling and faster vector indexing. Agent Logic: The run agent function in agent.js is the "Brain." It manages the conversation history and ensures the LLM stays in the "Trading Mentor" persona. The Database (Vector Embedding)Instead of a traditional SQL/NoSQL database, we use Vector Embeddings. Each trade log is converted into a mathematical vector (a list of numbers representing meaning).Why? Because if you search for "Reliance," it will also find "RIL" or "Blue chip trade" because they are semantically similar in the vector space.
Challenges Overcome The "Static Stats" Bug: Initially, the dashboard stayed at 0. We solved this by implementing a metadata tagging system where the AI "labels" its own memories before saving them. API Latency: By switching to Groq's LPU (Language Processing Unit) inference, we reduced response times from 5 seconds to sub-500ms.Hallucination Control: We used strict System Prompting to prevent the AI from giving financial advice. It is a "Journaling Assistant," not a "Financial Advisor."
Future Roadmap (The "Vision")As we move toward a production-ready version, the next steps are: Automated Risk Calculation: Integrating with Zerodha/AngelOne APIs to automatically pull trade data.Voice-to-Memory: Allowing traders to log trades via voice commands while they are driving or away from the screen. Multi-Market Intelligence: Specific "Context Banks" for NSE (India), NYSE (USA), and Crypto.
Conclusion TradeMemory is more than just a project; it’s a proof-of-concept for how Memory-Augmented AI can improve human performance in high-pressure environments. By building this, we have demonstrated proficiency in Full-Stack Development, Vector Databases, and Prompt Engineering.
Top comments (0)