How candiedoutlaw763/stop_loss works
StopLoss is a financial intelligence terminal: a user submits a single-asset or portfolio question, the backend gathers market and event evidence, produces risk and hedge analysis, audits claims, and streams results to the terminal UI. The separate ingestion engine builds normalized, themed, deduplicated evidence and vector indexes. README statements support the major product flows; source excerpts and the SOURCE INDEX add implementation links. Some agent and ingestion details are documented but their implementation files were not sampled.
Main entry points: runner.py Ingestion lanes · service.py Analysis service · useChatStream.ts Chat stream · yfinance_client.py Yahoo market client
Components 26
Terminal interface
- Terminal UI
frontend/app/chat/page.tsx - Chat stream
frontend/lib/chat/useChatStream.ts - Analysis presentation
frontend/components/chat/OrchestrationPanel.tsx
API and orchestration
- FastAPI
backend/src/stop_loss/api/app.py - Analysis service
backend/src/stop_loss/agents/service.py - Typed run events
backend/src/stop_loss/agents/run_events.py
Risk analysis
- Agent graph
backend/src/stop_loss/agents/graph.py - Query coordinator
backend/src/stop_loss/agents/nodes.py - Market, news, impact, analogs
backend/src/stop_loss/agents/nodes.py - Quant risk
backend/src/stop_loss/analytics/risk.py - Hedge strategy
backend/src/stop_loss/agents/portfolio_nodes.py - Evidence audit
backend/src/stop_loss/agents/audit.py - Market analytics
backend/src/stop_loss/analytics - Yahoo market client
backend/src/stop_loss/analytics/yfinance_client.py
Ingestion and retrieval
- Ingestion lanes
backend/src/stop_loss/ingestion/runner.py - Source connectors
backend/src/fin_terminal/connectors - Analog retrieval
backend/src/stop_loss/retrieval/search.py
Data foundations
- Typed records and themes
backend/src/fin_terminal/schemas.py - Embeddings
backend/src/fin_terminal/embeddings.py - Vector index
backend/src/fin_terminal/vectorstore/pinecone.py - Evidence log
backend/src/fin_terminal/evidence.py - Dedupe store
backend/src/fin_terminal/storage.py - Source resilience
backend/src/fin_terminal/resilience.py - Analysis models
backend/src/stop_loss/analytics/models.py - Runtime settings
backend/src/stop_loss/settings.py
Other components
- Investor
Connections 26
- Investor → Terminal UI: asks
- Terminal UI → Chat stream: submits query
- Chat stream → FastAPI: starts run
backend/src/stop_loss/api/app.py - FastAPI → Analysis service: starts analysis
backend/src/stop_loss/api/app.py - Analysis service → Agent graph: builds and invokes
backend/src/stop_loss/agents/service.py - Agent graph → Query coordinator: routes query
- Query coordinator → Market, news, impact, analogs: dispatches
- Market, news, impact, analogs → Quant risk: provides analysis
- Quant risk → Hedge strategy: informs strategy
- Hedge strategy → Evidence audit: submits claims
- Analysis service → Typed run events: streams lifecycle
backend/src/stop_loss/agents/service.py - FastAPI → Chat stream: streams SSE
- Chat stream → Analysis presentation: updates progress
- Market analytics → Yahoo market client: fetches market data
backend/src/stop_loss/analytics/yahoo.py - Yahoo market client → Source resilience: guards requests
backend/src/stop_loss/analytics/yfinance_client.py - Yahoo market client → Analysis models: returns typed data
backend/src/stop_loss/analytics/yfinance_client.py - Ingestion lanes → Source connectors: fetches sources
- Ingestion lanes → Typed records and themes: normalizes and tags
- Ingestion lanes → Embeddings: embeds records
- Ingestion lanes → Vector index: indexes records
- Ingestion lanes → Evidence log: records provenance
- Ingestion lanes → Dedupe store: deduplicates records
- Analog retrieval → Embeddings: embeds queries
backend/src/stop_loss/retrieval/search.py - Analog retrieval → Vector index: searches index
backend/src/stop_loss/retrieval/search.py - Analysis service → Analog retrieval: retrieves analogs
backend/src/stop_loss/agents/service.py - Runtime settings → Yahoo market client: configures client