Skip to content

Commit b2d22e3

Browse files
authored
Merge pull request #9 from ApexAILabs/feature/news-reporting-updates
Feature/news-reporting-updates
2 parents 103e9f6 + fe37902 commit b2d22e3

37 files changed

Lines changed: 3648 additions & 558 deletions

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
OPENAI_API_KEY=your_openai_api_key_here
2+
FINNHUB_API_KEY=your_finnhub_api_key_here
23
# Optional but recommended
34
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
45
FINANCIAL_DATA_API_KEY=your_financial_data_api_key_here

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
test:
3535
name: Unit Tests
3636
runs-on: ubuntu-latest
37+
env:
38+
FINNHUB_API_KEY: test-finnhub-key
3739
steps:
3840
- name: Checkout code
3941
uses: actions/checkout@v4
@@ -59,6 +61,8 @@ jobs:
5961
integration-tests:
6062
name: Integration Tests
6163
runs-on: ubuntu-latest
64+
env:
65+
FINNHUB_API_KEY: test-finnhub-key
6266
steps:
6367
- name: Checkout code
6468
uses: actions/checkout@v4

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A sophisticated multi-agent financial analysis system that uses **LangGraph**, *
1212
- **SEC Filing Analysis**: Deep analysis of 10-K and 10-Q reports using AI
1313
- **Technical Analysis**: Comprehensive technical indicators and chart pattern recognition
1414
- **Sentiment Analysis**: AI-powered sentiment analysis of news and social media
15+
- **WebSocket News Channels**: Dedicated multi-stream WebSockets for tier-one financial news, open agencies, and real-time pricing
1516
- **Portfolio Optimization**: Intelligent portfolio construction with risk management
1617
- **Trading Recommendations**: Buy/Sell/Hold recommendations with confidence scores
1718
- **Risk Assessment**: Multi-factor risk analysis and position sizing
@@ -67,6 +68,7 @@ Required environment variables:
6768

6869
```env
6970
OPENAI_API_KEY=your_openai_api_key_here
71+
FINNHUB_API_KEY=your_finnhub_api_key_here
7072
# Optional but recommended
7173
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
7274
FINANCIAL_DATA_API_KEY=your_financial_data_api_key_here
@@ -85,23 +87,55 @@ DEFAULT_PORTFOLIO_SIZE=100000
8587

8688
```bash
8789
# Basic analysis
88-
tradegraph AAPL MSFT GOOGL
90+
uv run tradegraph AAPL MSFT GOOGL
8991

9092
# Comprehensive analysis with custom parameters
91-
tradegraph AAPL MSFT GOOGL \
93+
uv run tradegraph AAPL MSFT GOOGL \
9294
--portfolio-size 250000 \
9395
--risk-tolerance aggressive \
9496
--time-horizon long_term \
9597
--analysis-type comprehensive
9698

9799
# Quick analysis
98-
tradegraph TSLA NVDA --analysis-type quick
100+
uv run tradegraph TSLA NVDA --analysis-type quick
99101

100102
# Generate alerts only
101-
tradegraph AAPL --alerts-only
103+
uv run tradegraph AAPL --alerts-only
102104

