How jngk07/stockagent works
Purpose and entry points
This is a Python multi-agent stock-trading workflow. It collects stock news, derives sentiment signals, predicts prices, and produces buy/sell trading decisions while persisting stage outputs to PostgreSQL.
Primary execution/UI entry points:
• main_pipeline.py — orchestrates the end-to-end agent flow.
• app.py — Streamlit-facing application entry point.
• agent1_news_reader.py — likely standalone entry for news collection.
Pipeline orchestration
main_pipeline.py is the control-plane boundary: it should sequence agents and pass each stage’s output into downstream stages. The intended flow is:
1. News acquisition
2. Sentiment signal generation
3. Price prediction
4. Trade decision
5. PostgreSQL logging
Relevant path:
• main_pipeline.py
News ingestion agent
The news-reader stage obtains stock-related news as the upstream market-context input. Its output is the source material for sentiment analysis and may also be available to prediction/trading logic.
Relevant path:
• agent1_news_reader.py
Boundary: external news/data sources enter the repository here; downstream agents should consume normalized news content rather than source-specific API responses.
Sentiment signal agent
The sentiment agent converts news input into a trading-oriented sentiment assessment. Its results are persisted as “Sentimental Logs” in PostgreSQL and become a core decision signal for the trader.
Relevant path:
• agent2_sentiment_signal.py
Boundary: this stage separates unstructured language/news analysis from structured numeric or categorical market signals.
Price prediction agent
The prediction stage estimates future stock prices or price direction, producing a second independent input to the trader. Prediction outputs are stored as “Price Prediction Logs.”
Relevant path:
• agent4_price_predictor.py
Boundary: predictive/model logic is isolated from final trade-policy logic, allowing the trader to combine forecasts with sentiment rather than embedding forecasting internally.
Trading decision agent
The trader agent consumes the available sentiment and price-prediction signals to determine buy/sell actions. It records decisions in “Trader Logs.”
Relevant path:
• agent3_trader.py
This is the policy boundary: upstream agents generate evidence; this component converts evidence into actionable trade recommendations.
Persistence, UI, and infrastructure
PostgreSQL is the system of record for sentiment, prediction, and trader logs. The README also identifies an MCP-server connection between local PostgreSQL and Claude Desktop, making the database externally inspectable through that integration.
Streamlit provides the application runtime/UI:
• app.py
• .streamlit/config.toml
Python dependencies and likely database, agent/model, and UI libraries are declared in:
• requirements.txt
Main entry points: main_pipeline.py Pipeline Orchestrator · agent3_trader.py Trade Decision · agent2_sentiment_signal.py Sentiment Signal · agent4_price_predictor.py Price Predictor
Components 12
Application Runtime
- Streamlit UI
app.py - Pipeline Orchestrator · Sequences the end-to-end trading workflow.
main_pipeline.py
Trading Agents
- News Reader · Normalizes stock news for downstream agents.
agent1_news_reader.py - Sentiment Signal · Converts news into trading-oriented sentiment.
agent2_sentiment_signal.py - Price Predictor · Produces price or direction forecasts independent of trade policy.
agent4_price_predictor.py - Trade Decision · Combines evidence into buy/sell recommendations.
agent3_trader.py
Persistence & Integration
- PostgreSQL · Stores sentiment, prediction, and trader logs.
- Sentimental Logs
- Price Prediction Logs
- Trader Logs
- Claude Desktop MCP · Inspects the local PostgreSQL connection through MCP.
Other components
- External News Sources
Connections 15
- Streamlit UI → Pipeline Orchestrator: runs workflow
- Pipeline Orchestrator → News Reader: news stage
- External News Sources → News Reader: stock news
- News Reader → Sentiment Signal: normalized news
- Pipeline Orchestrator → Price Predictor: prediction stage
- Sentiment Signal → Trade Decision: sentiment signal
- Price Predictor → Trade Decision: price forecast
- Pipeline Orchestrator → Trade Decision: decision stage
- Sentiment Signal → Sentimental Logs: writes
- Price Predictor → Price Prediction Logs: writes
- Trade Decision → Trader Logs: writes
- Sentimental Logs → PostgreSQL: stored in
- Price Prediction Logs → PostgreSQL: stored in
- Trader Logs → PostgreSQL: stored in
- Claude Desktop MCP → PostgreSQL: MCP connection