Building the First TradeObs AI Agent
Over the past several development sessions, Trade Observations crossed an important milestone. The project evolved from a collection of AI utilities into the foundation of a dedicated AI platform.
A Real Knowledge Base
The ingestion pipeline now contains:
- 15,052 AI analysis events
- 59,323 semantic chunks
- 53,473 searchable tags
Every chunk was embedded using text-embedding-3-small and stored in PostgreSQL with pgvector.
The embedding job completed successfully:
- 59,323 chunks embedded
- Approximately 6.15 million tokens
- About $0.12 in embedding cost
- Zero missing embeddings
Semantic Search
Natural-language questions are converted into embeddings and compared against every historical observation.
Instead of matching keywords, the system retrieves the most semantically similar historical analyses, including:
- Context
- Patterns
- Probability
- Entries and avoidance
- Exit warnings
- Chart references
FastAPI as the AI Service
TradeObs AI now exposes:
GET /healthGET /searchPOST /chat
The chat endpoint performs retrieval before calling the language model, grounding every response in historical Trade Observations data.
From API to Agent
The biggest architectural improvement was moving intelligence out of the API layer.
FastAPI
│
▼
TradeObsAgent
│
├── RetrievalAgent
├── ReviewAgent
└── OpenAI
The API now focuses on HTTP, while the agent orchestrates retrieval, prompt construction, and reasoning.
Specialized Agents
RetrievalAgent
Responsible for semantic search and returning the best historical evidence.
ReviewAgent
Responsible for retrieving review information and exit warnings for historical snapshots.
Although review labels are not yet populated, the framework is ready for the next evolution.
The Vision
The question driving this project is no longer:
"What pattern is this?"
Instead it is:
"What usually happened after this pattern?"
That answer will eventually combine:
- historical observations
- structured review labels
- outcome statistics
- Academy lessons
- notebook context
Example Command
python -c "from agents.tradeobs_agent import tradeobs_agent; r = tradeobs_agent.ask('bull spike pullback EMA L2 sell', limit=2); print(r['answer'][:800]); print(len(r['matches']))"
Example Response
The term "bull spike pullback EMA L2 sell" relates to a scenario where there is a bullish spike or breakout often pushing above an EMA, followed by a pullback, and consideration of a level 2 (L2) sell setup on the pullback.
Looking at the retrieved historical examples:
- Example #2 (Snapshot 76630) describes a bull spike/pullback near the EMA after a range or bear leg. Here, after a strong bull breakout (bull spike) above the EMA, the appropriate approach was to look for a with-trend buy on the first pullback above the EMA (H1/H2 buy), rather than a sell. Avoid shorting unless a clear reversal or failed breakout occurs.
This example highlights that after a bull spike, a pullback can be a good place for bullish entries if the price remains above EMA. No clean L1/L2 sell signals were prese...
What's Next
The next phase will focus on integrating the AI into the website through a chatbot, building a protected administration portal, and expanding the growing family of specialized agents.
Trade Observations is steadily evolving into a continuously learning market knowledge platform where every reviewed decision improves future AI responses.