103105
# JSON output
104-
tradegraph AAPL MSFT --output-format json > analysis.json
106+
uv run tradegraph AAPL MSFT --output-format json > analysis.json
107+
```
108+
109+
### Real-Time WebSocket Channels
110+
111+
The repository now ships with a FastAPI service that exposes three dedicated WebSocket channels:
112+
113+
1. `top_market_crypto` – Reuters, CNBC, WSJ, MarketWatch, and CoinDesk headlines
114+
2. `open_source_agencies` – Guardian, BBC, Al Jazeera, NPR, and Financial Express (all free/open access)
115+
3. `live_price_stream` – Finnhub (equities) + Binance (crypto) price snapshots with last year/month/day/hour trends
116+
117+
Launch the channel server with `uv` and subscribe from any WebSocket client:
118+
119+
```bash
120+
uv run uvicorn tradegraph_financial_advisor.server.channel_server:app --reload
121+
```
122+
123+
Example subscription (JavaScript snippet):
124+
125+
```js
126+
const socket = new WebSocket('ws://127.0.0.1:8000/ws/top_market_crypto?symbols=AAPL,MSFT,BTC-USD');
127+
socket.onmessage = (event) => {
128+
console.log(JSON.parse(event.data));
129+
};
130+
```
131+
132+
### PDF Financial Reports
133+
134+
Financial agents can now condense all three channels into a PDF that covers news context, buy/hold/sell guidance, risk mix, and multi-horizon price trends. Trend snapshots are limited to month/week/day/hour windows so the report explicitly reflects month-to-date momentum.
135+
136+
```bash
137+
uv run tradegraph AAPL BTC-USD --analysis-type comprehensive --channel-report \
138+
--pdf-path results/aapl_crypto_multichannel.pdf
105139
```
106140

107141
### Python API Usage
@@ -284,7 +318,7 @@ GOOGL: HOLD (Confidence: 65.0%)
284318

285319
- **LangGraph**: Workflow orchestration and agent coordination
286320
- **OpenAI GPT-4**: Natural language processing and analysis
287-
- **yfinance**: Financial data retrieval
321+
- **Finnhub** (equities) and **Binance** (crypto) for live/historical pricing
288322
- **pandas/numpy**: Data processing and analysis
289323
- **aiohttp**: Async HTTP requests
290324
- **pydantic**: Data validation and serialization

api/routers/health.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ async def check_dependencies():
269269
"pydantic",
270270
"langchain",
271271
"langgraph",
272-
"yfinance",
273272
"pandas",
274273
"numpy",
275274
"aiohttp",
@@ -290,15 +289,16 @@ async def check_dependencies():
290289
# Check environment variables
291290
import os
292291

293-
env_vars = ["OPENAI_API_KEY"]
292+
env_vars = ["OPENAI_API_KEY", "FINNHUB_API_KEY"]
294293
for var in env_vars:
295294
dependencies[f"env_{var.lower()}"] = {
296295
"status": "configured" if os.getenv(var) else "missing"
297296
}
298297

299298
# Check external services (simplified)
300299
dependencies["external_apis"] = {
301-
"openai": "configured" if os.getenv("OPENAI_API_KEY") else "not_configured"
300+
"openai": "configured" if os.getenv("OPENAI_API_KEY") else "not_configured",
301+
"finnhub": "configured" if os.getenv("FINNHUB_API_KEY") else "not_configured",
302302
}
303303

304304
return APIResponse(success=True, data=dependencies, message="Dependencies check completed")

docs/index.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,18 @@ OPENAI_API_KEY=your_openai_key
6464

6565
```bash
6666
# Basic analysis
67-
tradegraph AAPL MSFT GOOGL
67+
uv run tradegraph AAPL MSFT GOOGL
6868

6969
# Comprehensive analysis with custom parameters
70-
tradegraph AAPL MSFT --portfolio-size 250000 \
70+
uv run tradegraph AAPL MSFT --portfolio-size 250000 \
7171
--risk-tolerance aggressive \
7272
--analysis-type comprehensive
73+
74+
# Quick screen
75+
uv run tradegraph TSLA NVDA --analysis-type quick
76+
77+
# Alerts-only + JSON output
78+
uv run tradegraph AAPL --alerts-only --output-format json
7379
```
7480

7581
=== "Python API"
@@ -107,6 +113,43 @@ OPENAI_API_KEY=your_openai_key
107113
# Open http://localhost:3000
108114
```
109115

