Dmitry Beresnev
commited on
Commit
·
0abb67a
1
Parent(s):
5ec66b8
fix gitignore
Browse files- .gitignore +3 -1
- NEWS_MONITOR_GUIDE.md +0 -244
.gitignore
CHANGED
|
@@ -31,4 +31,6 @@ test_*.py
|
|
| 31 |
*_test.py
|
| 32 |
tests/__pycache__/
|
| 33 |
# Ignore md files
|
| 34 |
-
*.md
|
|
|
|
|
|
|
|
|
| 31 |
*_test.py
|
| 32 |
tests/__pycache__/
|
| 33 |
# Ignore md files
|
| 34 |
+
*.md
|
| 35 |
+
#
|
| 36 |
+
docs/
|
NEWS_MONITOR_GUIDE.md
DELETED
|
@@ -1,244 +0,0 @@
|
|
| 1 |
-
# 📰 Live Financial News Monitor - Professional Guide
|
| 2 |
-
|
| 3 |
-
## Overview
|
| 4 |
-
|
| 5 |
-
Профессиональная система мониторинга финансовых новостей с минимальной задержкой для трейдеров. Отслеживает макроэкономические, рыночные и геополитические события в режиме реального времени.
|
| 6 |
-
|
| 7 |
-
## 🎯 Ключевые Возможности
|
| 8 |
-
|
| 9 |
-
### 1. Multi-Source Intelligence
|
| 10 |
-
Агрегация новостей из премиальных источников:
|
| 11 |
-
- **Bloomberg Business** - вес 1.5 (высокая достоверность)
|
| 12 |
-
- **Reuters** - вес 1.5
|
| 13 |
-
- **Wall Street Journal** - вес 1.4
|
| 14 |
-
- **Financial Times** - вес 1.4
|
| 15 |
-
- **Federal Reserve** - вес 2.0 (наивысший приоритет)
|
| 16 |
-
- **CNBC, MarketWatch, Zero Hedge, Barron's, The Economist**
|
| 17 |
-
|
| 18 |
-
### 2. Intelligent Categorization
|
| 19 |
-
Автоматическая категоризация новостей:
|
| 20 |
-
- **MACRO** - монетарная политика, ЦБ, экономические индикаторы
|
| 21 |
-
- **MARKETS** - фондовые индексы, earnings, корпоративные события
|
| 22 |
-
- **GEOPOLITICAL** - конфликты, санкции, выборы, торговые войны
|
| 23 |
-
|
| 24 |
-
### 3. Sentiment Analysis
|
| 25 |
-
Профессиональный анализ настроений для трейдинга:
|
| 26 |
-
- **Positive** - rally, surge, growth, beat expectations
|
| 27 |
-
- **Negative** - crash, plunge, recession, crisis
|
| 28 |
-
- **Neutral** - нейтральный тон
|
| 29 |
-
|
| 30 |
-
### 4. Impact Assessment
|
| 31 |
-
Оценка влияния на рынки:
|
| 32 |
-
- **HIGH** - критические события, breaking news, высокое engagement
|
| 33 |
-
- **MEDIUM** - важные новости, средний уровень внимания
|
| 34 |
-
- **LOW** - второстепенные новости
|
| 35 |
-
|
| 36 |
-
### 5. Breaking News Detection
|
| 37 |
-
Мгновенная идентификация экстренных новостей по ключевым словам:
|
| 38 |
-
- BREAKING, ALERT, URGENT, Fed, Powell, emergency, surprise
|
| 39 |
-
|
| 40 |
-
## 🔧 Технические Характеристики
|
| 41 |
-
|
| 42 |
-
### Low-Latency Architecture
|
| 43 |
-
```python
|
| 44 |
-
# Кэширование с TTL 3 минуты
|
| 45 |
-
cache_ttl = 180 # секунд
|
| 46 |
-
|
| 47 |
-
# Streamlit кэширование для оптимизации
|
| 48 |
-
@st.cache_data(ttl=180)
|
| 49 |
-
def scrape_twitter_news(max_tweets=100)
|
| 50 |
-
```
|
| 51 |
-
|
| 52 |
-
### Performance Optimization
|
| 53 |
-
- **Параллельный сбор** из множественных источников
|
| 54 |
-
- **Умное кэширование** с автоматической инвалидацией
|
| 55 |
-
- **Фильтрация по времени** (только последние 24 часа)
|
| 56 |
-
- **Weighted scoring** на основе достоверности источника
|
| 57 |
-
|
| 58 |
-
### Data Structure
|
| 59 |
-
```python
|
| 60 |
-
{
|
| 61 |
-
'id': tweet_id,
|
| 62 |
-
'title': full_content,
|
| 63 |
-
'summary': truncated_summary,
|
| 64 |
-
'source': 'Bloomberg',
|
| 65 |
-
'category': 'macro',
|
| 66 |
-
'timestamp': datetime,
|
| 67 |
-
'sentiment': 'positive',
|
| 68 |
-
'impact': 'high',
|
| 69 |
-
'url': tweet_url,
|
| 70 |
-
'likes': 2500,
|
| 71 |
-
'retweets': 800,
|
| 72 |
-
'is_breaking': True,
|
| 73 |
-
'source_weight': 1.5
|
| 74 |
-
}
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
## 📊 Использование для Трейдинга
|
| 78 |
-
|
| 79 |
-
### Pre-Market Analysis
|
| 80 |
-
1. Проверяйте breaking news перед открытием рынка
|
| 81 |
-
2. Фокус на macro категории для understanding макротрендов
|
| 82 |
-
3. High impact + negative sentiment = потенциальная волатильность
|
| 83 |
-
|
| 84 |
-
### Intraday Trading
|
| 85 |
-
1. Enable auto-refresh (3 min) для непрерывного мониторинга
|
| 86 |
-
2. Отслеживайте earnings announcements (markets category)
|
| 87 |
-
3. Геополитические события могут вызвать резкие движения
|
| 88 |
-
|
| 89 |
-
### Risk Management
|
| 90 |
-
1. Breaking news с high impact требует немедленного внимания
|
| 91 |
-
2. Negative sentiment в macro = потенциальный selloff
|
| 92 |
-
3. Fed announcements (source_weight 2.0) = критическое влияние
|
| 93 |
-
|
| 94 |
-
## 🎨 UI Features
|
| 95 |
-
|
| 96 |
-
### Breaking News Banner
|
| 97 |
-
Красный баннер с анимацией для экстренных новостей:
|
| 98 |
-
- Пульсирующая анимация
|
| 99 |
-
- Моментальный доступ к источнику
|
| 100 |
-
- Приоритетное отображение
|
| 101 |
-
|
| 102 |
-
### News Cards
|
| 103 |
-
Профессиональные карточки новостей с:
|
| 104 |
-
- Color-coded sentiment indicator
|
| 105 |
-
- Impact level badges
|
| 106 |
-
- Engagement metrics (likes + retweets)
|
| 107 |
-
- Time-since-publication
|
| 108 |
-
- Direct links to sources
|
| 109 |
-
|
| 110 |
-
### Smart Filters
|
| 111 |
-
- Category (Macro/Markets/Geopolitical)
|
| 112 |
-
- Sentiment (Positive/Negative/Neutral)
|
| 113 |
-
- Impact Level (High/Medium/Low)
|
| 114 |
-
|
| 115 |
-
## 🚀 Advanced Features
|
| 116 |
-
|
| 117 |
-
### Keyword Detection Algorithms
|
| 118 |
-
|
| 119 |
-
**Macro Keywords** (43 keywords):
|
| 120 |
-
```python
|
| 121 |
-
['Fed', 'ECB', 'BoE', 'BoJ', 'FOMC', 'Powell', 'Lagarde',
|
| 122 |
-
'interest rate', 'rate cut', 'rate hike', 'QE',
|
| 123 |
-
'GDP', 'inflation', 'CPI', 'PPI', 'PCE', 'NFP',
|
| 124 |
-
'unemployment', 'retail sales', 'PMI', 'ISM',
|
| 125 |
-
'recession', 'stimulus', 'yield curve', ...]
|
| 126 |
-
```
|
| 127 |
-
|
| 128 |
-
**Geopolitical Keywords**:
|
| 129 |
-
```python
|
| 130 |
-
['war', 'conflict', 'sanctions', 'embargo',
|
| 131 |
-
'election', 'coup', 'protest', 'crisis',
|
| 132 |
-
'trade war', 'tariff', 'China', 'Russia',
|
| 133 |
-
'Taiwan', 'Middle East', 'Ukraine', ...]
|
| 134 |
-
```
|
| 135 |
-
|
| 136 |
-
**Market Keywords**:
|
| 137 |
-
```python
|
| 138 |
-
['S&P', 'Nasdaq', 'Dow', 'VIX', 'volatility',
|
| 139 |
-
'rally', 'sell-off', 'correction', 'crash',
|
| 140 |
-
'earnings', 'IPO', 'merger', 'M&A',
|
| 141 |
-
'Bitcoin', 'oil', 'gold', 'dollar', ...]
|
| 142 |
-
```
|
| 143 |
-
|
| 144 |
-
### Source Specialization
|
| 145 |
-
Каждый источник имеет специализацию для boost scoring:
|
| 146 |
-
```python
|
| 147 |
-
'bloomberg': {
|
| 148 |
-
'weight': 1.5,
|
| 149 |
-
'specialization': ['macro', 'markets']
|
| 150 |
-
}
|
| 151 |
-
```
|
| 152 |
-
|
| 153 |
-
## 📈 Performance Metrics
|
| 154 |
-
|
| 155 |
-
### Latency
|
| 156 |
-
- **Fetch time**: ~2-5 секунд для 100 твитов
|
| 157 |
-
- **Cache TTL**: 180 секунд (3 минуты)
|
| 158 |
-
- **UI render**: < 1 секунда
|
| 159 |
-
|
| 160 |
-
### Coverage
|
| 161 |
-
- **10 премиальных источников**
|
| 162 |
-
- **100+ твитов за цикл**
|
| 163 |
-
- **Последние 24 часа новостей**
|
| 164 |
-
|
| 165 |
-
### Accuracy
|
| 166 |
-
- **Source weighting** для достоверности
|
| 167 |
-
- **Multi-keyword matching** для точной категоризации
|
| 168 |
-
- **Engagement-based** оценка важности
|
| 169 |
-
|
| 170 |
-
## 🔐 Configuration
|
| 171 |
-
|
| 172 |
-
### Requirements
|
| 173 |
-
```bash
|
| 174 |
-
pip install snscrape>=3.4.0
|
| 175 |
-
```
|
| 176 |
-
|
| 177 |
-
### Mock Data Mode
|
| 178 |
-
Если snscrape недоступен, автоматически включается режим mock data с примерами новостей.
|
| 179 |
-
|
| 180 |
-
## 💡 Pro Tips for Traders
|
| 181 |
-
|
| 182 |
-
1. **Morning Routine**: Check breaking + high impact news за последний час
|
| 183 |
-
2. **Pre-Fed Meetings**: Filter macro + Federal Reserve для context
|
| 184 |
-
3. **Earnings Season**: Focus на markets category
|
| 185 |
-
4. **Geopolitical Tensions**: Monitor geopolitical + high impact
|
| 186 |
-
5. **Risk Events**: Breaking news = stop losses ready
|
| 187 |
-
|
| 188 |
-
## 🛠️ Troubleshooting
|
| 189 |
-
|
| 190 |
-
### snscrape Issues
|
| 191 |
-
```python
|
| 192 |
-
# Fallback to mock data automatically
|
| 193 |
-
SNSCRAPE_AVAILABLE = False
|
| 194 |
-
# Returns sample news for testing
|
| 195 |
-
```
|
| 196 |
-
|
| 197 |
-
### Rate Limiting
|
| 198 |
-
- Built-in caching prevents excessive requests
|
| 199 |
-
- 3-minute TTL балансирует freshness vs. API limits
|
| 200 |
-
|
| 201 |
-
### Empty Results
|
| 202 |
-
- Check filters (возможно слишком строгие)
|
| 203 |
-
- Verify Twitter API доступность
|
| 204 |
-
- Try "Refresh Now" button
|
| 205 |
-
|
| 206 |
-
## 📚 Architecture
|
| 207 |
-
|
| 208 |
-
```
|
| 209 |
-
services/news_monitor.py
|
| 210 |
-
├── FinanceNewsMonitor (main class)
|
| 211 |
-
│ ├── scrape_twitter_news() - data collection
|
| 212 |
-
│ ├── _categorize_tweet() - ML categorization
|
| 213 |
-
│ ├── _analyze_sentiment() - sentiment analysis
|
| 214 |
-
│ ├── _assess_impact() - importance scoring
|
| 215 |
-
│ └── get_news() - filtered retrieval
|
| 216 |
-
|
| 217 |
-
components/news.py
|
| 218 |
-
├── display_news_card() - individual card rendering
|
| 219 |
-
├── display_news_feed() - feed layout
|
| 220 |
-
├── display_breaking_news_banner() - alerts
|
| 221 |
-
└── display_news_statistics() - metrics
|
| 222 |
-
|
| 223 |
-
pages/05_Dashboard.py
|
| 224 |
-
└── Complete news dashboard UI
|
| 225 |
-
```
|
| 226 |
-
|
| 227 |
-
## 🎓 Learning Resources
|
| 228 |
-
|
| 229 |
-
### Understanding Impact Levels
|
| 230 |
-
- **High**: engagement > 1500 OR source_weight >= 2.0 OR breaking
|
| 231 |
-
- **Medium**: engagement 300-1500
|
| 232 |
-
- **Low**: engagement < 300
|
| 233 |
-
|
| 234 |
-
### Reading Engagement Metrics
|
| 235 |
-
```python
|
| 236 |
-
weighted_engagement = (likes + retweets * 2) * source_weight
|
| 237 |
-
```
|
| 238 |
-
Retweets имеют двойной вес, источники с высокой достоверностью повышают score.
|
| 239 |
-
|
| 240 |
-
---
|
| 241 |
-
|
| 242 |
-
**Built by professional traders, for professional traders** 🚀
|
| 243 |
-
|
| 244 |
-
*Минимальная задержка. Максимальная информированность.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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