Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
OPENAI_API_KEY=your_openai_api_key_here
FINNHUB_API_KEY=your_finnhub_api_key_here
# Optional but recommended
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
FINANCIAL_DATA_API_KEY=your_financial_data_api_key_here
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
env:
FINNHUB_API_KEY: test-finnhub-key
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -59,6 +61,8 @@ jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
env:
FINNHUB_API_KEY: test-finnhub-key
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ A sophisticated multi-agent financial analysis system that uses **LangGraph**, *
- **SEC Filing Analysis**: Deep analysis of 10-K and 10-Q reports using AI
- **Technical Analysis**: Comprehensive technical indicators and chart pattern recognition
- **Sentiment Analysis**: AI-powered sentiment analysis of news and social media
- **WebSocket News Channels**: Dedicated multi-stream WebSockets for tier-one financial news, open agencies, and real-time pricing
- **Portfolio Optimization**: Intelligent portfolio construction with risk management
- **Trading Recommendations**: Buy/Sell/Hold recommendations with confidence scores
- **Risk Assessment**: Multi-factor risk analysis and position sizing
Expand Down Expand Up @@ -67,6 +68,7 @@ Required environment variables:

```env
OPENAI_API_KEY=your_openai_api_key_here
FINNHUB_API_KEY=your_finnhub_api_key_here
# Optional but recommended
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
FINANCIAL_DATA_API_KEY=your_financial_data_api_key_here
Expand All @@ -85,23 +87,55 @@ DEFAULT_PORTFOLIO_SIZE=100000

```bash
# Basic analysis
tradegraph AAPL MSFT GOOGL
uv run tradegraph AAPL MSFT GOOGL

# Comprehensive analysis with custom parameters
tradegraph AAPL MSFT GOOGL \
uv run tradegraph AAPL MSFT GOOGL \
--portfolio-size 250000 \
--risk-tolerance aggressive \
--time-horizon long_term \
--analysis-type comprehensive

# Quick analysis
tradegraph TSLA NVDA --analysis-type quick
uv run tradegraph TSLA NVDA --analysis-type quick

# Generate alerts only
tradegraph AAPL --alerts-only
uv run tradegraph AAPL --alerts-only

# JSON output
tradegraph AAPL MSFT --output-format json > analysis.json
uv run tradegraph AAPL MSFT --output-format json > analysis.json
```

### Real-Time WebSocket Channels

The repository now ships with a FastAPI service that exposes three dedicated WebSocket channels:

1. `top_market_crypto` – Reuters, CNBC, WSJ, MarketWatch, and CoinDesk headlines
2. `open_source_agencies` – Guardian, BBC, Al Jazeera, NPR, and Financial Express (all free/open access)
3. `live_price_stream` – Finnhub (equities) + Binance (crypto) price snapshots with last year/month/day/hour trends

Launch the channel server with `uv` and subscribe from any WebSocket client:

```bash
uv run uvicorn tradegraph_financial_advisor.server.channel_server:app --reload
```

Example subscription (JavaScript snippet):

```js
const socket = new WebSocket('ws://127.0.0.1:8000/ws/top_market_crypto?symbols=AAPL,MSFT,BTC-USD');
socket.onmessage = (event) => {
console.log(JSON.parse(event.data));
};
```

### PDF Financial Reports

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.

```bash
uv run tradegraph AAPL BTC-USD --analysis-type comprehensive --channel-report \
--pdf-path results/aapl_crypto_multichannel.pdf
```

### Python API Usage
Expand Down Expand Up @@ -284,7 +318,7 @@ GOOGL: HOLD (Confidence: 65.0%)

- **LangGraph**: Workflow orchestration and agent coordination
- **OpenAI GPT-4**: Natural language processing and analysis
- **yfinance**: Financial data retrieval
- **Finnhub** (equities) and **Binance** (crypto) for live/historical pricing
- **pandas/numpy**: Data processing and analysis
- **aiohttp**: Async HTTP requests
- **pydantic**: Data validation and serialization
Expand Down
6 changes: 3 additions & 3 deletions api/routers/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ async def check_dependencies():
"pydantic",
"langchain",
"langgraph",
"yfinance",
"pandas",
"numpy",
"aiohttp",
Expand All @@ -290,15 +289,16 @@ async def check_dependencies():
# Check environment variables
import os

env_vars = ["OPENAI_API_KEY"]
env_vars = ["OPENAI_API_KEY", "FINNHUB_API_KEY"]
for var in env_vars:
dependencies[f"env_{var.lower()}"] = {
"status": "configured" if os.getenv(var) else "missing"
}

# Check external services (simplified)
dependencies["external_apis"] = {
"openai": "configured" if os.getenv("OPENAI_API_KEY") else "not_configured"
"openai": "configured" if os.getenv("OPENAI_API_KEY") else "not_configured",
"finnhub": "configured" if os.getenv("FINNHUB_API_KEY") else "not_configured",
}

return APIResponse(success=True, data=dependencies, message="Dependencies check completed")
Expand Down
47 changes: 45 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ OPENAI_API_KEY=your_openai_key

```bash
# Basic analysis
tradegraph AAPL MSFT GOOGL
uv run tradegraph AAPL MSFT GOOGL

