Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- README.md +142 -54
- pyproject.toml +16 -0
- run.py +10 -0
- src/market-analyst/README.md +142 -54
- uv.lock +0 -0
README.md
CHANGED
|
@@ -1,80 +1,168 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
emoji: π
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
-
|
| 7 |
-
app_port: 7860
|
| 8 |
-
pinned: false
|
| 9 |
license: mit
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
# π AI Market Analyst
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
## π Features
|
| 18 |
|
| 19 |
-
|
| 20 |
-
- **Market Analyst**: Calculates technicals (SMA 20/50/200, RSI 14) and analyzes trend/momentum.
|
| 21 |
-
- **Sentiment Analyst**: Scrapes full news articles and uses **FinBERT** to score sentiment (Bullish/Bearish).
|
| 22 |
-
- **Strategy Advisor**: Recommends complex option spreads (Iron Condors, Vertical Spreads) with *specific* legs (Strikes/Expiry).
|
| 23 |
-
- **Risk Manager**: Validates trades against a confidence rubric (>70% required) and volatility regime (VIX).
|
| 24 |
-
- **π΅οΈ Deep Sentiment Engine**: Goes beyond headlines by fetching and analyzing the full text of news articles using `BeautifulSoup` and `Transformers` (FinBERT).
|
| 25 |
-
- **β‘ High Performance**: Parallelized news fetching for rapid analysis.
|
| 26 |
-
- **π‘οΈ Guardrails**:
|
| 27 |
-
- **Market Hours**: Only operates during US Market Open (09:30-16:00 ET) to prevent stale data usage.
|
| 28 |
-
- **Type Safety**: Pydantic validation for all data pipelines.
|
| 29 |
-
- **Robustness**: Gracefully handles new IPOs or missing data.
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
### Prerequisites
|
| 50 |
-
- Python 3.12+
|
| 51 |
-
- `uv` package manager (optional but recommended)
|
| 52 |
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
```bash
|
| 57 |
-
pip install -e .
|
| 58 |
-
```
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
The app will open at `http://localhost:8501`.
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
-
# Build
|
| 72 |
-
docker build -t market-analyst -f src/market-analyst/Dockerfile .
|
| 73 |
|
| 74 |
-
|
|
|
|
| 75 |
docker run -p 7860:7860 market-analyst
|
| 76 |
```
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
app_port: 7860
|
|
|
|
| 3 |
colorFrom: blue
|
| 4 |
colorTo: gray
|
| 5 |
+
emoji: π
|
|
|
|
|
|
|
| 6 |
license: mit
|
| 7 |
+
pinned: false
|
| 8 |
+
sdk: docker
|
| 9 |
+
short_description: Multi-agent AI that recommends stock option spreads
|
| 10 |
+
title: AI Market Analyst --- Real-Time Stock & Options Insights
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# π AI Market Analyst --- From Ticker to Strategy
|
| 14 |
+
|
| 15 |
+
Enter a stock ticker and get **real-time technical analysis, news
|
| 16 |
+
sentiment, and AI-generated option strategies** --- all powered by a
|
| 17 |
+
coordinated **multi-agent system**.
|
| 18 |
+
|
| 19 |
+
Designed for **learning, demos, and research** in agentic finance
|
| 20 |
+
workflows.
|
| 21 |
+
|
| 22 |
+
------------------------------------------------------------------------
|
| 23 |
+
|
| 24 |
+
## π Try it with these tickers
|
| 25 |
|
| 26 |
+
- `AAPL` --- Large-cap, steady trend
|
| 27 |
+
- `TSLA` --- High volatility, news-driven
|
| 28 |
+
- `NVDA` --- Momentum + sentiment play
|
| 29 |
+
- `SPY` --- Market-wide signal
|
| 30 |
+
|
| 31 |
+
β¬οΈ Start with one ticker and explore how different agents reason
|
| 32 |
+
together.
|
| 33 |
+
|
| 34 |
+
------------------------------------------------------------------------
|
| 35 |
+
|
| 36 |
+
## β¨ Why this Space is different
|
| 37 |
+
|
| 38 |
+
Most market tools show charts.\
|
| 39 |
+
This one **explains the reasoning** behind a strategy.
|
| 40 |
+
|
| 41 |
+
βοΈ Multiple specialized AI agents (not one monolithic model)\
|
| 42 |
+
βοΈ Combines **technicals + sentiment + volatility**\
|
| 43 |
+
βοΈ Generates **structured option strategies**, not vague advice\
|
| 44 |
+
βοΈ Built with strong guardrails to avoid misleading outputs
|
| 45 |
+
|
| 46 |
+
This Space is a **reference implementation** for agentic AI in finance.
|
| 47 |
+
|
| 48 |
+
------------------------------------------------------------------------
|
| 49 |
|
| 50 |
## π Features
|
| 51 |
|
| 52 |
+
### π§ Multi-Agent Swarm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
Each agent has a single responsibility:
|
| 55 |
|
| 56 |
+
- **Market Analyst Agent**
|
| 57 |
+
- Computes SMA (20 / 50 / 200), RSI (14)
|
| 58 |
+
- Detects trend, momentum, and regime
|
| 59 |
+
- **Sentiment Analyst Agent**
|
| 60 |
+
- Scrapes full news articles (not just headlines)
|
| 61 |
+
- Uses **FinBERT** to classify sentiment as Bullish / Bearish /
|
| 62 |
+
Neutral
|
| 63 |
+
- **Strategy Advisor Agent**
|
| 64 |
+
- Proposes **option spreads** (Iron Condors, Vertical Spreads)
|
| 65 |
+
- Includes concrete legs: strikes, expiry, and structure
|
| 66 |
+
- **Risk Manager Agent**
|
| 67 |
+
- Validates strategies against:
|
| 68 |
+
- Confidence score (\>70% required)
|
| 69 |
+
- Market volatility (VIX regime)
|
| 70 |
+
- Data completeness
|
| 71 |
+
|
| 72 |
+
------------------------------------------------------------------------
|
| 73 |
+
|
| 74 |
+
### π΅οΈ Deep Sentiment Engine
|
| 75 |
|
| 76 |
+
- Fetches **full article text** using `requests` + `BeautifulSoup`
|
| 77 |
+
- Runs transformer-based sentiment analysis (FinBERT)
|
| 78 |
+
- Aggregates sentiment across multiple sources
|
| 79 |
+
|
| 80 |
+
------------------------------------------------------------------------
|
| 81 |
+
|
| 82 |
+
### π‘οΈ Built-in Guardrails
|
| 83 |
+
|
| 84 |
+
- β° **Market Hours Aware**\
|
| 85 |
+
Runs only during US market hours (09:30--16:00 ET)
|
| 86 |
+
|
| 87 |
+
- π§Ύ **Type Safety**\
|
| 88 |
+
End-to-end Pydantic validation
|
| 89 |
+
|
| 90 |
+
- π§― **Robust by Design**\
|
| 91 |
+
Handles missing data, low-liquidity tickers, and new IPOs gracefully
|
| 92 |
+
|
| 93 |
+
------------------------------------------------------------------------
|
| 94 |
+
|
| 95 |
+
## π How it works (high level)
|
| 96 |
+
|
| 97 |
+
1. You enter a stock ticker
|
| 98 |
+
2. Market data is fetched and technical indicators are computed
|
| 99 |
+
3. News articles are scraped and sentiment-scored
|
| 100 |
+
4. Strategy Advisor proposes an option structure
|
| 101 |
+
5. Risk Manager validates or rejects the strategy
|
| 102 |
+
6. Final output includes **analysis + rationale**
|
| 103 |
+
|
| 104 |
+
------------------------------------------------------------------------
|
| 105 |
+
|
| 106 |
+
## π§ͺ Example use cases
|
| 107 |
+
|
| 108 |
+
- Learning **options strategy design**
|
| 109 |
+
- Demonstrating **multi-agent coordination**
|
| 110 |
+
- Building agentic finance prototypes
|
| 111 |
+
- Educational demos (no real-money trading)
|
| 112 |
+
|
| 113 |
+
------------------------------------------------------------------------
|
| 114 |
+
|
| 115 |
+
## π§ Under the hood (for developers)
|
| 116 |
+
|
| 117 |
+
src/market-analyst/
|
| 118 |
+
βββ app.py # Streamlit UI (Agent Orchestrator)
|
| 119 |
+
βββ aagents/ # Agent definitions
|
| 120 |
+
β βββ market_analyst.py # Technical indicators & trends
|
| 121 |
+
β βββ sentiment_analyst.py# FinBERT sentiment engine
|
| 122 |
+
β βββ strategy_advisor.py # Options strategist
|
| 123 |
+
β βββ risk_manager.py # Trade validator
|
| 124 |
+
βββ tools/ # Capability layer
|
| 125 |
+
β βββ market_data.py # yfinance, pandas-ta, options chains
|
| 126 |
+
β βββ news_data.py # DDGS, requests, FinBERT, Pydantic
|
| 127 |
+
βββ Dockerfile # HF Spaces deployment
|
| 128 |
+
|
| 129 |
+
------------------------------------------------------------------------
|
| 130 |
+
|
| 131 |
+
## βΆοΈ Run locally
|
| 132 |
|
| 133 |
### Prerequisites
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
- Python 3.12+
|
| 136 |
+
- Virtual environment recommended
|
| 137 |
|
| 138 |
+
### Install & run
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
+
``` bash
|
| 141 |
+
pip install -e .
|
| 142 |
+
streamlit run src/market-analyst/app.py
|
| 143 |
+
```
|
|
|
|
| 144 |
|
| 145 |
+
App runs at: `http://localhost:8501`
|
| 146 |
|
| 147 |
+
------------------------------------------------------------------------
|
| 148 |
|
| 149 |
+
## π³ Docker / Hugging Face Spaces
|
|
|
|
|
|
|
| 150 |
|
| 151 |
+
``` bash
|
| 152 |
+
docker build -t market-analyst -f src/market-analyst/Dockerfile .
|
| 153 |
docker run -p 7860:7860 market-analyst
|
| 154 |
```
|
| 155 |
|
| 156 |
+
------------------------------------------------------------------------
|
| 157 |
+
|
| 158 |
+
## β οΈ Financial Disclaimer
|
| 159 |
+
|
| 160 |
+
**Educational use only.**\
|
| 161 |
+
This tool is **not** a financial advisor and does **not** provide
|
| 162 |
+
investment advice.\
|
| 163 |
+
Do **not** use for real-money trading.
|
| 164 |
+
|
| 165 |
+
------------------------------------------------------------------------
|
| 166 |
|
| 167 |
+
π‘ Like this Space?\
|
| 168 |
+
β Give it a like Β· π Duplicate it Β· π¬ Share feedback
|
pyproject.toml
CHANGED
|
@@ -33,6 +33,16 @@ dependencies = [
|
|
| 33 |
"html2text>=2025.4.15",
|
| 34 |
"traceloop-sdk>=0.33.0",
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# =======================
|
| 37 |
# VECTOR DB / INDEXING
|
| 38 |
# =======================
|
|
@@ -93,6 +103,12 @@ dependencies = [
|
|
| 93 |
"streamlit>=1.51.0",
|
| 94 |
"reportlab>=4.4.5",
|
| 95 |
"fastapi",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
# =======================
|
| 98 |
# AUDIO / VIDEO
|
|
|
|
| 33 |
"html2text>=2025.4.15",
|
| 34 |
"traceloop-sdk>=0.33.0",
|
| 35 |
|
| 36 |
+
# =======================
|
| 37 |
+
# MICROSOFT AGENT FRAMEWORK
|
| 38 |
+
# =======================
|
| 39 |
+
#"agent-framework==1.0.0b251204",
|
| 40 |
+
#"agent-framework-azure-ai==1.0.0b251204",
|
| 41 |
+
#"azure-ai-projects",
|
| 42 |
+
#"azure-ai-agents",
|
| 43 |
+
#"azure-ai-agents>=1.2.0b5",
|
| 44 |
+
#"agent-framework-azure-ai",
|
| 45 |
+
|
| 46 |
# =======================
|
| 47 |
# VECTOR DB / INDEXING
|
| 48 |
# =======================
|
|
|
|
| 103 |
"streamlit>=1.51.0",
|
| 104 |
"reportlab>=4.4.5",
|
| 105 |
"fastapi",
|
| 106 |
+
"Pillow",
|
| 107 |
+
"python-docx",
|
| 108 |
+
"matplotlib",
|
| 109 |
+
"fpdf",
|
| 110 |
+
"extra-streamlit-components",
|
| 111 |
+
"nest_asyncio",
|
| 112 |
|
| 113 |
# =======================
|
| 114 |
# AUDIO / VIDEO
|
run.py
CHANGED
|
@@ -72,6 +72,16 @@ APP_REGISTRY: Dict[str, Dict[str, str]] = {
|
|
| 72 |
"path": "src/market-analyst",
|
| 73 |
"entry": "app.py",
|
| 74 |
"description": "Market Analyst - Multi-agent market analysis tool"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
}
|
| 77 |
|
|
|
|
| 72 |
"path": "src/market-analyst",
|
| 73 |
"entry": "app.py",
|
| 74 |
"description": "Market Analyst - Multi-agent market analysis tool"
|
| 75 |
+
},
|
| 76 |
+
"image": {
|
| 77 |
+
"path": "src/image-generator",
|
| 78 |
+
"entry": "app.py",
|
| 79 |
+
"description": "Image Generator - Multi-agent image generation tool"
|
| 80 |
+
},
|
| 81 |
+
"interview-assistant": {
|
| 82 |
+
"path": "src/interview-assistant",
|
| 83 |
+
"entry": "app.py",
|
| 84 |
+
"description": "Interview Assistant - Multi-agent interview tool"
|
| 85 |
}
|
| 86 |
}
|
| 87 |
|
src/market-analyst/README.md
CHANGED
|
@@ -1,80 +1,168 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
emoji: π
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
-
|
| 7 |
-
app_port: 7860
|
| 8 |
-
pinned: false
|
| 9 |
license: mit
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
# π AI Market Analyst
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
## π Features
|
| 18 |
|
| 19 |
-
|
| 20 |
-
- **Market Analyst**: Calculates technicals (SMA 20/50/200, RSI 14) and analyzes trend/momentum.
|
| 21 |
-
- **Sentiment Analyst**: Scrapes full news articles and uses **FinBERT** to score sentiment (Bullish/Bearish).
|
| 22 |
-
- **Strategy Advisor**: Recommends complex option spreads (Iron Condors, Vertical Spreads) with *specific* legs (Strikes/Expiry).
|
| 23 |
-
- **Risk Manager**: Validates trades against a confidence rubric (>70% required) and volatility regime (VIX).
|
| 24 |
-
- **π΅οΈ Deep Sentiment Engine**: Goes beyond headlines by fetching and analyzing the full text of news articles using `BeautifulSoup` and `Transformers` (FinBERT).
|
| 25 |
-
- **β‘ High Performance**: Parallelized news fetching for rapid analysis.
|
| 26 |
-
- **π‘οΈ Guardrails**:
|
| 27 |
-
- **Market Hours**: Only operates during US Market Open (09:30-16:00 ET) to prevent stale data usage.
|
| 28 |
-
- **Type Safety**: Pydantic validation for all data pipelines.
|
| 29 |
-
- **Robustness**: Gracefully handles new IPOs or missing data.
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
### Prerequisites
|
| 50 |
-
- Python 3.12+
|
| 51 |
-
- `uv` package manager (optional but recommended)
|
| 52 |
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
```bash
|
| 57 |
-
pip install -e .
|
| 58 |
-
```
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
The app will open at `http://localhost:8501`.
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
-
# Build
|
| 72 |
-
docker build -t market-analyst -f src/market-analyst/Dockerfile .
|
| 73 |
|
| 74 |
-
|
|
|
|
| 75 |
docker run -p 7860:7860 market-analyst
|
| 76 |
```
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
app_port: 7860
|
|
|
|
| 3 |
colorFrom: blue
|
| 4 |
colorTo: gray
|
| 5 |
+
emoji: π
|
|
|
|
|
|
|
| 6 |
license: mit
|
| 7 |
+
pinned: false
|
| 8 |
+
sdk: docker
|
| 9 |
+
short_description: Multi-agent AI that recommends stock option spreads
|
| 10 |
+
title: AI Market Analyst --- Real-Time Stock & Options Insights
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# π AI Market Analyst --- From Ticker to Strategy
|
| 14 |
+
|
| 15 |
+
Enter a stock ticker and get **real-time technical analysis, news
|
| 16 |
+
sentiment, and AI-generated option strategies** --- all powered by a
|
| 17 |
+
coordinated **multi-agent system**.
|
| 18 |
+
|
| 19 |
+
Designed for **learning, demos, and research** in agentic finance
|
| 20 |
+
workflows.
|
| 21 |
+
|
| 22 |
+
------------------------------------------------------------------------
|
| 23 |
+
|
| 24 |
+
## π Try it with these tickers
|
| 25 |
|
| 26 |
+
- `AAPL` --- Large-cap, steady trend
|
| 27 |
+
- `TSLA` --- High volatility, news-driven
|
| 28 |
+
- `NVDA` --- Momentum + sentiment play
|
| 29 |
+
- `SPY` --- Market-wide signal
|
| 30 |
+
|
| 31 |
+
β¬οΈ Start with one ticker and explore how different agents reason
|
| 32 |
+
together.
|
| 33 |
+
|
| 34 |
+
------------------------------------------------------------------------
|
| 35 |
+
|
| 36 |
+
## β¨ Why this Space is different
|
| 37 |
+
|
| 38 |
+
Most market tools show charts.\
|
| 39 |
+
This one **explains the reasoning** behind a strategy.
|
| 40 |
+
|
| 41 |
+
βοΈ Multiple specialized AI agents (not one monolithic model)\
|
| 42 |
+
βοΈ Combines **technicals + sentiment + volatility**\
|
| 43 |
+
βοΈ Generates **structured option strategies**, not vague advice\
|
| 44 |
+
βοΈ Built with strong guardrails to avoid misleading outputs
|
| 45 |
+
|
| 46 |
+
This Space is a **reference implementation** for agentic AI in finance.
|
| 47 |
+
|
| 48 |
+
------------------------------------------------------------------------
|
| 49 |
|
| 50 |
## π Features
|
| 51 |
|
| 52 |
+
### π§ Multi-Agent Swarm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
Each agent has a single responsibility:
|
| 55 |
|
| 56 |
+
- **Market Analyst Agent**
|
| 57 |
+
- Computes SMA (20 / 50 / 200), RSI (14)
|
| 58 |
+
- Detects trend, momentum, and regime
|
| 59 |
+
- **Sentiment Analyst Agent**
|
| 60 |
+
- Scrapes full news articles (not just headlines)
|
| 61 |
+
- Uses **FinBERT** to classify sentiment as Bullish / Bearish /
|
| 62 |
+
Neutral
|
| 63 |
+
- **Strategy Advisor Agent**
|
| 64 |
+
- Proposes **option spreads** (Iron Condors, Vertical Spreads)
|
| 65 |
+
- Includes concrete legs: strikes, expiry, and structure
|
| 66 |
+
- **Risk Manager Agent**
|
| 67 |
+
- Validates strategies against:
|
| 68 |
+
- Confidence score (\>70% required)
|
| 69 |
+
- Market volatility (VIX regime)
|
| 70 |
+
- Data completeness
|
| 71 |
+
|
| 72 |
+
------------------------------------------------------------------------
|
| 73 |
+
|
| 74 |
+
### π΅οΈ Deep Sentiment Engine
|
| 75 |
|
| 76 |
+
- Fetches **full article text** using `requests` + `BeautifulSoup`
|
| 77 |
+
- Runs transformer-based sentiment analysis (FinBERT)
|
| 78 |
+
- Aggregates sentiment across multiple sources
|
| 79 |
+
|
| 80 |
+
------------------------------------------------------------------------
|
| 81 |
+
|
| 82 |
+
### π‘οΈ Built-in Guardrails
|
| 83 |
+
|
| 84 |
+
- β° **Market Hours Aware**\
|
| 85 |
+
Runs only during US market hours (09:30--16:00 ET)
|
| 86 |
+
|
| 87 |
+
- π§Ύ **Type Safety**\
|
| 88 |
+
End-to-end Pydantic validation
|
| 89 |
+
|
| 90 |
+
- π§― **Robust by Design**\
|
| 91 |
+
Handles missing data, low-liquidity tickers, and new IPOs gracefully
|
| 92 |
+
|
| 93 |
+
------------------------------------------------------------------------
|
| 94 |
+
|
| 95 |
+
## π How it works (high level)
|
| 96 |
+
|
| 97 |
+
1. You enter a stock ticker
|
| 98 |
+
2. Market data is fetched and technical indicators are computed
|
| 99 |
+
3. News articles are scraped and sentiment-scored
|
| 100 |
+
4. Strategy Advisor proposes an option structure
|
| 101 |
+
5. Risk Manager validates or rejects the strategy
|
| 102 |
+
6. Final output includes **analysis + rationale**
|
| 103 |
+
|
| 104 |
+
------------------------------------------------------------------------
|
| 105 |
+
|
| 106 |
+
## π§ͺ Example use cases
|
| 107 |
+
|
| 108 |
+
- Learning **options strategy design**
|
| 109 |
+
- Demonstrating **multi-agent coordination**
|
| 110 |
+
- Building agentic finance prototypes
|
| 111 |
+
- Educational demos (no real-money trading)
|
| 112 |
+
|
| 113 |
+
------------------------------------------------------------------------
|
| 114 |
+
|
| 115 |
+
## π§ Under the hood (for developers)
|
| 116 |
+
|
| 117 |
+
src/market-analyst/
|
| 118 |
+
βββ app.py # Streamlit UI (Agent Orchestrator)
|
| 119 |
+
βββ aagents/ # Agent definitions
|
| 120 |
+
β βββ market_analyst.py # Technical indicators & trends
|
| 121 |
+
β βββ sentiment_analyst.py# FinBERT sentiment engine
|
| 122 |
+
β βββ strategy_advisor.py # Options strategist
|
| 123 |
+
β βββ risk_manager.py # Trade validator
|
| 124 |
+
βββ tools/ # Capability layer
|
| 125 |
+
β βββ market_data.py # yfinance, pandas-ta, options chains
|
| 126 |
+
β βββ news_data.py # DDGS, requests, FinBERT, Pydantic
|
| 127 |
+
βββ Dockerfile # HF Spaces deployment
|
| 128 |
+
|
| 129 |
+
------------------------------------------------------------------------
|
| 130 |
+
|
| 131 |
+
## βΆοΈ Run locally
|
| 132 |
|
| 133 |
### Prerequisites
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
- Python 3.12+
|
| 136 |
+
- Virtual environment recommended
|
| 137 |
|
| 138 |
+
### Install & run
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
+
``` bash
|
| 141 |
+
pip install -e .
|
| 142 |
+
streamlit run src/market-analyst/app.py
|
| 143 |
+
```
|
|
|
|
| 144 |
|
| 145 |
+
App runs at: `http://localhost:8501`
|
| 146 |
|
| 147 |
+
------------------------------------------------------------------------
|
| 148 |
|
| 149 |
+
## π³ Docker / Hugging Face Spaces
|
|
|
|
|
|
|
| 150 |
|
| 151 |
+
``` bash
|
| 152 |
+
docker build -t market-analyst -f src/market-analyst/Dockerfile .
|
| 153 |
docker run -p 7860:7860 market-analyst
|
| 154 |
```
|
| 155 |
|
| 156 |
+
------------------------------------------------------------------------
|
| 157 |
+
|
| 158 |
+
## β οΈ Financial Disclaimer
|
| 159 |
+
|
| 160 |
+
**Educational use only.**\
|
| 161 |
+
This tool is **not** a financial advisor and does **not** provide
|
| 162 |
+
investment advice.\
|
| 163 |
+
Do **not** use for real-money trading.
|
| 164 |
+
|
| 165 |
+
------------------------------------------------------------------------
|
| 166 |
|
| 167 |
+
π‘ Like this Space?\
|
| 168 |
+
β Give it a like Β· π Duplicate it Β· π¬ Share feedback
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|