116+
### Real-Time WebSocket Channels
117+
118+
Three curated channels expose tier-one market news, open-license agencies, and real-time price trends via FastAPI:
119+
120+
1. `top_market_crypto` – Reuters, CNBC, Wall Street Journal, MarketWatch, and CoinDesk
121+
2. `open_source_agencies` – The Guardian, BBC Business, Al Jazeera, NPR, and Financial Express
122+
3. `live_price_stream` – Finnhub equities + Binance crypto spot prices with last year/month/day/hour performance
123+
124+
Start the channel server locally:
125+
126+
```bash
127+
uv run uvicorn tradegraph_financial_advisor.server.channel_server:app --reload
128+
```
129+
130+
Listen from any WebSocket client:
131+
132+
```js
133+
const socket = new WebSocket('ws://127.0.0.1:8000/ws/top_market_crypto?symbols=AAPL,MSFT,BTC-USD');
134+
socket.onmessage = (event) => {
135+
console.log(JSON.parse(event.data));
136+
};
137+
```
138+
139+
Snapshots are also available via `GET /channels/{channel_id}?symbols=AAPL,MSFT`.
140+
141+
### Multichannel PDF Reports
142+
143+
Generate investor-ready PDFs that merge channel summaries, recommendations, and the trend matrix (month/week/day/hour lookback so the results focus on month-to-date moves):
144+
145+
```bash
146+
uv run tradegraph AAPL BTC-USD --analysis-type comprehensive --channel-report \
147+
--pdf-path results/aapl_crypto_multichannel.pdf
148+
```
149+
150+
The resulting file includes the ChannelReportAgent executive summary, news highlights, allocation guidance, and a multi-horizon trend table.
151+
152+
110153
## 📈 Example Output
111154

112155
```json

examples/basic_usage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ async def main():
229229

230230
# Check environment first
231231
if not check_environment():
232-
print("\n⚠️ Please configure your environment variables before running examples")
232+
print(
233+
"\n⚠️ Please configure your environment variables before running examples"
234+
)
233235
return
234236

235237
# Run examples

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,30 @@ dependencies = [
3030
"requests>=2.31.0",
3131
"aiohttp>=3.9.0",
3232
"beautifulsoup4>=4.12.0",
33+
"feedparser>=6.0.0",
3334
"pandas>=2.1.0",
3435
"numpy>=1.24.0",
3536
"python-dotenv>=1.0.0",
3637
"pydantic>=2.5.0",
3738
"pydantic-settings>=2.0.0",
3839
"asyncio>=3.4.3",
3940
"loguru>=0.7.0",
40-
"yfinance>=0.2.0",
4141
"alpha-vantage>=2.3.0",
4242
"python-dateutil>=2.8.0",
4343
"plotly>=5.15.0",
44+
"kaleido>=0.2.1",
45+
"duckdb>=0.10.0",
4446
"fastapi>=0.118.0",
47+
"reportlab>=4.0.0",
48+
"uvicorn>=0.30.0",
4549
]
4650

4751
[project.optional-dependencies]
4852
dev = [
4953
"pytest>=7.4.0",
5054
"pytest-asyncio>=0.21.0",
5155
"pytest-cov>=4.1.0",
52-
"black>=23.0.0",
56+
"black==23.3.0",
5357
"isort>=5.12.0",
5458
"flake8>=6.0.0",
5559
"mypy>=1.5.0",

requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ mcp>=1.0.0
77
requests>=2.31.0
88
aiohttp>=3.9.0
99
beautifulsoup4>=4.12.0
10+
feedparser>=6.0.0
1011
pandas>=2.1.0
1112
numpy>=1.24.0
1213
python-dotenv>=1.0.0
1314
pydantic>=2.5.0
1415
loguru>=0.7.0
15-
yfinance>=0.2.0
1616
alpha-vantage>=2.3.0
1717
pytest>=7.4.0
1818
pytest-asyncio>=0.21.0
1919
pytest-cov>=4.1.0
2020
python-dateutil>=2.8.0
2121
plotly>=5.15.0
22+
kaleido>=0.2.1
23+
duckdb>=0.10.0
24+
reportlab>=4.0.0
25+
uvicorn>=0.30.0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from .channel_report_agent import ChannelReportAgent
2+
from .financial_agent import FinancialAnalysisAgent
3+
from .news_agent import NewsReaderAgent
4+
from .recommendation_engine import TradingRecommendationEngine
5+
from .report_analysis_agent import ReportAnalysisAgent
6+
from .multi_asset_allocation_agent import MultiAssetAllocationAgent
7+
8+
__all__ = [
9+
"ChannelReportAgent",
10+
"FinancialAnalysisAgent",
11+
"NewsReaderAgent",
12+
"TradingRecommendationEngine",
13+
"ReportAnalysisAgent",
14+
"MultiAssetAllocationAgent",
15+
]

0 commit comments

Comments
 (0)