# Comprehensive analysis with custom parameters
tradegraph AAPL MSFT --portfolio-size 250000 \
uv run tradegraph AAPL MSFT --portfolio-size 250000 \
--risk-tolerance aggressive \
--analysis-type comprehensive

# Quick screen
uv run tradegraph TSLA NVDA --analysis-type quick

# Alerts-only + JSON output
uv run tradegraph AAPL --alerts-only --output-format json
```

=== "Python API"
Expand Down Expand Up @@ -107,6 +113,43 @@ OPENAI_API_KEY=your_openai_key
# Open http://localhost:3000
```

### Real-Time WebSocket Channels

Three curated channels expose tier-one market news, open-license agencies, and real-time price trends via FastAPI:

1. `top_market_crypto` – Reuters, CNBC, Wall Street Journal, MarketWatch, and CoinDesk
2. `open_source_agencies` – The Guardian, BBC Business, Al Jazeera, NPR, and Financial Express
3. `live_price_stream` – Finnhub equities + Binance crypto spot prices with last year/month/day/hour performance

Start the channel server locally:

```bash
uv run uvicorn tradegraph_financial_advisor.server.channel_server:app --reload
```

Listen from any WebSocket client:

```js
const socket = new WebSocket('ws://127.0.0.1:8000/ws/top_market_crypto?symbols=AAPL,MSFT,BTC-USD');
socket.onmessage = (event) => {
console.log(JSON.parse(event.data));
};
```

Snapshots are also available via `GET /channels/{channel_id}?symbols=AAPL,MSFT`.

### Multichannel PDF Reports

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):

```bash
uv run tradegraph AAPL BTC-USD --analysis-type comprehensive --channel-report \
--pdf-path results/aapl_crypto_multichannel.pdf
```

The resulting file includes the ChannelReportAgent executive summary, news highlights, allocation guidance, and a multi-horizon trend table.


## 📈 Example Output

```json
Expand Down
4 changes: 3 additions & 1 deletion examples/basic_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ async def main():

# Check environment first
if not check_environment():
print("\n⚠️ Please configure your environment variables before running examples")
print(
"\n⚠️ Please configure your environment variables before running examples"
)
return

# Run examples
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,30 @@ dependencies = [
"requests>=2.31.0",
"aiohttp>=3.9.0",
"beautifulsoup4>=4.12.0",
"feedparser>=6.0.0",
"pandas>=2.1.0",
"numpy>=1.24.0",
"python-dotenv>=1.0.0",
"pydantic>=2.5.0",
"pydantic-settings>=2.0.0",
"asyncio>=3.4.3",
"loguru>=0.7.0",
"yfinance>=0.2.0",
"alpha-vantage>=2.3.0",
"python-dateutil>=2.8.0",
"plotly>=5.15.0",
"kaleido>=0.2.1",
"duckdb>=0.10.0",
"fastapi>=0.118.0",
"reportlab>=4.0.0",
"uvicorn>=0.30.0",
]

[project.optional-dependencies]
dev = [
"pytest>=7.4.0",
"pytest-asyncio>=0.21.0",
"pytest-cov>=4.1.0",
"black>=23.0.0",
"black==23.3.0",
"isort>=5.12.0",
"flake8>=6.0.0",
"mypy>=1.5.0",
Expand Down
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ mcp>=1.0.0
requests>=2.31.0
aiohttp>=3.9.0
beautifulsoup4>=4.12.0
feedparser>=6.0.0
pandas>=2.1.0
numpy>=1.24.0
python-dotenv>=1.0.0
pydantic>=2.5.0
loguru>=0.7.0
yfinance>=0.2.0
alpha-vantage>=2.3.0
pytest>=7.4.0
pytest-asyncio>=0.21.0
pytest-cov>=4.1.0
python-dateutil>=2.8.0
plotly>=5.15.0
kaleido>=0.2.1
duckdb>=0.10.0
reportlab>=4.0.0
uvicorn>=0.30.0
15 changes: 15 additions & 0 deletions src/tradegraph_financial_advisor/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .channel_report_agent import ChannelReportAgent
from .financial_agent import FinancialAnalysisAgent
from .news_agent import NewsReaderAgent
from .recommendation_engine import TradingRecommendationEngine
from .report_analysis_agent import ReportAnalysisAgent
from .multi_asset_allocation_agent import MultiAssetAllocationAgent

__all__ = [
"ChannelReportAgent",
"FinancialAnalysisAgent",
"NewsReaderAgent",
"TradingRecommendationEngine",
"ReportAnalysisAgent",
"MultiAssetAllocationAgent",
]
Loading
Loading