diff --git a/.env.example b/.env.example index 3ae41e0..9340c2b 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,12 @@ -# MongoDB Atlas Connection -MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/ +# MongoDB Atlas Connection (managed by Doppler) +# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/ # Database Configuration MONGODB_DATABASE=taigong # Swarm Debate Configuration SWARM_THRESHOLD=5 -SWARM_TIME_WINDOW_HOURS=24 \ No newline at end of file +SWARM_TIME_WINDOW_HOURS=24 + +# Note: Sensitive secrets like MONGODB_URI are managed by Doppler +# Run: doppler secrets set MONGODB_URI "your-connection-string" \ No newline at end of file diff --git a/.gitguardian.yaml b/.gitguardian.yaml new file mode 100644 index 0000000..1972383 --- /dev/null +++ b/.gitguardian.yaml @@ -0,0 +1,45 @@ +# GitGuardian configuration for liurenchaxin project +version: 2 + +# Paths to exclude from scanning +paths_ignore: + - venv/ + - .git/ + - node_modules/ + - __pycache__/ + - "*.pyc" + - "*.log" + - .kiro/ + - examples/ + - tests/fixtures/ + - tools/ + +# File patterns to exclude +patterns_ignore: + - "*.min.js" + - "*.bundle.js" + - "*.map" + - "*.lock" + - "package-lock.json" + - "yarn.lock" + +# Only scan specific file types for secrets +match_policy: + - "*.py" + - "*.js" + - "*.ts" + - "*.json" + - "*.yaml" + - "*.yml" + - "*.env.example" + - "*.md" + - "*.sh" + +# Exclude .env files from scanning (they should be in .gitignore anyway) +paths_ignore_patterns: + - ".env" + - ".env.local" + - ".env.production" + +# Secret detection settings +secret_scan_preference: secret \ No newline at end of file diff --git a/docs/rapidapi/api_inventory.md b/docs/rapidapi/api_inventory.md index 98cb081..28304d8 100644 --- a/docs/rapidapi/api_inventory.md +++ b/docs/rapidapi/api_inventory.md @@ -4,7 +4,7 @@ 基于Doppler配置和实际测试,记录当前RapidAPI订阅的API服务及其可用性。 -**API密钥**: `6731900a13msh816fbe854209ac2p1bded2jsn1538144d52a4` +**API密钥**: `[REDACTED - 从Doppler获取RAPIDAPI_KEY]` **总订阅数**: 17个API服务 **最后更新**: 2025-08-02 @@ -193,4 +193,4 @@ **维护者**: Ben **联系方式**: 通过Doppler配置管理API密钥 -**更新频率**: 每次API测试后更新 \ No newline at end of file +**更新频率**: 每次API测试后更新 diff --git a/docs/rapidapi/jixia_load_balancing_strategy.md b/docs/rapidapi/jixia_load_balancing_strategy.md new file mode 100644 index 0000000..9257992 --- /dev/null +++ b/docs/rapidapi/jixia_load_balancing_strategy.md @@ -0,0 +1,341 @@ +# 🏛️ 稷下学宫八仙论道负载分担策略 + +## 📋 概述 + +基于现有的RapidAPI订阅和雅虎财经数据接口,设计一套智能负载分担策略,让八仙论道系统中的不同角色调用不同的API端点获取相同类型的数据,实现API负载均衡和系统稳定性。 + +## 🎯 核心理念 + +**"同样的数据,不同的路径"** - 通过多API轮换获取相同类型的市场数据,避免单一API过载,确保系统稳定运行。 + +## 📊 可用API资源清单 + +### ✅ 已验证可用的API (4个) + +```python +AVAILABLE_APIS = { + 'alpha_vantage': { + 'host': 'alpha-vantage.p.rapidapi.com', + 'response_time': 1.26, + 'rate_limit': '500/min, 500k/month', + 'specialty': ['stock_quote', 'company_overview', 'earnings'] + }, + 'yahoo_finance_15': { + 'host': 'yahoo-finance15.p.rapidapi.com', + 'response_time': 2.07, + 'rate_limit': '500/min, 500k/month', + 'specialty': ['stock_quote', 'market_movers', 'news'] + }, + 'webull': { + 'host': 'webull.p.rapidapi.com', + 'response_time': 1.56, + 'rate_limit': '500/min, 500k/month', + 'specialty': ['stock_search', 'market_gainers'] + }, + 'seeking_alpha': { + 'host': 'seeking-alpha.p.rapidapi.com', + 'response_time': 3.32, + 'rate_limit': '500/min, 500k/month', + 'specialty': ['company_profile', 'market_analysis'] + } +} +``` + +## 🎭 八仙负载分担配置 + +### 数据类型映射策略 + +```python +DATA_TYPE_API_MAPPING = { + # 股票报价数据 - 3个API可提供 + 'stock_quote': { + '吕洞宾': 'alpha_vantage', # 主力剑仙用最快的API + '何仙姑': 'yahoo_finance_15', # 风控专家用稳定的API + '张果老': 'webull', # 技术分析师用搜索强的API + '韩湘子': 'alpha_vantage', # 基本面研究用专业API + '汉钟离': 'yahoo_finance_15', # 量化专家用市场数据API + '蓝采和': 'webull', # 情绪分析师用活跃数据API + '曹国舅': 'seeking_alpha', # 宏观分析师用分析API + '铁拐李': 'alpha_vantage' # 逆向投资用基础数据API + }, + + # 公司概览数据 - 2个API可提供 + 'company_overview': { + '吕洞宾': 'alpha_vantage', # 技术分析需要完整数据 + '何仙姑': 'seeking_alpha', # 风控需要分析师观点 + '张果老': 'alpha_vantage', # 技术分析偏好数据API + '韩湘子': 'seeking_alpha', # 基本面研究需要深度分析 + '汉钟离': 'alpha_vantage', # 量化需要结构化数据 + '蓝采和': 'seeking_alpha', # 情绪分析需要市场观点 + '曹国舅': 'seeking_alpha', # 宏观分析需要专业观点 + '铁拐李': 'alpha_vantage' # 逆向投资需要基础数据 + }, + + # 市场动态数据 - 2个API可提供 + 'market_movers': { + '吕洞宾': 'yahoo_finance_15', # 剑仙关注市场热点 + '何仙姑': 'webull', # 风控关注活跃股票 + '张果老': 'yahoo_finance_15', # 技术分析关注涨跌榜 + '韩湘子': 'webull', # 基本面研究关注搜索热度 + '汉钟离': 'yahoo_finance_15', # 量化关注市场数据 + '蓝采和': 'webull', # 情绪分析关注活跃度 + '曹国舅': 'yahoo_finance_15', # 宏观关注整体趋势 + '铁拐李': 'webull' # 逆向投资关注异常股票 + }, + + # 新闻和分析数据 - 2个API可提供 + 'market_news': { + '吕洞宾': 'yahoo_finance_15', # 剑仙需要快速资讯 + '何仙姑': 'seeking_alpha', # 风控需要深度分析 + '张果老': 'yahoo_finance_15', # 技术分析关注市场新闻 + '韩湘子': 'seeking_alpha', # 基本面需要分析师观点 + '汉钟离': 'yahoo_finance_15', # 量化关注数据驱动新闻 + '蓝采和': 'seeking_alpha', # 情绪分析需要市场情绪 + '曹国舅': 'seeking_alpha', # 宏观需要政策分析 + '铁拐李': 'yahoo_finance_15' # 逆向投资关注反向指标 + } +} +``` + +## 🔄 智能轮换策略 + +### 1. 时间窗口轮换 + +```python +TIME_BASED_ROTATION = { + # 交易时段 (9:30-16:00 EST) - 优先使用快速API + 'trading_hours': { + 'primary_apis': ['alpha_vantage', 'webull'], + 'backup_apis': ['yahoo_finance_15', 'seeking_alpha'] + }, + + # 非交易时段 - 可以使用较慢但更详细的API + 'after_hours': { + 'primary_apis': ['seeking_alpha', 'yahoo_finance_15'], + 'backup_apis': ['alpha_vantage', 'webull'] + } +} +``` + +### 2. 负载感知轮换 + +```python +LOAD_AWARE_ROTATION = { + # 当某个API接近限制时,自动切换到其他API + 'rate_limit_thresholds': { + 'alpha_vantage': 450, # 90% of 500/min + 'yahoo_finance_15': 450, + 'webull': 450, + 'seeking_alpha': 450 + }, + + # 故障转移优先级 + 'failover_priority': { + 'alpha_vantage': ['webull', 'yahoo_finance_15'], + 'yahoo_finance_15': ['webull', 'alpha_vantage'], + 'webull': ['alpha_vantage', 'yahoo_finance_15'], + 'seeking_alpha': ['yahoo_finance_15', 'alpha_vantage'] + } +} +``` + +## 🏗️ 实现架构 + +### 核心组件 + +```python +class JixiaLoadBalancer: + """稷下学宫负载均衡器""" + + def __init__(self): + self.api_pool = APIPool(AVAILABLE_APIS) + self.immortal_mapping = DATA_TYPE_API_MAPPING + self.rate_limiter = RateLimiter() + self.health_checker = APIHealthChecker() + + def get_data_for_immortal(self, immortal_name: str, data_type: str, symbol: str): + """为特定仙人获取数据""" + # 1. 获取该仙人的首选API + preferred_api = self.immortal_mapping[data_type][immortal_name] + + # 2. 检查API健康状态和速率限制 + if self.is_api_available(preferred_api): + return self.call_api(preferred_api, data_type, symbol) + + # 3. 故障转移到备用API + backup_apis = LOAD_AWARE_ROTATION['failover_priority'][preferred_api] + for backup_api in backup_apis: + if self.is_api_available(backup_api): + return self.call_api(backup_api, data_type, symbol) + + # 4. 如果所有API都不可用,返回缓存数据 + return self.get_cached_data(data_type, symbol) + + def is_api_available(self, api_name: str) -> bool: + """检查API是否可用""" + # 检查健康状态 + if not self.health_checker.is_healthy(api_name): + return False + + # 检查速率限制 + if self.rate_limiter.is_rate_limited(api_name): + return False + + return True +``` + +### 数据统一化处理 + +```python +class DataNormalizer: + """数据标准化处理器""" + + def normalize_stock_quote(self, raw_data: dict, api_source: str) -> dict: + """将不同API的股票报价数据标准化""" + if api_source == 'alpha_vantage': + return self._normalize_alpha_vantage_quote(raw_data) + elif api_source == 'yahoo_finance_15': + return self._normalize_yahoo_quote(raw_data) + elif api_source == 'webull': + return self._normalize_webull_quote(raw_data) + + def _normalize_alpha_vantage_quote(self, data: dict) -> dict: + """标准化Alpha Vantage数据格式""" + global_quote = data.get('Global Quote', {}) + return { + 'symbol': global_quote.get('01. symbol'), + 'price': float(global_quote.get('05. price', 0)), + 'change': float(global_quote.get('09. change', 0)), + 'change_percent': global_quote.get('10. change percent', '0%'), + 'volume': int(global_quote.get('06. volume', 0)), + 'source': 'alpha_vantage' + } + + def _normalize_yahoo_quote(self, data: dict) -> dict: + """标准化Yahoo Finance数据格式""" + body = data.get('body', {}) + return { + 'symbol': body.get('symbol'), + 'price': float(body.get('regularMarketPrice', 0)), + 'change': float(body.get('regularMarketChange', 0)), + 'change_percent': f"{body.get('regularMarketChangePercent', 0):.2f}%", + 'volume': int(body.get('regularMarketVolume', 0)), + 'source': 'yahoo_finance_15' + } +``` + +## 📊 监控和统计 + +### API使用统计 + +```python +class APIUsageMonitor: + """API使用监控器""" + + def __init__(self): + self.usage_stats = { + 'alpha_vantage': {'calls': 0, 'errors': 0, 'avg_response_time': 0}, + 'yahoo_finance_15': {'calls': 0, 'errors': 0, 'avg_response_time': 0}, + 'webull': {'calls': 0, 'errors': 0, 'avg_response_time': 0}, + 'seeking_alpha': {'calls': 0, 'errors': 0, 'avg_response_time': 0} + } + + def record_api_call(self, api_name: str, response_time: float, success: bool): + """记录API调用统计""" + stats = self.usage_stats[api_name] + stats['calls'] += 1 + if not success: + stats['errors'] += 1 + + # 更新平均响应时间 + current_avg = stats['avg_response_time'] + total_calls = stats['calls'] + stats['avg_response_time'] = (current_avg * (total_calls - 1) + response_time) / total_calls + + def get_load_distribution(self) -> dict: + """获取负载分布统计""" + total_calls = sum(stats['calls'] for stats in self.usage_stats.values()) + if total_calls == 0: + return {} + + return { + api: { + 'percentage': (stats['calls'] / total_calls) * 100, + 'success_rate': ((stats['calls'] - stats['errors']) / stats['calls']) * 100 if stats['calls'] > 0 else 0, + 'avg_response_time': stats['avg_response_time'] + } + for api, stats in self.usage_stats.items() + } +``` + +## 🎯 实施计划 + +### 第一阶段:基础负载均衡 +1. **实现核心负载均衡器** - 基本的API轮换逻辑 +2. **数据标准化处理** - 统一不同API的数据格式 +3. **简单故障转移** - 基本的备用API切换 + +### 第二阶段:智能优化 +1. **速率限制监控** - 实时监控API使用情况 +2. **健康检查机制** - 定期检测API可用性 +3. **性能优化** - 基于响应时间优化API选择 + +### 第三阶段:高级功能 +1. **预测性负载均衡** - 基于历史数据预测API负载 +2. **成本优化** - 基于API成本优化调用策略 +3. **实时监控面板** - 可视化API使用情况 + +## 📈 预期效果 + +### 性能提升 +- **API负载分散**: 单个API负载降低60-70% +- **系统稳定性**: 故障率降低80%以上 +- **响应速度**: 平均响应时间提升30% + +### 成本控制 +- **API使用优化**: 避免单一API过度使用 +- **故障恢复**: 减少因API故障导致的数据缺失 +- **扩展性**: 支持更多API的无缝接入 + +## 🔧 配置示例 + +### 环境配置 +```bash +# Doppler环境变量 +RAPIDAPI_KEY=your_rapidapi_key +ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key + +# 负载均衡配置 +LOAD_BALANCER_ENABLED=true +API_HEALTH_CHECK_INTERVAL=300 # 5分钟 +RATE_LIMIT_BUFFER=50 # 保留50个请求的缓冲 +``` + +### 使用示例 +```python +# 在稷下学宫系统中使用 +from jixia_load_balancer import JixiaLoadBalancer + +load_balancer = JixiaLoadBalancer() + +# 八仙论道时,每个仙人获取数据 +for immortal in ['吕洞宾', '何仙姑', '张果老', '韩湘子', '汉钟离', '蓝采和', '曹国舅', '铁拐李']: + quote_data = load_balancer.get_data_for_immortal(immortal, 'stock_quote', 'TSLA') + overview_data = load_balancer.get_data_for_immortal(immortal, 'company_overview', 'TSLA') + + print(f"{immortal}: 获取到{quote_data['source']}的数据") +``` + +--- + +## 🎉 总结 + +通过这套负载分担策略,稷下学宫八仙论道系统可以: + +1. **智能分配API调用** - 不同仙人使用不同API获取相同数据 +2. **实现真正的负载均衡** - 避免单一API过载 +3. **提高系统稳定性** - 多重故障转移保障 +4. **优化成本效益** - 充分利用现有API资源 +5. **支持无缝扩展** - 新API可轻松接入系统 + +**"八仙过海,各显神通"** - 让每个仙人都有自己的数据获取路径,共同构建稳定可靠的智能投资决策系统!🚀 \ No newline at end of file diff --git a/internal/analysis/rapidapi_subscription_report.md b/internal/analysis/rapidapi_subscription_report.md index 03438e9..3aa4f61 100644 --- a/internal/analysis/rapidapi_subscription_report.md +++ b/internal/analysis/rapidapi_subscription_report.md @@ -2,7 +2,7 @@ ## 📊 总体概况 -**API Key**: `6731900a13msh816fbe854209ac2p1bded2jsn1538144d52a4` +**API Key**: `[REDACTED - 从Doppler获取RAPIDAPI_KEY]` **订阅总数**: 16个 (根据控制台显示) **24小时调用**: 9次 **已确认可用**: 4个核心API diff --git a/internal/docs/openhands_integration_guide.md b/internal/docs/openhands_integration_guide.md index 36c41bd..2d465d6 100644 --- a/internal/docs/openhands_integration_guide.md +++ b/internal/docs/openhands_integration_guide.md @@ -64,7 +64,7 @@ verifier = LingbaoFieldVerifier( openmanus_url="your-openmanus-url", api_key="your-openmanus-key", - openhands_api_key="hA04ZDQbdKUbBCqmN5ZPFkcdK0xsKLwX" + openhands_api_key="[REDACTED - 从Doppler获取OPENHANDS_API_KEY]" ) # 执行验证 @@ -110,7 +110,7 @@ from src.core.openhands_integration import LingbaoOpenHandsVerifier # 创建验证器 verifier = LingbaoOpenHandsVerifier( - api_key="hA04ZDQbdKUbBCqmN5ZPFkcdK0xsKLwX" + api_key="[REDACTED - 从Doppler获取OPENHANDS_API_KEY]" ) # 验证辩论结论 @@ -132,7 +132,7 @@ from src.core.lingbao_field_verification import LingbaoFieldVerifier verifier = LingbaoFieldVerifier( openmanus_url="your-openmanus-url", api_key="your-api-key", - openhands_api_key="hA04ZDQbdKUbBCqmN5ZPFkcdK0xsKLwX" + openhands_api_key="[REDACTED - 从Doppler获取OPENHANDS_API_KEY]" ) # 执行完整验证流程 @@ -190,7 +190,7 @@ tianzun_report = await verifier.verify_debate_result(debate_result) ```bash # OpenHands配置 -OPENHANDS_API_KEY=hA04ZDQbdKUbBCqmN5ZPFkcdK0xsKLwX +OPENHANDS_API_KEY=[REDACTED - 从Doppler获取OPENHANDS_API_KEY] OPENHANDS_BASE_URL=https://app.all-hands.dev OPENHANDS_TIMEOUT=300 @@ -224,7 +224,7 @@ pip install aiohttp pydantic ```python # 在.env文件中配置 -OPENHANDS_API_KEY=hA04ZDQbdKUbBCqmN5ZPFkcdK0xsKLwX +OPENHANDS_API_KEY=[REDACTED - 从Doppler获取OPENHANDS_API_KEY] ``` ### 3. 运行演示 diff --git a/meta_analysis_results.txt b/meta_analysis_results.txt new file mode 100644 index 0000000..70895af --- /dev/null +++ b/meta_analysis_results.txt @@ -0,0 +1,2884 @@ +✅ 成功获取 Alpha Vantage API Key: 4HDGAT4Z... + +🔍 正在获取 META 的财务数据... + +📊 获取公司概览... + +============================================================ +META - 公司概览 +============================================================ +{ + "Symbol": "META", + "AssetType": "Common Stock", + "Name": "Meta Platforms Inc.", + "Description": "Meta Platforms, Inc. develops products that enable people to connect and share with friends and family through mobile devices, PCs, virtual reality headsets, wearables and home devices around the world. The company is headquartered in Menlo Park, California.", + "CIK": "1326801", + "Exchange": "NASDAQ", + "Currency": "USD", + "Country": "USA", + "Sector": "TECHNOLOGY", + "Industry": "SERVICES-COMPUTER PROGRAMMING, DATA PROCESSING, ETC.", + "Address": "1601 WILLOW ROAD, MENLO PARK, CA, US", + "OfficialSite": "https://investor.atmeta.com", + "FiscalYearEnd": "December", + "LatestQuarter": "2025-06-30", + "MarketCapitalization": "1884130116000", + "EBITDA": "94279999000", + "PERatio": "27.24", + "PEGRatio": "2.403", + "BookValue": "77.47", + "DividendPerShare": "2.05", + "DividendYield": "0.0027", + "EPS": "27.53", + "RevenuePerShareTTM": "70.81", + "ProfitMargin": "0.4", + "OperatingMarginTTM": "0.43", + "ReturnOnAssetsTTM": "0.185", + "ReturnOnEquityTTM": "0.406", + "RevenueTTM": "178803999000", + "GrossProfitTTM": "146558992000", + "DilutedEPSTTM": "27.53", + "QuarterlyEarningsGrowthYOY": "0.384", + "QuarterlyRevenueGrowthYOY": "0.216", + "AnalystTargetPrice": "844.48", + "AnalystRatingStrongBuy": "10", + "AnalystRatingBuy": "51", + "AnalystRatingHold": "6", + "AnalystRatingSell": "0", + "AnalystRatingStrongSell": "1", + "TrailingPE": "27.24", + "ForwardPE": "28.82", + "PriceToSalesRatioTTM": "10.54", + "PriceToBookRatio": "9.66", + "EVToRevenue": "10.55", + "EVToEBITDA": "19.26", + "Beta": "1.284", + "52WeekHigh": "784.75", + "52WeekLow": "449.26", + "50DayMovingAverage": "699.01", + "200DayMovingAverage": "629.11", + "SharesOutstanding": "2168960000", + "SharesFloat": "2169861000", + "PercentInsiders": "0.069", + "PercentInstitutions": "80.066", + "DividendDate": "2025-06-26", + "ExDividendDate": "2025-06-16" +} + +📈 获取财报数据... + +============================================================ +META - 财报数据 +============================================================ +{ + "symbol": "META", + "annualEarnings": [ + { + "fiscalDateEnding": "2025-06-30", + "reportedEPS": "13.57" + }, + { + "fiscalDateEnding": "2024-12-31", + "reportedEPS": "23.92" + }, + { + "fiscalDateEnding": "2023-12-31", + "reportedEPS": "14.9" + }, + { + "fiscalDateEnding": "2022-12-31", + "reportedEPS": "8.58" + }, + { + "fiscalDateEnding": "2021-12-31", + "reportedEPS": "13.8" + }, + { + "fiscalDateEnding": "2020-12-31", + "reportedEPS": "9.79" + }, + { + "fiscalDateEnding": "2019-12-31", + "reportedEPS": "6.44" + }, + { + "fiscalDateEnding": "2018-12-31", + "reportedEPS": "7.57" + }, + { + "fiscalDateEnding": "2017-12-31", + "reportedEPS": "5.71" + }, + { + "fiscalDateEnding": "2016-12-31", + "reportedEPS": "3.51" + }, + { + "fiscalDateEnding": "2015-12-31", + "reportedEPS": "1.77" + }, + { + "fiscalDateEnding": "2014-12-31", + "reportedEPS": "1.31" + }, + { + "fiscalDateEnding": "2013-12-31", + "reportedEPS": "0.65" + }, + { + "fiscalDateEnding": "2012-12-31", + "reportedEPS": "0.1945" + } + ], + "quarterlyEarnings": [ + { + "fiscalDateEnding": "2025-06-30", + "reportedDate": "2025-07-30", + "reportedEPS": "7.14", + "estimatedEPS": "5.89", + "surprise": "1.25", + "surprisePercentage": "21.2224", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2025-03-31", + "reportedDate": "2025-04-30", + "reportedEPS": "6.43", + "estimatedEPS": "5.22", + "surprise": "1.21", + "surprisePercentage": "23.1801", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2024-12-31", + "reportedDate": "2025-01-29", + "reportedEPS": "8.02", + "estimatedEPS": "6.68", + "surprise": "1.34", + "surprisePercentage": "20.0599", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2024-09-30", + "reportedDate": "2024-10-30", + "reportedEPS": "6.03", + "estimatedEPS": "5.3", + "surprise": "0.73", + "surprisePercentage": "13.7736", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2024-06-30", + "reportedDate": "2024-07-31", + "reportedEPS": "5.16", + "estimatedEPS": "4.76", + "surprise": "0.4", + "surprisePercentage": "8.4034", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2024-03-31", + "reportedDate": "2024-04-24", + "reportedEPS": "4.71", + "estimatedEPS": "4.32", + "surprise": "0.39", + "surprisePercentage": "9.0278", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2023-12-31", + "reportedDate": "2024-02-01", + "reportedEPS": "5.33", + "estimatedEPS": "4.96", + "surprise": "0.37", + "surprisePercentage": "7.4597", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2023-09-30", + "reportedDate": "2023-10-25", + "reportedEPS": "4.39", + "estimatedEPS": "3.6", + "surprise": "0.79", + "surprisePercentage": "21.9444", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2023-06-30", + "reportedDate": "2023-07-26", + "reportedEPS": "2.98", + "estimatedEPS": "2.87", + "surprise": "0.11", + "surprisePercentage": "3.8328", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2023-03-31", + "reportedDate": "2023-04-26", + "reportedEPS": "2.2", + "estimatedEPS": "1.95", + "surprise": "0.25", + "surprisePercentage": "12.8205", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2022-12-31", + "reportedDate": "2023-02-01", + "reportedEPS": "1.76", + "estimatedEPS": "2.23", + "surprise": "-0.47", + "surprisePercentage": "-21.0762", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2022-09-30", + "reportedDate": "2022-10-26", + "reportedEPS": "1.64", + "estimatedEPS": "1.86", + "surprise": "-0.22", + "surprisePercentage": "-11.828", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2022-06-30", + "reportedDate": "2022-07-27", + "reportedEPS": "2.46", + "estimatedEPS": "2.55", + "surprise": "-0.09", + "surprisePercentage": "-3.5294", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2022-03-31", + "reportedDate": "2022-04-27", + "reportedEPS": "2.72", + "estimatedEPS": "2.55", + "surprise": "0.17", + "surprisePercentage": "6.6667", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2021-12-31", + "reportedDate": "2022-02-02", + "reportedEPS": "3.67", + "estimatedEPS": "3.83", + "surprise": "-0.16", + "surprisePercentage": "-4.1775", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2021-09-30", + "reportedDate": "2021-10-25", + "reportedEPS": "3.22", + "estimatedEPS": "3.17", + "surprise": "0.05", + "surprisePercentage": "1.5773", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2021-06-30", + "reportedDate": "2021-07-28", + "reportedEPS": "3.61", + "estimatedEPS": "3.01", + "surprise": "0.6", + "surprisePercentage": "19.9336", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2021-03-31", + "reportedDate": "2021-04-28", + "reportedEPS": "3.3", + "estimatedEPS": "2.35", + "surprise": "0.95", + "surprisePercentage": "40.4255", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2020-12-31", + "reportedDate": "2021-01-27", + "reportedEPS": "3.88", + "estimatedEPS": "3.24", + "surprise": "0.64", + "surprisePercentage": "19.7531", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2020-09-30", + "reportedDate": "2020-10-29", + "reportedEPS": "2.4", + "estimatedEPS": "1.91", + "surprise": "0.49", + "surprisePercentage": "25.6545", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2020-06-30", + "reportedDate": "2020-07-30", + "reportedEPS": "1.8", + "estimatedEPS": "1.37", + "surprise": "0.43", + "surprisePercentage": "31.3869", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2020-03-31", + "reportedDate": "2020-04-29", + "reportedEPS": "1.71", + "estimatedEPS": "1.7", + "surprise": "0.01", + "surprisePercentage": "0.5882", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2019-12-31", + "reportedDate": "2020-01-29", + "reportedEPS": "2.56", + "estimatedEPS": "2.53", + "surprise": "0.03", + "surprisePercentage": "1.1858", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2019-09-30", + "reportedDate": "2019-10-30", + "reportedEPS": "2.12", + "estimatedEPS": "1.88", + "surprise": "0.24", + "surprisePercentage": "12.766", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2019-06-30", + "reportedDate": "2019-07-24", + "reportedEPS": "0.91", + "estimatedEPS": "1.85", + "surprise": "-0.94", + "surprisePercentage": "-50.8108", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2019-03-31", + "reportedDate": "2019-04-24", + "reportedEPS": "0.85", + "estimatedEPS": "1.61", + "surprise": "-0.76", + "surprisePercentage": "-47.205", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2018-12-31", + "reportedDate": "2019-01-30", + "reportedEPS": "2.38", + "estimatedEPS": "2.18", + "surprise": "0.2", + "surprisePercentage": "9.1743", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2018-09-30", + "reportedDate": "2018-10-30", + "reportedEPS": "1.76", + "estimatedEPS": "1.44", + "surprise": "0.32", + "surprisePercentage": "22.2222", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2018-06-30", + "reportedDate": "2018-07-25", + "reportedEPS": "1.74", + "estimatedEPS": "1.71", + "surprise": "0.03", + "surprisePercentage": "1.7544", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2018-03-31", + "reportedDate": "2018-04-25", + "reportedEPS": "1.69", + "estimatedEPS": "1.35", + "surprise": "0.34", + "surprisePercentage": "25.1852", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2017-12-31", + "reportedDate": "2018-01-31", + "reportedEPS": "1.44", + "estimatedEPS": "1.94", + "surprise": "-0.5", + "surprisePercentage": "-25.7732", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2017-09-30", + "reportedDate": "2017-11-01", + "reportedEPS": "1.59", + "estimatedEPS": "1.28", + "surprise": "0.31", + "surprisePercentage": "24.2188", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2017-06-30", + "reportedDate": "2017-07-26", + "reportedEPS": "1.32", + "estimatedEPS": "1.12", + "surprise": "0.2", + "surprisePercentage": "17.8571", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2017-03-31", + "reportedDate": "2017-05-04", + "reportedEPS": "1.36", + "estimatedEPS": "1.12", + "surprise": "0.24", + "surprisePercentage": "21.4286", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2016-12-31", + "reportedDate": "2017-02-01", + "reportedEPS": "1.21", + "estimatedEPS": "1.04", + "surprise": "0.17", + "surprisePercentage": "16.3462", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2016-09-30", + "reportedDate": "2016-11-02", + "reportedEPS": "0.82", + "estimatedEPS": "0.71", + "surprise": "0.11", + "surprisePercentage": "15.493", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2016-06-30", + "reportedDate": "2016-07-27", + "reportedEPS": "0.71", + "estimatedEPS": "0.57", + "surprise": "0.14", + "surprisePercentage": "24.5614", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2016-03-31", + "reportedDate": "2016-04-27", + "reportedEPS": "0.77", + "estimatedEPS": "0.62", + "surprise": "0.15", + "surprisePercentage": "24.1935", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2015-12-31", + "reportedDate": "2016-01-27", + "reportedEPS": "0.79", + "estimatedEPS": "0.68", + "surprise": "0.11", + "surprisePercentage": "16.1765", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2015-09-30", + "reportedDate": "2015-11-04", + "reportedEPS": "0.31", + "estimatedEPS": "0.27", + "surprise": "0.04", + "surprisePercentage": "14.8148", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2015-06-30", + "reportedDate": "2015-07-29", + "reportedEPS": "0.25", + "estimatedEPS": "0.24", + "surprise": "0.01", + "surprisePercentage": "4.1667", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2015-03-31", + "reportedDate": "2015-04-22", + "reportedEPS": "0.42", + "estimatedEPS": "0.4", + "surprise": "0.02", + "surprisePercentage": "5", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2014-12-31", + "reportedDate": "2015-01-28", + "reportedEPS": "0.25", + "estimatedEPS": "0.23", + "surprise": "0.02", + "surprisePercentage": "8.6957", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2014-09-30", + "reportedDate": "2014-10-28", + "reportedEPS": "0.42", + "estimatedEPS": "0.4", + "surprise": "0.02", + "surprisePercentage": "5", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2014-06-30", + "reportedDate": "2014-07-23", + "reportedEPS": "0.3", + "estimatedEPS": "0.24", + "surprise": "0.06", + "surprisePercentage": "25", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2014-03-31", + "reportedDate": "2014-04-23", + "reportedEPS": "0.34", + "estimatedEPS": "0.24", + "surprise": "0.1", + "surprisePercentage": "41.6667", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2013-12-31", + "reportedDate": "2014-01-29", + "reportedEPS": "0.2", + "estimatedEPS": "0.2", + "surprise": "0", + "surprisePercentage": "0", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2013-09-30", + "reportedDate": "2013-10-30", + "reportedEPS": "0.17", + "estimatedEPS": "0.12", + "surprise": "0.05", + "surprisePercentage": "41.6667", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2013-06-30", + "reportedDate": "2013-07-24", + "reportedEPS": "0.19", + "estimatedEPS": "0.14", + "surprise": "0.05", + "surprisePercentage": "35.7143", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2013-03-31", + "reportedDate": "2013-05-01", + "reportedEPS": "0.09", + "estimatedEPS": "0.08", + "surprise": "0.01", + "surprisePercentage": "12.5", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2012-12-31", + "reportedDate": "2013-01-30", + "reportedEPS": "0.03", + "estimatedEPS": "-0.01", + "surprise": "0.04", + "surprisePercentage": "400", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2012-09-30", + "reportedDate": "2012-10-23", + "reportedEPS": "-0.02", + "estimatedEPS": "0.06", + "surprise": "-0.08", + "surprisePercentage": "-133.3333", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2012-06-30", + "reportedDate": "2012-07-26", + "reportedEPS": "0.12", + "estimatedEPS": "0.11", + "surprise": "0.01", + "surprisePercentage": "9.0909", + "reportTime": "post-market" + }, + { + "fiscalDateEnding": "2012-03-31", + "reportedDate": "2012-05-30", + "reportedEPS": "0.0645", + "estimatedEPS": "None", + "surprise": "0", + "surprisePercentage": "None", + "reportTime": "pre-market" + } + ] +} + +⭐ 获取分析师评级... + +============================================================ +META - 分析师评级 +============================================================ +❌ 错误: This API function (ANALYST_RECOMMENDATIONS) does not exist. + +💰 获取损益表... + +============================================================ +META - 损益表 +============================================================ +{ + "symbol": "META", + "annualReports": [ + { + "fiscalDateEnding": "2024-12-31", + "reportedCurrency": "USD", + "grossProfit": "134340000000", + "totalRevenue": "164501000000", + "costOfRevenue": "30161000000", + "costofGoodsAndServicesSold": "30161000000", + "operatingIncome": "69380000000", + "sellingGeneralAndAdministrative": "9740000000", + "researchAndDevelopment": "43873000000", + "operatingExpenses": "64960000000", + "investmentIncomeNet": "None", + "netInterestIncome": "1973000000", + "interestIncome": "2517000000", + "interestExpense": "715000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "15498000000", + "incomeBeforeTax": "70663000000", + "incomeTaxExpense": "8303000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "62360000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "71378000000", + "ebitda": "86876000000", + "netIncome": "62360000000" + }, + { + "fiscalDateEnding": "2023-12-31", + "reportedCurrency": "USD", + "grossProfit": "108943000000", + "totalRevenue": "134902000000", + "costOfRevenue": "25959000000", + "costofGoodsAndServicesSold": "25959000000", + "operatingIncome": "46751000000", + "sellingGeneralAndAdministrative": "11408000000", + "researchAndDevelopment": "38483000000", + "operatingExpenses": "62192000000", + "investmentIncomeNet": "None", + "netInterestIncome": "677000000", + "interestIncome": "1639000000", + "interestExpense": "446000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-150000000", + "depreciation": "None", + "depreciationAndAmortization": "10382000000", + "incomeBeforeTax": "47428000000", + "incomeTaxExpense": "8330000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "29734000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "46751000000", + "ebitda": "57133000000", + "netIncome": "39098000000" + }, + { + "fiscalDateEnding": "2022-12-31", + "reportedCurrency": "USD", + "grossProfit": "91360000000", + "totalRevenue": "116609000000", + "costOfRevenue": "25249000000", + "costofGoodsAndServicesSold": "25249000000", + "operatingIncome": "28944000000", + "sellingGeneralAndAdministrative": "11816000000", + "researchAndDevelopment": "35338000000", + "operatingExpenses": "62416000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-125000000", + "interestIncome": "461000000", + "interestExpense": "185000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-320000000", + "depreciation": "None", + "depreciationAndAmortization": "8686000000", + "incomeBeforeTax": "28819000000", + "incomeTaxExpense": "5619000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "23200000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "28944000000", + "ebitda": "37630000000", + "netIncome": "23200000000" + }, + { + "fiscalDateEnding": "2021-12-31", + "reportedCurrency": "USD", + "grossProfit": "95280000000", + "totalRevenue": "117929000000", + "costOfRevenue": "22649000000", + "costofGoodsAndServicesSold": "22649000000", + "operatingIncome": "46753000000", + "sellingGeneralAndAdministrative": "9829000000", + "researchAndDevelopment": "24655000000", + "operatingExpenses": "48527000000", + "investmentIncomeNet": "None", + "netInterestIncome": "531000000", + "interestIncome": "484000000", + "interestExpense": "461000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "210000000", + "depreciation": "None", + "depreciationAndAmortization": "7967000000", + "incomeBeforeTax": "47284000000", + "incomeTaxExpense": "7914000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "39370000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "46753000000", + "ebitda": "54720000000", + "netIncome": "39370000000" + }, + { + "fiscalDateEnding": "2020-12-31", + "reportedCurrency": "USD", + "grossProfit": "69273000000", + "totalRevenue": "85965000000", + "costOfRevenue": "16692000000", + "costofGoodsAndServicesSold": "16692000000", + "operatingIncome": "32671000000", + "sellingGeneralAndAdministrative": "6564000000", + "researchAndDevelopment": "18447000000", + "operatingExpenses": "36602000000", + "investmentIncomeNet": "None", + "netInterestIncome": "509000000", + "interestIncome": "672000000", + "interestExpense": "672000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-34000000", + "depreciation": "None", + "depreciationAndAmortization": "6862000000", + "incomeBeforeTax": "33180000000", + "incomeTaxExpense": "4034000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "29146000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "32671000000", + "ebitda": "39533000000", + "netIncome": "29146000000" + }, + { + "fiscalDateEnding": "2019-12-31", + "reportedCurrency": "USD", + "grossProfit": "57927000000", + "totalRevenue": "70697000000", + "costOfRevenue": "12770000000", + "costofGoodsAndServicesSold": "12770000000", + "operatingIncome": "23986000000", + "sellingGeneralAndAdministrative": "10465000000", + "researchAndDevelopment": "13600000000", + "operatingExpenses": "33941000000", + "investmentIncomeNet": "None", + "netInterestIncome": "826000000", + "interestIncome": "924000000", + "interestExpense": "20000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "27000000", + "depreciation": "None", + "depreciationAndAmortization": "5741000000", + "incomeBeforeTax": "24812000000", + "incomeTaxExpense": "6327000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "18485000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "23986000000", + "ebitda": "29727000000", + "netIncome": "18485000000" + }, + { + "fiscalDateEnding": "2018-12-31", + "reportedCurrency": "USD", + "grossProfit": "46483000000", + "totalRevenue": "55838000000", + "costOfRevenue": "9355000000", + "costofGoodsAndServicesSold": "9355000000", + "operatingIncome": "24913000000", + "sellingGeneralAndAdministrative": "3451000000", + "researchAndDevelopment": "10273000000", + "operatingExpenses": "21570000000", + "investmentIncomeNet": "None", + "netInterestIncome": "448000000", + "interestIncome": "661000000", + "interestExpense": "9000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-204000000", + "depreciation": "None", + "depreciationAndAmortization": "4315000000", + "incomeBeforeTax": "25361000000", + "incomeTaxExpense": "3249000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "22112000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "24913000000", + "ebitda": "29228000000", + "netIncome": "22112000000" + }, + { + "fiscalDateEnding": "2017-12-31", + "reportedCurrency": "USD", + "grossProfit": "35199000000", + "totalRevenue": "40653000000", + "costOfRevenue": "5454000000", + "costofGoodsAndServicesSold": "5454000000", + "operatingIncome": "20203000000", + "sellingGeneralAndAdministrative": "2517000000", + "researchAndDevelopment": "7754000000", + "operatingExpenses": "14996000000", + "investmentIncomeNet": "None", + "netInterestIncome": "391000000", + "interestIncome": "398000000", + "interestExpense": "6000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-1000000", + "depreciation": "None", + "depreciationAndAmortization": "3025000000", + "incomeBeforeTax": "20594000000", + "incomeTaxExpense": "4660000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "15934000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "20203000000", + "ebitda": "23228000000", + "netIncome": "15934000000" + }, + { + "fiscalDateEnding": "2016-12-31", + "reportedCurrency": "USD", + "grossProfit": "23849000000", + "totalRevenue": "27638000000", + "costOfRevenue": "3789000000", + "costofGoodsAndServicesSold": "3789000000", + "operatingIncome": "12427000000", + "sellingGeneralAndAdministrative": "1731000000", + "researchAndDevelopment": "5919000000", + "operatingExpenses": "11422000000", + "investmentIncomeNet": "None", + "netInterestIncome": "91000000", + "interestIncome": "176000000", + "interestExpense": "10000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-75000000", + "depreciation": "None", + "depreciationAndAmortization": "2342000000", + "incomeBeforeTax": "12518000000", + "incomeTaxExpense": "2301000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "10217000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "12427000000", + "ebitda": "14769000000", + "netIncome": "10217000000" + }, + { + "fiscalDateEnding": "2015-12-31", + "reportedCurrency": "USD", + "grossProfit": "15061000000", + "totalRevenue": "17928000000", + "costOfRevenue": "2867000000", + "costofGoodsAndServicesSold": "2867000000", + "operatingIncome": "6225000000", + "sellingGeneralAndAdministrative": "1295000000", + "researchAndDevelopment": "4816000000", + "operatingExpenses": "8836000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-31000000", + "interestIncome": "52000000", + "interestExpense": "23000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "6000000", + "depreciation": "None", + "depreciationAndAmortization": "1945000000", + "incomeBeforeTax": "6194000000", + "incomeTaxExpense": "2506000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "3688000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "6225000000", + "ebitda": "8170000000", + "netIncome": "3688000000" + }, + { + "fiscalDateEnding": "2014-12-31", + "reportedCurrency": "USD", + "grossProfit": "10313000000", + "totalRevenue": "12466000000", + "costOfRevenue": "2153000000", + "costofGoodsAndServicesSold": "2153000000", + "operatingIncome": "4994000000", + "sellingGeneralAndAdministrative": "973000000", + "researchAndDevelopment": "2666000000", + "operatingExpenses": "5319000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-84000000", + "interestIncome": "27000000", + "interestExpense": "23000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-1000000", + "depreciation": "None", + "depreciationAndAmortization": "1243000000", + "incomeBeforeTax": "4910000000", + "incomeTaxExpense": "1970000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "2940000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "4994000000", + "ebitda": "6237000000", + "netIncome": "2940000000" + }, + { + "fiscalDateEnding": "2013-12-31", + "reportedCurrency": "USD", + "grossProfit": "5997000000", + "totalRevenue": "7872000000", + "costOfRevenue": "1875000000", + "costofGoodsAndServicesSold": "1875000000", + "operatingIncome": "2804000000", + "sellingGeneralAndAdministrative": "781000000", + "researchAndDevelopment": "1415000000", + "operatingExpenses": "3193000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-50000000", + "interestIncome": "19000000", + "interestExpense": "56000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "1000000", + "depreciation": "None", + "depreciationAndAmortization": "1011000000", + "incomeBeforeTax": "2754000000", + "incomeTaxExpense": "1254000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "1500000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "2804000000", + "ebitda": "3815000000", + "netIncome": "1500000000" + }, + { + "fiscalDateEnding": "2012-12-31", + "reportedCurrency": "USD", + "grossProfit": "3725000000", + "totalRevenue": "5089000000", + "costOfRevenue": "1364000000", + "costofGoodsAndServicesSold": "1364000000", + "operatingIncome": "538000000", + "sellingGeneralAndAdministrative": "892000000", + "researchAndDevelopment": "1399000000", + "operatingExpenses": "3187000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-44000000", + "interestIncome": "0", + "interestExpense": "51000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "7000000", + "depreciation": "None", + "depreciationAndAmortization": "649000000", + "incomeBeforeTax": "494000000", + "incomeTaxExpense": "441000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "53000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "538000000", + "ebitda": "1187000000", + "netIncome": "53000000" + }, + { + "fiscalDateEnding": "2011-12-31", + "reportedCurrency": "USD", + "grossProfit": "2851000000", + "totalRevenue": "3711000000", + "costOfRevenue": "860000000", + "costofGoodsAndServicesSold": "860000000", + "operatingIncome": "1756000000", + "sellingGeneralAndAdministrative": "280000000", + "researchAndDevelopment": "388000000", + "operatingExpenses": "1095000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-61000000", + "interestIncome": "0", + "interestExpense": "42000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-19000000", + "depreciation": "None", + "depreciationAndAmortization": "323000000", + "incomeBeforeTax": "1695000000", + "incomeTaxExpense": "695000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "None", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1756000000", + "ebitda": "2079000000", + "netIncome": "1000000000" + }, + { + "fiscalDateEnding": "2010-12-31", + "reportedCurrency": "USD", + "grossProfit": "1481000000", + "totalRevenue": "1974000000", + "costOfRevenue": "493000000", + "costofGoodsAndServicesSold": "493000000", + "operatingIncome": "1032000000", + "sellingGeneralAndAdministrative": "138000000", + "researchAndDevelopment": "144000000", + "operatingExpenses": "449000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-24000000", + "interestIncome": "0", + "interestExpense": "22000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-2000000", + "depreciation": "None", + "depreciationAndAmortization": "139000000", + "incomeBeforeTax": "1008000000", + "incomeTaxExpense": "402000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "None", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1032000000", + "ebitda": "1171000000", + "netIncome": "606000000" + }, + { + "fiscalDateEnding": "2009-12-31", + "reportedCurrency": "None", + "grossProfit": "554000000", + "totalRevenue": "777000000", + "costOfRevenue": "223000000", + "costofGoodsAndServicesSold": "223000000", + "operatingIncome": "262000000", + "sellingGeneralAndAdministrative": "205000000", + "researchAndDevelopment": "87000000", + "operatingExpenses": "292000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "10000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "78000000", + "incomeBeforeTax": "254000000", + "incomeTaxExpense": "25000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "None", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "264000000", + "ebitda": "342000000", + "netIncome": "122000000" + }, + { + "fiscalDateEnding": "2008-12-31", + "reportedCurrency": "None", + "grossProfit": "148000000", + "totalRevenue": "272000000", + "costOfRevenue": "124000000", + "costofGoodsAndServicesSold": "124000000", + "operatingIncome": "-55000000", + "sellingGeneralAndAdministrative": "156000000", + "researchAndDevelopment": "47000000", + "operatingExpenses": "203000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "1000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "None", + "incomeBeforeTax": "-56000000", + "incomeTaxExpense": "None", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "None", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "None", + "ebitda": "-55000000", + "netIncome": "-56000000" + }, + { + "fiscalDateEnding": "2007-12-31", + "reportedCurrency": "None", + "grossProfit": "112000000", + "totalRevenue": "153000000", + "costOfRevenue": "41000000", + "costofGoodsAndServicesSold": "41000000", + "operatingIncome": "-124000000", + "sellingGeneralAndAdministrative": "155000000", + "researchAndDevelopment": "81000000", + "operatingExpenses": "236000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "11000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "None", + "incomeBeforeTax": "-135000000", + "incomeTaxExpense": "3000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "None", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "None", + "ebitda": "-124000000", + "netIncome": "-138000000" + } + ], + "quarterlyReports": [ + { + "fiscalDateEnding": "2025-06-30", + "reportedCurrency": "USD", + "grossProfit": "39025000000", + "totalRevenue": "47516000000", + "costOfRevenue": "8491000000", + "costofGoodsAndServicesSold": "8491000000", + "operatingIncome": "20441000000", + "sellingGeneralAndAdministrative": "2663000000", + "researchAndDevelopment": "12942000000", + "operatingExpenses": "18584000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-103000000", + "interestIncome": "481000000", + "interestExpense": "241000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "4342000000", + "incomeBeforeTax": "20534000000", + "incomeTaxExpense": "2197000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "18337000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "20534000000", + "ebitda": "24876000000", + "netIncome": "18337000000" + }, + { + "fiscalDateEnding": "2025-03-31", + "reportedCurrency": "USD", + "grossProfit": "34742000000", + "totalRevenue": "42314000000", + "costOfRevenue": "7572000000", + "costofGoodsAndServicesSold": "7572000000", + "operatingIncome": "17555000000", + "sellingGeneralAndAdministrative": "2280000000", + "researchAndDevelopment": "12150000000", + "operatingExpenses": "17187000000", + "investmentIncomeNet": "None", + "netInterestIncome": "595000000", + "interestIncome": "658000000", + "interestExpense": "240000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "3900000000", + "incomeBeforeTax": "18382000000", + "incomeTaxExpense": "1738000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "16644000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "18622000000", + "ebitda": "22522000000", + "netIncome": "16644000000" + }, + { + "fiscalDateEnding": "2024-12-31", + "reportedCurrency": "USD", + "grossProfit": "39546000000", + "totalRevenue": "48385000000", + "costOfRevenue": "8839000000", + "costofGoodsAndServicesSold": "8839000000", + "operatingIncome": "23364000000", + "sellingGeneralAndAdministrative": "762000000", + "researchAndDevelopment": "12180000000", + "operatingExpenses": "16182000000", + "investmentIncomeNet": "None", + "netInterestIncome": "573000000", + "interestIncome": "731000000", + "interestExpense": "251000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "4460000000", + "incomeBeforeTax": "23552000000", + "incomeTaxExpense": "2714000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "20838000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "23803000000", + "ebitda": "28263000000", + "netIncome": "20838000000" + }, + { + "fiscalDateEnding": "2024-09-30", + "reportedCurrency": "USD", + "grossProfit": "33214000000", + "totalRevenue": "40589000000", + "costOfRevenue": "7375000000", + "costofGoodsAndServicesSold": "7375000000", + "operatingIncome": "17350000000", + "sellingGeneralAndAdministrative": "1865000000", + "researchAndDevelopment": "11177000000", + "operatingExpenses": "15864000000", + "investmentIncomeNet": "None", + "netInterestIncome": "461000000", + "interestIncome": "661000000", + "interestExpense": "208000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "4027000000", + "incomeBeforeTax": "17822000000", + "incomeTaxExpense": "2134000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "15688000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "18030000000", + "ebitda": "22057000000", + "netIncome": "15688000000" + }, + { + "fiscalDateEnding": "2024-06-30", + "reportedCurrency": "USD", + "grossProfit": "31763000000", + "totalRevenue": "39071000000", + "costOfRevenue": "7308000000", + "costofGoodsAndServicesSold": "7308000000", + "operatingIncome": "14847000000", + "sellingGeneralAndAdministrative": "3658000000", + "researchAndDevelopment": "10537000000", + "operatingExpenses": "16916000000", + "investmentIncomeNet": "None", + "netInterestIncome": "427000000", + "interestIncome": "540000000", + "interestExpense": "128000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "3637000000", + "incomeBeforeTax": "15106000000", + "incomeTaxExpense": "1641000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "13465000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "15234000000", + "ebitda": "18871000000", + "netIncome": "13465000000" + }, + { + "fiscalDateEnding": "2024-03-31", + "reportedCurrency": "USD", + "grossProfit": "29815000000", + "totalRevenue": "36455000000", + "costOfRevenue": "6640000000", + "costofGoodsAndServicesSold": "6640000000", + "operatingIncome": "13818000000", + "sellingGeneralAndAdministrative": "3455000000", + "researchAndDevelopment": "9978000000", + "operatingExpenses": "15997000000", + "investmentIncomeNet": "None", + "netInterestIncome": "513000000", + "interestIncome": "585000000", + "interestExpense": "127000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "3374000000", + "incomeBeforeTax": "14183000000", + "incomeTaxExpense": "1814000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "12369000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "14310000000", + "ebitda": "17684000000", + "netIncome": "12369000000" + }, + { + "fiscalDateEnding": "2023-12-31", + "reportedCurrency": "USD", + "grossProfit": "32416000000", + "totalRevenue": "40111000000", + "costOfRevenue": "7695000000", + "costofGoodsAndServicesSold": "7695000000", + "operatingIncome": "16384000000", + "sellingGeneralAndAdministrative": "2289000000", + "researchAndDevelopment": "10517000000", + "operatingExpenses": "16032000000", + "investmentIncomeNet": "None", + "netInterestIncome": "484000000", + "interestIncome": "588000000", + "interestExpense": "424000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "3172000000", + "incomeBeforeTax": "16808000000", + "incomeTaxExpense": "2791000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "14017000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "16384000000", + "ebitda": "19556000000", + "netIncome": "14017000000" + }, + { + "fiscalDateEnding": "2023-09-30", + "reportedCurrency": "USD", + "grossProfit": "27936000000", + "totalRevenue": "34146000000", + "costOfRevenue": "6210000000", + "costofGoodsAndServicesSold": "6210000000", + "operatingIncome": "13748000000", + "sellingGeneralAndAdministrative": "2070000000", + "researchAndDevelopment": "9241000000", + "operatingExpenses": "14188000000", + "investmentIncomeNet": "None", + "netInterestIncome": "370000000", + "interestIncome": "534000000", + "interestExpense": "139000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "2859000000", + "incomeBeforeTax": "14020000000", + "incomeTaxExpense": "2437000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "11583000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "13748000000", + "ebitda": "16607000000", + "netIncome": "11583000000" + }, + { + "fiscalDateEnding": "2023-06-30", + "reportedCurrency": "USD", + "grossProfit": "26054000000", + "totalRevenue": "31999000000", + "costOfRevenue": "5945000000", + "costofGoodsAndServicesSold": "5945000000", + "operatingIncome": "9392000000", + "sellingGeneralAndAdministrative": "4164000000", + "researchAndDevelopment": "9344000000", + "operatingExpenses": "16662000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-99000000", + "interestIncome": "323000000", + "interestExpense": "116000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-99000000", + "depreciation": "None", + "depreciationAndAmortization": "2623000000", + "incomeBeforeTax": "9293000000", + "incomeTaxExpense": "1505000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "7788000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "9392000000", + "ebitda": "12015000000", + "netIncome": "7788000000" + }, + { + "fiscalDateEnding": "2023-03-31", + "reportedCurrency": "USD", + "grossProfit": "22537000000", + "totalRevenue": "28645000000", + "costOfRevenue": "6108000000", + "costofGoodsAndServicesSold": "6108000000", + "operatingIncome": "7227000000", + "sellingGeneralAndAdministrative": "2885000000", + "researchAndDevelopment": "9381000000", + "operatingExpenses": "15310000000", + "investmentIncomeNet": "None", + "netInterestIncome": "80000000", + "interestIncome": "193000000", + "interestExpense": "55000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "80000000", + "depreciation": "None", + "depreciationAndAmortization": "2524000000", + "incomeBeforeTax": "7307000000", + "incomeTaxExpense": "1598000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "5709000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "7227000000", + "ebitda": "9751000000", + "netIncome": "5709000000" + }, + { + "fiscalDateEnding": "2022-12-31", + "reportedCurrency": "USD", + "grossProfit": "23829000000", + "totalRevenue": "32165000000", + "costOfRevenue": "8336000000", + "costofGoodsAndServicesSold": "8336000000", + "operatingIncome": "6399000000", + "sellingGeneralAndAdministrative": "3085000000", + "researchAndDevelopment": "9771000000", + "operatingExpenses": "17430000000", + "investmentIncomeNet": "None", + "netInterestIncome": "32000000", + "interestIncome": "32000000", + "interestExpense": "32000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-249000000", + "depreciation": "None", + "depreciationAndAmortization": "2376000000", + "incomeBeforeTax": "6149000000", + "incomeTaxExpense": "1497000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4653000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "6399000000", + "ebitda": "8775000000", + "netIncome": "4652000000" + }, + { + "fiscalDateEnding": "2022-09-30", + "reportedCurrency": "USD", + "grossProfit": "21998000000", + "totalRevenue": "27714000000", + "costOfRevenue": "5716000000", + "costofGoodsAndServicesSold": "5716000000", + "operatingIncome": "5664000000", + "sellingGeneralAndAdministrative": "3384000000", + "researchAndDevelopment": "9170000000", + "operatingExpenses": "16334000000", + "investmentIncomeNet": "None", + "netInterestIncome": "-88000000", + "interestIncome": "77000000", + "interestExpense": "77000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-88000000", + "depreciation": "None", + "depreciationAndAmortization": "2175000000", + "incomeBeforeTax": "5576000000", + "incomeTaxExpense": "1181000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4395000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5664000000", + "ebitda": "7839000000", + "netIncome": "4395000000" + }, + { + "fiscalDateEnding": "2022-06-30", + "reportedCurrency": "USD", + "grossProfit": "23630000000", + "totalRevenue": "28822000000", + "costOfRevenue": "5192000000", + "costofGoodsAndServicesSold": "5192000000", + "operatingIncome": "8358000000", + "sellingGeneralAndAdministrative": "2987000000", + "researchAndDevelopment": "8690000000", + "operatingExpenses": "15272000000", + "investmentIncomeNet": "None", + "netInterestIncome": "91000000", + "interestIncome": "91000000", + "interestExpense": "91000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-172000000", + "depreciation": "None", + "depreciationAndAmortization": "1979000000", + "incomeBeforeTax": "8186000000", + "incomeTaxExpense": "1499000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "6687000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "8358000000", + "ebitda": "10337000000", + "netIncome": "6687000000" + }, + { + "fiscalDateEnding": "2022-03-31", + "reportedCurrency": "USD", + "grossProfit": "21903000000", + "totalRevenue": "27908000000", + "costOfRevenue": "6005000000", + "costofGoodsAndServicesSold": "6005000000", + "operatingIncome": "8524000000", + "sellingGeneralAndAdministrative": "2360000000", + "researchAndDevelopment": "7707000000", + "operatingExpenses": "13379000000", + "investmentIncomeNet": "None", + "netInterestIncome": "384000000", + "interestIncome": "384000000", + "interestExpense": "76000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "384000000", + "depreciation": "None", + "depreciationAndAmortization": "2156000000", + "incomeBeforeTax": "8908000000", + "incomeTaxExpense": "1443000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "7465000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "8524000000", + "ebitda": "10680000000", + "netIncome": "7465000000" + }, + { + "fiscalDateEnding": "2021-12-31", + "reportedCurrency": "USD", + "grossProfit": "27323000000", + "totalRevenue": "33671000000", + "costOfRevenue": "6348000000", + "costofGoodsAndServicesSold": "6348000000", + "operatingIncome": "12585000000", + "sellingGeneralAndAdministrative": "3305000000", + "researchAndDevelopment": "7046000000", + "operatingExpenses": "14738000000", + "investmentIncomeNet": "None", + "netInterestIncome": "117000000", + "interestIncome": "117000000", + "interestExpense": "102000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "118000000", + "depreciation": "None", + "depreciationAndAmortization": "2014000000", + "incomeBeforeTax": "12702000000", + "incomeTaxExpense": "2417000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "10285000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "12585000000", + "ebitda": "14599000000", + "netIncome": "10285000000" + }, + { + "fiscalDateEnding": "2021-09-30", + "reportedCurrency": "USD", + "grossProfit": "23239000000", + "totalRevenue": "29010000000", + "costOfRevenue": "5771000000", + "costofGoodsAndServicesSold": "5771000000", + "operatingIncome": "10423000000", + "sellingGeneralAndAdministrative": "2946000000", + "researchAndDevelopment": "6316000000", + "operatingExpenses": "12816000000", + "investmentIncomeNet": "None", + "netInterestIncome": "120000000", + "interestIncome": "120000000", + "interestExpense": "120000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "142000000", + "depreciation": "None", + "depreciationAndAmortization": "1995000000", + "incomeBeforeTax": "10565000000", + "incomeTaxExpense": "1371000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "9194000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "10423000000", + "ebitda": "12418000000", + "netIncome": "9194000000" + }, + { + "fiscalDateEnding": "2021-06-30", + "reportedCurrency": "USD", + "grossProfit": "23678000000", + "totalRevenue": "29077000000", + "costOfRevenue": "5399000000", + "costofGoodsAndServicesSold": "5399000000", + "operatingIncome": "12367000000", + "sellingGeneralAndAdministrative": "1956000000", + "researchAndDevelopment": "6096000000", + "operatingExpenses": "11311000000", + "investmentIncomeNet": "None", + "netInterestIncome": "146000000", + "interestIncome": "121000000", + "interestExpense": "121000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "146000000", + "depreciation": "None", + "depreciationAndAmortization": "1985000000", + "incomeBeforeTax": "12513000000", + "incomeTaxExpense": "2119000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "10394000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "12367000000", + "ebitda": "14352000000", + "netIncome": "10394000000" + }, + { + "fiscalDateEnding": "2021-03-31", + "reportedCurrency": "USD", + "grossProfit": "21040000000", + "totalRevenue": "26171000000", + "costOfRevenue": "5131000000", + "costofGoodsAndServicesSold": "5131000000", + "operatingIncome": "11378000000", + "sellingGeneralAndAdministrative": "1622000000", + "researchAndDevelopment": "5197000000", + "operatingExpenses": "9662000000", + "investmentIncomeNet": "None", + "netInterestIncome": "125000000", + "interestIncome": "118000000", + "interestExpense": "118000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "125000000", + "depreciation": "None", + "depreciationAndAmortization": "1972000000", + "incomeBeforeTax": "11503000000", + "incomeTaxExpense": "2006000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "9497000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "11378000000", + "ebitda": "13350000000", + "netIncome": "9497000000" + }, + { + "fiscalDateEnding": "2020-12-31", + "reportedCurrency": "USD", + "grossProfit": "22862000000", + "totalRevenue": "28072000000", + "costOfRevenue": "5210000000", + "costofGoodsAndServicesSold": "5210000000", + "operatingIncome": "12775000000", + "sellingGeneralAndAdministrative": "1599000000", + "researchAndDevelopment": "5208000000", + "operatingExpenses": "10087000000", + "investmentIncomeNet": "None", + "netInterestIncome": "280000000", + "interestIncome": "136000000", + "interestExpense": "136000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "280000000", + "depreciation": "None", + "depreciationAndAmortization": "1863000000", + "incomeBeforeTax": "13055000000", + "incomeTaxExpense": "1836000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "11220000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "12775000000", + "ebitda": "14638000000", + "netIncome": "11219000000" + }, + { + "fiscalDateEnding": "2020-09-30", + "reportedCurrency": "USD", + "grossProfit": "17276000000", + "totalRevenue": "21470000000", + "costOfRevenue": "4194000000", + "costofGoodsAndServicesSold": "4194000000", + "operatingIncome": "8040000000", + "sellingGeneralAndAdministrative": "1790000000", + "researchAndDevelopment": "4763000000", + "operatingExpenses": "9236000000", + "investmentIncomeNet": "None", + "netInterestIncome": "146000000", + "interestIncome": "146000000", + "interestExpense": "146000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "93000000", + "depreciation": "None", + "depreciationAndAmortization": "1698000000", + "incomeBeforeTax": "8133000000", + "incomeTaxExpense": "287000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "7846000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "8040000000", + "ebitda": "9738000000", + "netIncome": "7846000000" + }, + { + "fiscalDateEnding": "2020-06-30", + "reportedCurrency": "USD", + "grossProfit": "14858000000", + "totalRevenue": "18687000000", + "costOfRevenue": "3829000000", + "costofGoodsAndServicesSold": "3829000000", + "operatingIncome": "5963000000", + "sellingGeneralAndAdministrative": "1593000000", + "researchAndDevelopment": "4462000000", + "operatingExpenses": "8895000000", + "investmentIncomeNet": "None", + "netInterestIncome": "162000000", + "interestIncome": "162000000", + "interestExpense": "162000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "168000000", + "depreciation": "None", + "depreciationAndAmortization": "1704000000", + "incomeBeforeTax": "6131000000", + "incomeTaxExpense": "953000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "5178000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5963000000", + "ebitda": "7667000000", + "netIncome": "5178000000" + }, + { + "fiscalDateEnding": "2020-03-31", + "reportedCurrency": "USD", + "grossProfit": "14278000000", + "totalRevenue": "17737000000", + "costOfRevenue": "3459000000", + "costofGoodsAndServicesSold": "3459000000", + "operatingIncome": "5893000000", + "sellingGeneralAndAdministrative": "1583000000", + "researchAndDevelopment": "4015000000", + "operatingExpenses": "8385000000", + "investmentIncomeNet": "None", + "netInterestIncome": "228000000", + "interestIncome": "228000000", + "interestExpense": "228000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-32000000", + "depreciation": "None", + "depreciationAndAmortization": "1597000000", + "incomeBeforeTax": "5861000000", + "incomeTaxExpense": "959000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4902000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5893000000", + "ebitda": "7490000000", + "netIncome": "4902000000" + }, + { + "fiscalDateEnding": "2019-12-31", + "reportedCurrency": "USD", + "grossProfit": "17590000000", + "totalRevenue": "21082000000", + "costOfRevenue": "3492000000", + "costofGoodsAndServicesSold": "3492000000", + "operatingIncome": "8858000000", + "sellingGeneralAndAdministrative": "1829000000", + "researchAndDevelopment": "3877000000", + "operatingExpenses": "8732000000", + "investmentIncomeNet": "None", + "netInterestIncome": "229000000", + "interestIncome": "249000000", + "interestExpense": "229000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "311000000", + "depreciation": "None", + "depreciationAndAmortization": "1468000000", + "incomeBeforeTax": "9169000000", + "incomeTaxExpense": "1820000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "7349000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "8858000000", + "ebitda": "10326000000", + "netIncome": "7349000000" + }, + { + "fiscalDateEnding": "2019-09-30", + "reportedCurrency": "USD", + "grossProfit": "14497000000", + "totalRevenue": "17652000000", + "costOfRevenue": "3155000000", + "costofGoodsAndServicesSold": "3155000000", + "operatingIncome": "7185000000", + "sellingGeneralAndAdministrative": "1348000000", + "researchAndDevelopment": "3548000000", + "operatingExpenses": "7312000000", + "investmentIncomeNet": "None", + "netInterestIncome": "258000000", + "interestIncome": "258000000", + "interestExpense": "258000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "144000000", + "depreciation": "None", + "depreciationAndAmortization": "1416000000", + "incomeBeforeTax": "7329000000", + "incomeTaxExpense": "1238000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "6091000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "7185000000", + "ebitda": "8601000000", + "netIncome": "6091000000" + }, + { + "fiscalDateEnding": "2019-06-30", + "reportedCurrency": "USD", + "grossProfit": "13579000000", + "totalRevenue": "16886000000", + "costOfRevenue": "3307000000", + "costofGoodsAndServicesSold": "3307000000", + "operatingIncome": "4626000000", + "sellingGeneralAndAdministrative": "3224000000", + "researchAndDevelopment": "3315000000", + "operatingExpenses": "8953000000", + "investmentIncomeNet": "None", + "netInterestIncome": "219000000", + "interestIncome": "219000000", + "interestExpense": "219000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "206000000", + "depreciation": "None", + "depreciationAndAmortization": "1502000000", + "incomeBeforeTax": "4832000000", + "incomeTaxExpense": "2216000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "2616000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "4626000000", + "ebitda": "6128000000", + "netIncome": "2616000000" + }, + { + "fiscalDateEnding": "2019-03-31", + "reportedCurrency": "USD", + "grossProfit": "12261000000", + "totalRevenue": "15077000000", + "costOfRevenue": "2816000000", + "costofGoodsAndServicesSold": "2816000000", + "operatingIncome": "3317000000", + "sellingGeneralAndAdministrative": "4064000000", + "researchAndDevelopment": "2860000000", + "operatingExpenses": "8944000000", + "investmentIncomeNet": "None", + "netInterestIncome": "198000000", + "interestIncome": "198000000", + "interestExpense": "198000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "165000000", + "depreciation": "None", + "depreciationAndAmortization": "1355000000", + "incomeBeforeTax": "3482000000", + "incomeTaxExpense": "1053000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "2429000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "3317000000", + "ebitda": "4672000000", + "netIncome": "2429000000" + }, + { + "fiscalDateEnding": "2018-12-31", + "reportedCurrency": "USD", + "grossProfit": "14118000000", + "totalRevenue": "16914000000", + "costOfRevenue": "2796000000", + "costofGoodsAndServicesSold": "2796000000", + "operatingIncome": "7820000000", + "sellingGeneralAndAdministrative": "976000000", + "researchAndDevelopment": "2855000000", + "operatingExpenses": "6298000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "187000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "151000000", + "depreciation": "None", + "depreciationAndAmortization": "1225000000", + "incomeBeforeTax": "7971000000", + "incomeTaxExpense": "1089000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "6881000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "7820000000", + "ebitda": "9045000000", + "netIncome": "6882000000" + }, + { + "fiscalDateEnding": "2018-09-30", + "reportedCurrency": "USD", + "grossProfit": "11309000000", + "totalRevenue": "13727000000", + "costOfRevenue": "2418000000", + "costofGoodsAndServicesSold": "2418000000", + "operatingIncome": "5781000000", + "sellingGeneralAndAdministrative": "943000000", + "researchAndDevelopment": "2657000000", + "operatingExpenses": "5528000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "176000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "131000000", + "depreciation": "None", + "depreciationAndAmortization": "1107000000", + "incomeBeforeTax": "5912000000", + "incomeTaxExpense": "775000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "5137000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5781000000", + "ebitda": "6888000000", + "netIncome": "5137000000" + }, + { + "fiscalDateEnding": "2018-06-30", + "reportedCurrency": "USD", + "grossProfit": "11017000000", + "totalRevenue": "13231000000", + "costOfRevenue": "2214000000", + "costofGoodsAndServicesSold": "2214000000", + "operatingIncome": "5863000000", + "sellingGeneralAndAdministrative": "776000000", + "researchAndDevelopment": "2523000000", + "operatingExpenses": "5154000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "143000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "5000000", + "depreciation": "None", + "depreciationAndAmortization": "1034000000", + "incomeBeforeTax": "5868000000", + "incomeTaxExpense": "762000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "5106000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5863000000", + "ebitda": "6897000000", + "netIncome": "5106000000" + }, + { + "fiscalDateEnding": "2018-03-31", + "reportedCurrency": "USD", + "grossProfit": "10039000000", + "totalRevenue": "11966000000", + "costOfRevenue": "1927000000", + "costofGoodsAndServicesSold": "1927000000", + "operatingIncome": "5449000000", + "sellingGeneralAndAdministrative": "757000000", + "researchAndDevelopment": "2238000000", + "operatingExpenses": "4590000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "145000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "161000000", + "depreciation": "None", + "depreciationAndAmortization": "949000000", + "incomeBeforeTax": "5610000000", + "incomeTaxExpense": "622000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4988000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5449000000", + "ebitda": "6398000000", + "netIncome": "4988000000" + }, + { + "fiscalDateEnding": "2017-12-31", + "reportedCurrency": "USD", + "grossProfit": "11361000000", + "totalRevenue": "12972000000", + "costOfRevenue": "1611000000", + "costofGoodsAndServicesSold": "1611000000", + "operatingIncome": "7352000000", + "sellingGeneralAndAdministrative": "686000000", + "researchAndDevelopment": "1949000000", + "operatingExpenses": "4009000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "126000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "109000000", + "depreciation": "None", + "depreciationAndAmortization": "853000000", + "incomeBeforeTax": "7462000000", + "incomeTaxExpense": "3194000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4269000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "7352000000", + "ebitda": "8205000000", + "netIncome": "4268000000" + }, + { + "fiscalDateEnding": "2017-09-30", + "reportedCurrency": "USD", + "grossProfit": "8880000000", + "totalRevenue": "10328000000", + "costOfRevenue": "1448000000", + "costofGoodsAndServicesSold": "1448000000", + "operatingIncome": "5122000000", + "sellingGeneralAndAdministrative": "536000000", + "researchAndDevelopment": "2052000000", + "operatingExpenses": "3758000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "108000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "114000000", + "depreciation": "None", + "depreciationAndAmortization": "773000000", + "incomeBeforeTax": "5236000000", + "incomeTaxExpense": "529000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4707000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "5122000000", + "ebitda": "5895000000", + "netIncome": "4707000000" + }, + { + "fiscalDateEnding": "2017-06-30", + "reportedCurrency": "USD", + "grossProfit": "8084000000", + "totalRevenue": "9321000000", + "costOfRevenue": "1237000000", + "costofGoodsAndServicesSold": "1237000000", + "operatingIncome": "4401000000", + "sellingGeneralAndAdministrative": "640000000", + "researchAndDevelopment": "1919000000", + "operatingExpenses": "3683000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "91000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "87000000", + "depreciation": "None", + "depreciationAndAmortization": "728000000", + "incomeBeforeTax": "4488000000", + "incomeTaxExpense": "594000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "3894000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "4401000000", + "ebitda": "5129000000", + "netIncome": "3894000000" + }, + { + "fiscalDateEnding": "2017-03-31", + "reportedCurrency": "USD", + "grossProfit": "6873000000", + "totalRevenue": "8032000000", + "costOfRevenue": "1159000000", + "costofGoodsAndServicesSold": "1159000000", + "operatingIncome": "3327000000", + "sellingGeneralAndAdministrative": "655000000", + "researchAndDevelopment": "1834000000", + "operatingExpenses": "3546000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "67000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "81000000", + "depreciation": "None", + "depreciationAndAmortization": "671000000", + "incomeBeforeTax": "3408000000", + "incomeTaxExpense": "344000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "3064000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "3327000000", + "ebitda": "3998000000", + "netIncome": "3064000000" + }, + { + "fiscalDateEnding": "2016-12-31", + "reportedCurrency": "USD", + "grossProfit": "7762000000", + "totalRevenue": "8809000000", + "costOfRevenue": "1047000000", + "costofGoodsAndServicesSold": "1047000000", + "operatingIncome": "4566000000", + "sellingGeneralAndAdministrative": "515000000", + "researchAndDevelopment": "1563000000", + "operatingExpenses": "3196000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "56000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-32000000", + "depreciation": "None", + "depreciationAndAmortization": "614000000", + "incomeBeforeTax": "4533000000", + "incomeTaxExpense": "965000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "4273000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "4566000000", + "ebitda": "5180000000", + "netIncome": "3568000000" + }, + { + "fiscalDateEnding": "2016-09-30", + "reportedCurrency": "USD", + "grossProfit": "6024000000", + "totalRevenue": "7011000000", + "costOfRevenue": "987000000", + "costofGoodsAndServicesSold": "987000000", + "operatingIncome": "3122000000", + "sellingGeneralAndAdministrative": "438000000", + "researchAndDevelopment": "1539000000", + "operatingExpenses": "2902000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "50000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "47000000", + "depreciation": "None", + "depreciationAndAmortization": "591000000", + "incomeBeforeTax": "3169000000", + "incomeTaxExpense": "790000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "2379000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "3122000000", + "ebitda": "3713000000", + "netIncome": "2379000000" + }, + { + "fiscalDateEnding": "2016-06-30", + "reportedCurrency": "USD", + "grossProfit": "5520000000", + "totalRevenue": "6436000000", + "costOfRevenue": "916000000", + "costofGoodsAndServicesSold": "916000000", + "operatingIncome": "2746000000", + "sellingGeneralAndAdministrative": "412000000", + "researchAndDevelopment": "1463000000", + "operatingExpenses": "2774000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "32000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "20000000", + "depreciation": "None", + "depreciationAndAmortization": "585000000", + "incomeBeforeTax": "2766000000", + "incomeTaxExpense": "711000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "2055000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "2746000000", + "ebitda": "3331000000", + "netIncome": "2055000000" + }, + { + "fiscalDateEnding": "2016-03-31", + "reportedCurrency": "USD", + "grossProfit": "4544000000", + "totalRevenue": "5382000000", + "costOfRevenue": "838000000", + "costofGoodsAndServicesSold": "838000000", + "operatingIncome": "2009000000", + "sellingGeneralAndAdministrative": "366000000", + "researchAndDevelopment": "1343000000", + "operatingExpenses": "2535000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "27000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "56000000", + "depreciation": "None", + "depreciationAndAmortization": "552000000", + "incomeBeforeTax": "2065000000", + "incomeTaxExpense": "555000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "1505000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "2009000000", + "ebitda": "2561000000", + "netIncome": "1510000000" + }, + { + "fiscalDateEnding": "2015-12-31", + "reportedCurrency": "USD", + "grossProfit": "5017000000", + "totalRevenue": "5841000000", + "costOfRevenue": "824000000", + "costofGoodsAndServicesSold": "824000000", + "operatingIncome": "2560000000", + "sellingGeneralAndAdministrative": "371000000", + "researchAndDevelopment": "1314000000", + "operatingExpenses": "2457000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "14000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-3000000", + "depreciation": "None", + "depreciationAndAmortization": "543000000", + "incomeBeforeTax": "2557000000", + "incomeTaxExpense": "995000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "1561000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "2560000000", + "ebitda": "3103000000", + "netIncome": "1562000000" + }, + { + "fiscalDateEnding": "2015-09-30", + "reportedCurrency": "USD", + "grossProfit": "3781000000", + "totalRevenue": "4501000000", + "costOfRevenue": "720000000", + "costofGoodsAndServicesSold": "720000000", + "operatingIncome": "1459000000", + "sellingGeneralAndAdministrative": "345000000", + "researchAndDevelopment": "1271000000", + "operatingExpenses": "2322000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "7000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-27000000", + "depreciation": "None", + "depreciationAndAmortization": "486000000", + "incomeBeforeTax": "1432000000", + "incomeTaxExpense": "536000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "896000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1459000000", + "ebitda": "1945000000", + "netIncome": "896000000" + }, + { + "fiscalDateEnding": "2015-06-30", + "reportedCurrency": "USD", + "grossProfit": "3374000000", + "totalRevenue": "4042000000", + "costOfRevenue": "668000000", + "costofGoodsAndServicesSold": "668000000", + "operatingIncome": "1273000000", + "sellingGeneralAndAdministrative": "305000000", + "researchAndDevelopment": "1170000000", + "operatingExpenses": "2101000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "5000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "459000000", + "incomeBeforeTax": "1273000000", + "incomeTaxExpense": "554000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "719000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1273000000", + "ebitda": "1732000000", + "netIncome": "719000000" + }, + { + "fiscalDateEnding": "2015-03-31", + "reportedCurrency": "USD", + "grossProfit": "2889000000", + "totalRevenue": "3543000000", + "costOfRevenue": "654000000", + "costofGoodsAndServicesSold": "654000000", + "operatingIncome": "933000000", + "sellingGeneralAndAdministrative": "274000000", + "researchAndDevelopment": "1062000000", + "operatingExpenses": "1956000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "2000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-1000000", + "depreciation": "None", + "depreciationAndAmortization": "457000000", + "incomeBeforeTax": "932000000", + "incomeTaxExpense": "420000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "512000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "933000000", + "ebitda": "1390000000", + "netIncome": "512000000" + }, + { + "fiscalDateEnding": "2014-12-31", + "reportedCurrency": "USD", + "grossProfit": "3198000000", + "totalRevenue": "3851000000", + "costOfRevenue": "653000000", + "costofGoodsAndServicesSold": "653000000", + "operatingIncome": "1133000000", + "sellingGeneralAndAdministrative": "330000000", + "researchAndDevelopment": "1111000000", + "operatingExpenses": "2065000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "23000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-19000000", + "depreciation": "None", + "depreciationAndAmortization": "433000000", + "incomeBeforeTax": "1114000000", + "incomeTaxExpense": "413000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "701000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1133000000", + "ebitda": "1566000000", + "netIncome": "701000000" + }, + { + "fiscalDateEnding": "2014-09-30", + "reportedCurrency": "USD", + "grossProfit": "2638000000", + "totalRevenue": "3203000000", + "costOfRevenue": "565000000", + "costofGoodsAndServicesSold": "565000000", + "operatingIncome": "1397000000", + "sellingGeneralAndAdministrative": "259000000", + "researchAndDevelopment": "608000000", + "operatingExpenses": "1241000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "4000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-61000000", + "depreciation": "None", + "depreciationAndAmortization": "289000000", + "incomeBeforeTax": "1336000000", + "incomeTaxExpense": "530000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "806000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1397000000", + "ebitda": "1686000000", + "netIncome": "806000000" + }, + { + "fiscalDateEnding": "2014-06-30", + "reportedCurrency": "USD", + "grossProfit": "2437000000", + "totalRevenue": "2910000000", + "costOfRevenue": "473000000", + "costofGoodsAndServicesSold": "473000000", + "operatingIncome": "1390000000", + "sellingGeneralAndAdministrative": "197000000", + "researchAndDevelopment": "492000000", + "operatingExpenses": "1047000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "4000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-4000000", + "depreciation": "None", + "depreciationAndAmortization": "257000000", + "incomeBeforeTax": "1386000000", + "incomeTaxExpense": "595000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "791000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1390000000", + "ebitda": "1647000000", + "netIncome": "791000000" + }, + { + "fiscalDateEnding": "2014-03-31", + "reportedCurrency": "USD", + "grossProfit": "2040000000", + "totalRevenue": "2502000000", + "costOfRevenue": "462000000", + "costofGoodsAndServicesSold": "462000000", + "operatingIncome": "1075000000", + "sellingGeneralAndAdministrative": "187000000", + "researchAndDevelopment": "455000000", + "operatingExpenses": "965000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "19000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "264000000", + "incomeBeforeTax": "1075000000", + "incomeTaxExpense": "433000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "642000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1075000000", + "ebitda": "1339000000", + "netIncome": "642000000" + }, + { + "fiscalDateEnding": "2013-12-31", + "reportedCurrency": "USD", + "grossProfit": "2094000000", + "totalRevenue": "2585000000", + "costOfRevenue": "491000000", + "costofGoodsAndServicesSold": "491000000", + "operatingIncome": "1133000000", + "sellingGeneralAndAdministrative": "261000000", + "researchAndDevelopment": "408000000", + "operatingExpenses": "961000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "7000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "3000000", + "depreciation": "None", + "depreciationAndAmortization": "274000000", + "incomeBeforeTax": "1130000000", + "incomeTaxExpense": "607000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "523000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "1133000000", + "ebitda": "1407000000", + "netIncome": "523000000" + }, + { + "fiscalDateEnding": "2013-09-30", + "reportedCurrency": "USD", + "grossProfit": "1509000000", + "totalRevenue": "2016000000", + "costOfRevenue": "507000000", + "costofGoodsAndServicesSold": "507000000", + "operatingIncome": "736000000", + "sellingGeneralAndAdministrative": "171000000", + "researchAndDevelopment": "369000000", + "operatingExpenses": "773000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "21000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "11000000", + "depreciation": "None", + "depreciationAndAmortization": "274000000", + "incomeBeforeTax": "726000000", + "incomeTaxExpense": "301000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "425000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "736000000", + "ebitda": "1010000000", + "netIncome": "425000000" + }, + { + "fiscalDateEnding": "2013-06-30", + "reportedCurrency": "USD", + "grossProfit": "1348000000", + "totalRevenue": "1813000000", + "costOfRevenue": "465000000", + "costofGoodsAndServicesSold": "465000000", + "operatingIncome": "562000000", + "sellingGeneralAndAdministrative": "173000000", + "researchAndDevelopment": "344000000", + "operatingExpenses": "786000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "14000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-3000000", + "depreciation": "None", + "depreciationAndAmortization": "230000000", + "incomeBeforeTax": "545000000", + "incomeTaxExpense": "212000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "333000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "562000000", + "ebitda": "792000000", + "netIncome": "333000000" + }, + { + "fiscalDateEnding": "2013-03-31", + "reportedCurrency": "USD", + "grossProfit": "1045000000", + "totalRevenue": "1458000000", + "costOfRevenue": "413000000", + "costofGoodsAndServicesSold": "413000000", + "operatingIncome": "373000000", + "sellingGeneralAndAdministrative": "176000000", + "researchAndDevelopment": "293000000", + "operatingExpenses": "672000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "15000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-5000000", + "depreciation": "None", + "depreciationAndAmortization": "241000000", + "incomeBeforeTax": "353000000", + "incomeTaxExpense": "134000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "219000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "373000000", + "ebitda": "614000000", + "netIncome": "219000000" + }, + { + "fiscalDateEnding": "2012-12-31", + "reportedCurrency": "USD", + "grossProfit": "1187000000", + "totalRevenue": "1585000000", + "costOfRevenue": "398000000", + "costofGoodsAndServicesSold": "398000000", + "operatingIncome": "523000000", + "sellingGeneralAndAdministrative": "174000000", + "researchAndDevelopment": "297000000", + "operatingExpenses": "664000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "16000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "224000000", + "incomeBeforeTax": "505000000", + "incomeTaxExpense": "441000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "523000000", + "ebitda": "747000000", + "netIncome": "64000000" + }, + { + "fiscalDateEnding": "2012-09-30", + "reportedCurrency": "USD", + "grossProfit": "940000000", + "totalRevenue": "1262000000", + "costOfRevenue": "322000000", + "costofGoodsAndServicesSold": "322000000", + "operatingIncome": "377000000", + "sellingGeneralAndAdministrative": "151000000", + "researchAndDevelopment": "244000000", + "operatingExpenses": "563000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "11000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "6000000", + "depreciation": "None", + "depreciationAndAmortization": "176000000", + "incomeBeforeTax": "372000000", + "incomeTaxExpense": "431000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "-59000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "377000000", + "ebitda": "553000000", + "netIncome": "-59000000" + }, + { + "fiscalDateEnding": "2012-06-30", + "reportedCurrency": "USD", + "grossProfit": "817000000", + "totalRevenue": "1184000000", + "costOfRevenue": "367000000", + "costofGoodsAndServicesSold": "367000000", + "operatingIncome": "-743000000", + "sellingGeneralAndAdministrative": "463000000", + "researchAndDevelopment": "705000000", + "operatingExpenses": "1560000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "10000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "-12000000", + "depreciation": "None", + "depreciationAndAmortization": "139000000", + "incomeBeforeTax": "-765000000", + "incomeTaxExpense": "-608000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "-157000000", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "-743000000", + "ebitda": "-604000000", + "netIncome": "-157000000" + }, + { + "fiscalDateEnding": "2012-03-31", + "reportedCurrency": "USD", + "grossProfit": "781000000", + "totalRevenue": "1058000000", + "costOfRevenue": "277000000", + "costofGoodsAndServicesSold": "277000000", + "operatingIncome": "381000000", + "sellingGeneralAndAdministrative": "88000000", + "researchAndDevelopment": "153000000", + "operatingExpenses": "400000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "13000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "110000000", + "incomeBeforeTax": "382000000", + "incomeTaxExpense": "177000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "381000000", + "ebitda": "491000000", + "netIncome": "205000000" + }, + { + "fiscalDateEnding": "2011-12-31", + "reportedCurrency": "USD", + "grossProfit": "884000000", + "totalRevenue": "1131000000", + "costOfRevenue": "247000000", + "costofGoodsAndServicesSold": "247000000", + "operatingIncome": "547000000", + "sellingGeneralAndAdministrative": "58000000", + "researchAndDevelopment": "124000000", + "operatingExpenses": "337000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "16000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "103000000", + "incomeBeforeTax": "519000000", + "incomeTaxExpense": "217000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "547000000", + "ebitda": "650000000", + "netIncome": "302000000" + }, + { + "fiscalDateEnding": "2011-09-30", + "reportedCurrency": "USD", + "grossProfit": "718000000", + "totalRevenue": "954000000", + "costOfRevenue": "236000000", + "costofGoodsAndServicesSold": "236000000", + "operatingIncome": "414000000", + "sellingGeneralAndAdministrative": "82000000", + "researchAndDevelopment": "108000000", + "operatingExpenses": "304000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "10000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "97000000", + "incomeBeforeTax": "379000000", + "incomeTaxExpense": "152000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "414000000", + "ebitda": "511000000", + "netIncome": "227000000" + }, + { + "fiscalDateEnding": "2011-06-30", + "reportedCurrency": "USD", + "grossProfit": "685000000", + "totalRevenue": "895000000", + "costOfRevenue": "210000000", + "costofGoodsAndServicesSold": "210000000", + "operatingIncome": "407000000", + "sellingGeneralAndAdministrative": "83000000", + "researchAndDevelopment": "99000000", + "operatingExpenses": "278000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "9000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "72000000", + "incomeBeforeTax": "399000000", + "incomeTaxExpense": "159000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "407000000", + "ebitda": "479000000", + "netIncome": "240000000" + }, + { + "fiscalDateEnding": "2011-03-31", + "reportedCurrency": "USD", + "grossProfit": "564000000", + "totalRevenue": "731000000", + "costOfRevenue": "167000000", + "costofGoodsAndServicesSold": "167000000", + "operatingIncome": "388000000", + "sellingGeneralAndAdministrative": "51000000", + "researchAndDevelopment": "57000000", + "operatingExpenses": "176000000", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "7000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "51000000", + "incomeBeforeTax": "398000000", + "incomeTaxExpense": "165000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "388000000", + "ebitda": "439000000", + "netIncome": "233000000" + }, + { + "fiscalDateEnding": "2010-12-31", + "reportedCurrency": "USD", + "grossProfit": "1620000000", + "totalRevenue": "730000000", + "costOfRevenue": "151000000", + "costofGoodsAndServicesSold": "151000000", + "operatingIncome": "435000000", + "sellingGeneralAndAdministrative": "144000000", + "researchAndDevelopment": "46000000", + "operatingExpenses": "0", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "22000000", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "None", + "incomeBeforeTax": "1008000000", + "incomeTaxExpense": "402000000", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "435000000", + "ebitda": "None", + "netIncome": "251000000" + }, + { + "fiscalDateEnding": "2010-09-30", + "reportedCurrency": "USD", + "grossProfit": "0", + "totalRevenue": "467000000", + "costOfRevenue": "131000000", + "costofGoodsAndServicesSold": "131000000", + "operatingIncome": "216000000", + "sellingGeneralAndAdministrative": "120000000", + "researchAndDevelopment": "41000000", + "operatingExpenses": "0", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "0", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "None", + "incomeBeforeTax": "0", + "incomeTaxExpense": "0", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "216000000", + "ebitda": "None", + "netIncome": "131000000" + }, + { + "fiscalDateEnding": "2010-06-30", + "reportedCurrency": "USD", + "grossProfit": "0", + "totalRevenue": "432000000", + "costOfRevenue": "111000000", + "costofGoodsAndServicesSold": "111000000", + "operatingIncome": "219000000", + "sellingGeneralAndAdministrative": "102000000", + "researchAndDevelopment": "32000000", + "operatingExpenses": "0", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "0", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "None", + "incomeBeforeTax": "0", + "incomeTaxExpense": "0", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "219000000", + "ebitda": "None", + "netIncome": "129000000" + }, + { + "fiscalDateEnding": "2010-03-31", + "reportedCurrency": "USD", + "grossProfit": "0", + "totalRevenue": "345000000", + "costOfRevenue": "100000000", + "costofGoodsAndServicesSold": "100000000", + "operatingIncome": "162000000", + "sellingGeneralAndAdministrative": "83000000", + "researchAndDevelopment": "25000000", + "operatingExpenses": "0", + "investmentIncomeNet": "None", + "netInterestIncome": "None", + "interestIncome": "None", + "interestExpense": "0", + "nonInterestIncome": "None", + "otherNonOperatingIncome": "None", + "depreciation": "None", + "depreciationAndAmortization": "None", + "incomeBeforeTax": "0", + "incomeTaxExpense": "0", + "interestAndDebtExpense": "None", + "netIncomeFromContinuingOperations": "0", + "comprehensiveIncomeNetOfTax": "None", + "ebit": "162000000", + "ebitda": "None", + "netIncome": "95000000" + } + ] +} + +✅ META 数据获取完成! +⏰ 完成时间: 2025-08-02 16:52:42 diff --git a/rss_analysis_report.json b/rss_analysis_report.json deleted file mode 100644 index 0735e92..0000000 --- a/rss_analysis_report.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "error": "无法连接到数据库" -} \ No newline at end of file diff --git a/scripts/add_sequence_ids.py b/scripts/add_sequence_ids.py index 8ddb7ea..ba274b7 100644 --- a/scripts/add_sequence_ids.py +++ b/scripts/add_sequence_ids.py @@ -9,7 +9,9 @@ from pymongo import MongoClient def add_sequence_ids(): """为现有文章添加流水号""" # 连接MongoDB - mongo_uri = os.getenv('MONGODB_URI', 'mongodb+srv://ben:313131@cauldron.tx3qnoq.mongodb.net/') + mongo_uri = os.getenv('MONGODB_URI') + if not mongo_uri: + raise ValueError("MONGODB_URI environment variable is required") client = MongoClient(mongo_uri) db = client['taigong'] collection = db['articles'] diff --git a/scripts/cleanup_duplicates.py b/scripts/cleanup_duplicates.py index 2a7e94a..51601cb 100644 --- a/scripts/cleanup_duplicates.py +++ b/scripts/cleanup_duplicates.py @@ -21,7 +21,9 @@ def generate_stable_id(title, pub_date, content): def cleanup_duplicates(): """清理重复数据""" # 连接MongoDB - mongo_uri = os.getenv('MONGODB_URI', 'mongodb+srv://ben:313131@cauldron.tx3qnoq.mongodb.net/') + mongo_uri = os.getenv('MONGODB_URI') + if not mongo_uri: + raise ValueError("MONGODB_URI environment variable is required") client = MongoClient(mongo_uri) db = client['taigong'] collection = db['articles'] diff --git a/scripts/create_vector_index.js b/scripts/create_vector_index.js new file mode 100644 index 0000000..9cd7cba --- /dev/null +++ b/scripts/create_vector_index.js @@ -0,0 +1,35 @@ +// MongoDB Atlas Vector Search Index Creation Script +// 为swarm辩论系统创建向量索引 + +// 连接到数据库 +use('taigong'); + +// 创建向量索引用于语义搜索和内容聚类 +// 这个索引将支持swarm辩论系统的语义相似性匹配 +db.articles.createSearchIndex( + "vector_search_index", + { + "fields": [ + { + "type": "vector", + "path": "embedding", + "numDimensions": 1536, // OpenAI text-embedding-ada-002 维度 + "similarity": "cosine" + }, + { + "type": "filter", + "path": "published_time" + }, + { + "type": "filter", + "path": "title" + } + ] + } +); + +print("向量索引创建完成!"); +print("索引名称: vector_search_index"); +print("向量维度: 1536 (OpenAI embedding)"); +print("相似性算法: cosine"); +print("支持过滤字段: published_time, title"); \ No newline at end of file diff --git a/scripts/generate_embeddings.py b/scripts/generate_embeddings.py new file mode 100644 index 0000000..67ceae3 --- /dev/null +++ b/scripts/generate_embeddings.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +""" +为MongoDB中的文章生成向量embeddings +用于swarm辩论系统的语义搜索和内容聚类 +""" + +import os +import openai +from pymongo import MongoClient +from typing import List, Dict +import time + +def get_mongodb_client(): + """从Doppler获取MongoDB连接""" + mongodb_uri = os.getenv('MONGODB_URI') + if not mongodb_uri: + raise ValueError("MONGODB_URI not found in environment variables") + return MongoClient(mongodb_uri) + +def generate_embedding(text: str) -> List[float]: + """使用OpenAI API生成文本embedding""" + try: + response = openai.Embedding.create( + model="text-embedding-ada-002", + input=text + ) + return response['data'][0]['embedding'] + except Exception as e: + print(f"生成embedding失败: {e}") + return None + +def update_articles_with_embeddings(): + """为所有文章添加embedding字段""" + client = get_mongodb_client() + db = client.taigong + collection = db.articles + + # 获取所有没有embedding的文章 + articles = collection.find({"embedding": {"$exists": False}}) + + count = 0 + for article in articles: + title = article.get('title', '') + if not title: + continue + + print(f"处理文章: {title[:50]}...") + + # 生成embedding + embedding = generate_embedding(title) + if embedding: + # 更新文档 + collection.update_one( + {"_id": article["_id"]}, + {"$set": {"embedding": embedding}} + ) + count += 1 + print(f"✓ 已更新 {count} 篇文章") + + # 避免API rate limit + time.sleep(0.1) + else: + print(f"× 跳过文章: {title[:50]}") + + print(f"\n完成!共处理 {count} 篇文章") + client.close() + +if __name__ == "__main__": + # 设置OpenAI API密钥 (应该从Doppler获取) + openai.api_key = os.getenv('OPENAI_API_KEY') + if not openai.api_key: + print("警告: OPENAI_API_KEY 未设置,请先在Doppler中配置") + exit(1) + + update_articles_with_embeddings() \ No newline at end of file diff --git a/ai_personalities.md b/src/jixia/ai_personalities.md similarity index 100% rename from ai_personalities.md rename to src/jixia/ai_personalities.md diff --git a/baxian_swarm_debate.py b/src/jixia/baxian_swarm_debate.py similarity index 100% rename from baxian_swarm_debate.py rename to src/jixia/baxian_swarm_debate.py diff --git a/src/jixia/engines/jixia_load_balancer.py b/src/jixia/engines/jixia_load_balancer.py new file mode 100644 index 0000000..1c9ae46 --- /dev/null +++ b/src/jixia/engines/jixia_load_balancer.py @@ -0,0 +1,462 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +稷下学宫负载均衡器 +实现八仙论道的API负载分担策略 +""" + +import time +import random +import requests +from datetime import datetime, timezone +from typing import Dict, List, Any, Optional, Tuple +from dataclasses import dataclass +from collections import defaultdict +import json +import os + +@dataclass +class APIResult: + """API调用结果""" + success: bool + data: Dict[str, Any] + api_used: str + response_time: float + error: Optional[str] = None + cached: bool = False + +class RateLimiter: + """速率限制器""" + + def __init__(self): + self.api_calls = defaultdict(list) + self.limits = { + 'alpha_vantage': {'per_minute': 500, 'per_month': 500000}, + 'yahoo_finance_15': {'per_minute': 500, 'per_month': 500000}, + 'webull': {'per_minute': 500, 'per_month': 500000}, + 'seeking_alpha': {'per_minute': 500, 'per_month': 500000} + } + + def is_rate_limited(self, api_name: str) -> bool: + """检查是否达到速率限制""" + now = time.time() + calls = self.api_calls[api_name] + + # 清理1分钟前的记录 + self.api_calls[api_name] = [call_time for call_time in calls if now - call_time < 60] + + # 检查每分钟限制 + if len(self.api_calls[api_name]) >= self.limits[api_name]['per_minute'] * 0.9: # 90%阈值 + return True + + return False + + def record_call(self, api_name: str): + """记录API调用""" + self.api_calls[api_name].append(time.time()) + +class APIHealthChecker: + """API健康检查器""" + + def __init__(self): + self.health_status = { + 'alpha_vantage': {'healthy': True, 'last_check': 0, 'consecutive_failures': 0}, + 'yahoo_finance_15': {'healthy': True, 'last_check': 0, 'consecutive_failures': 0}, + 'webull': {'healthy': True, 'last_check': 0, 'consecutive_failures': 0}, + 'seeking_alpha': {'healthy': True, 'last_check': 0, 'consecutive_failures': 0} + } + self.check_interval = 300 # 5分钟检查一次 + + def is_healthy(self, api_name: str) -> bool: + """检查API是否健康""" + status = self.health_status[api_name] + now = time.time() + + # 如果距离上次检查超过间隔时间,进行健康检查 + if now - status['last_check'] > self.check_interval: + self._perform_health_check(api_name) + + return status['healthy'] + + def _perform_health_check(self, api_name: str): + """执行健康检查""" + # 这里可以实现具体的健康检查逻辑 + # 暂时简化为基于连续失败次数判断 + status = self.health_status[api_name] + status['last_check'] = time.time() + + # 如果连续失败超过3次,标记为不健康 + if status['consecutive_failures'] > 3: + status['healthy'] = False + else: + status['healthy'] = True + + def record_success(self, api_name: str): + """记录成功调用""" + self.health_status[api_name]['consecutive_failures'] = 0 + self.health_status[api_name]['healthy'] = True + + def record_failure(self, api_name: str): + """记录失败调用""" + self.health_status[api_name]['consecutive_failures'] += 1 + +class DataNormalizer: + """数据标准化处理器""" + + def normalize_stock_quote(self, raw_data: dict, api_source: str) -> dict: + """将不同API的股票报价数据标准化""" + try: + if api_source == 'alpha_vantage': + return self._normalize_alpha_vantage_quote(raw_data) + elif api_source == 'yahoo_finance_15': + return self._normalize_yahoo_quote(raw_data) + elif api_source == 'webull': + return self._normalize_webull_quote(raw_data) + elif api_source == 'seeking_alpha': + return self._normalize_seeking_alpha_quote(raw_data) + else: + return {'error': f'Unknown API source: {api_source}'} + except Exception as e: + return {'error': f'Data normalization failed: {str(e)}'} + + def _normalize_alpha_vantage_quote(self, data: dict) -> dict: + """标准化Alpha Vantage数据格式""" + global_quote = data.get('Global Quote', {}) + return { + 'symbol': global_quote.get('01. symbol'), + 'price': float(global_quote.get('05. price', 0)), + 'change': float(global_quote.get('09. change', 0)), + 'change_percent': global_quote.get('10. change percent', '0%'), + 'volume': int(global_quote.get('06. volume', 0)), + 'high': float(global_quote.get('03. high', 0)), + 'low': float(global_quote.get('04. low', 0)), + 'source': 'alpha_vantage', + 'timestamp': global_quote.get('07. latest trading day') + } + + def _normalize_yahoo_quote(self, data: dict) -> dict: + """标准化Yahoo Finance数据格式""" + body = data.get('body', {}) + return { + 'symbol': body.get('symbol'), + 'price': float(body.get('regularMarketPrice', 0)), + 'change': float(body.get('regularMarketChange', 0)), + 'change_percent': f"{body.get('regularMarketChangePercent', 0):.2f}%", + 'volume': int(body.get('regularMarketVolume', 0)), + 'high': float(body.get('regularMarketDayHigh', 0)), + 'low': float(body.get('regularMarketDayLow', 0)), + 'source': 'yahoo_finance_15', + 'timestamp': body.get('regularMarketTime') + } + + def _normalize_webull_quote(self, data: dict) -> dict: + """标准化Webull数据格式""" + if 'stocks' in data and len(data['stocks']) > 0: + stock = data['stocks'][0] + return { + 'symbol': stock.get('symbol'), + 'price': float(stock.get('close', 0)), + 'change': float(stock.get('change', 0)), + 'change_percent': f"{stock.get('changeRatio', 0):.2f}%", + 'volume': int(stock.get('volume', 0)), + 'high': float(stock.get('high', 0)), + 'low': float(stock.get('low', 0)), + 'source': 'webull', + 'timestamp': stock.get('timeStamp') + } + return {'error': 'No stock data found in Webull response'} + + def _normalize_seeking_alpha_quote(self, data: dict) -> dict: + """标准化Seeking Alpha数据格式""" + if 'data' in data and len(data['data']) > 0: + stock_data = data['data'][0] + attributes = stock_data.get('attributes', {}) + return { + 'symbol': attributes.get('slug'), + 'price': float(attributes.get('lastPrice', 0)), + 'change': float(attributes.get('dayChange', 0)), + 'change_percent': f"{attributes.get('dayChangePercent', 0):.2f}%", + 'volume': int(attributes.get('volume', 0)), + 'source': 'seeking_alpha', + 'market_cap': attributes.get('marketCap'), + 'pe_ratio': attributes.get('peRatio') + } + return {'error': 'No data found in Seeking Alpha response'} + +class JixiaLoadBalancer: + """稷下学宫负载均衡器""" + + def __init__(self, rapidapi_key: str): + self.rapidapi_key = rapidapi_key + self.rate_limiter = RateLimiter() + self.health_checker = APIHealthChecker() + self.data_normalizer = DataNormalizer() + self.cache = {} # 简单的内存缓存 + self.cache_ttl = 300 # 5分钟缓存 + + # API配置 + self.api_configs = { + 'alpha_vantage': { + 'host': 'alpha-vantage.p.rapidapi.com', + 'endpoints': { + 'stock_quote': '/query?function=GLOBAL_QUOTE&symbol={symbol}', + 'company_overview': '/query?function=OVERVIEW&symbol={symbol}', + 'earnings': '/query?function=EARNINGS&symbol={symbol}' + } + }, + 'yahoo_finance_15': { + 'host': 'yahoo-finance15.p.rapidapi.com', + 'endpoints': { + 'stock_quote': '/api/yahoo/qu/quote/{symbol}', + 'market_movers': '/api/yahoo/co/collections/day_gainers', + 'market_news': '/api/yahoo/ne/news' + } + }, + 'webull': { + 'host': 'webull.p.rapidapi.com', + 'endpoints': { + 'stock_quote': '/stock/search?keyword={symbol}', + 'market_movers': '/market/get-active-gainers' + } + }, + 'seeking_alpha': { + 'host': 'seeking-alpha.p.rapidapi.com', + 'endpoints': { + 'company_overview': '/symbols/get-profile?symbols={symbol}', + 'market_news': '/news/list?category=market-news' + } + } + } + + # 八仙API分配策略 + self.immortal_api_mapping = { + 'stock_quote': { + '吕洞宾': 'alpha_vantage', # 主力剑仙用最快的API + '何仙姑': 'yahoo_finance_15', # 风控专家用稳定的API + '张果老': 'webull', # 技术分析师用搜索强的API + '韩湘子': 'alpha_vantage', # 基本面研究用专业API + '汉钟离': 'yahoo_finance_15', # 量化专家用市场数据API + '蓝采和': 'webull', # 情绪分析师用活跃数据API + '曹国舅': 'seeking_alpha', # 宏观分析师用分析API + '铁拐李': 'alpha_vantage' # 逆向投资用基础数据API + }, + 'company_overview': { + '吕洞宾': 'alpha_vantage', + '何仙姑': 'seeking_alpha', + '张果老': 'alpha_vantage', + '韩湘子': 'seeking_alpha', + '汉钟离': 'alpha_vantage', + '蓝采和': 'seeking_alpha', + '曹国舅': 'seeking_alpha', + '铁拐李': 'alpha_vantage' + }, + 'market_movers': { + '吕洞宾': 'yahoo_finance_15', + '何仙姑': 'webull', + '张果老': 'yahoo_finance_15', + '韩湘子': 'webull', + '汉钟离': 'yahoo_finance_15', + '蓝采和': 'webull', + '曹国舅': 'yahoo_finance_15', + '铁拐李': 'webull' + }, + 'market_news': { + '吕洞宾': 'yahoo_finance_15', + '何仙姑': 'seeking_alpha', + '张果老': 'yahoo_finance_15', + '韩湘子': 'seeking_alpha', + '汉钟离': 'yahoo_finance_15', + '蓝采和': 'seeking_alpha', + '曹国舅': 'seeking_alpha', + '铁拐李': 'yahoo_finance_15' + } + } + + # 故障转移优先级 + self.failover_priority = { + 'alpha_vantage': ['webull', 'yahoo_finance_15'], + 'yahoo_finance_15': ['webull', 'alpha_vantage'], + 'webull': ['alpha_vantage', 'yahoo_finance_15'], + 'seeking_alpha': ['yahoo_finance_15', 'alpha_vantage'] + } + + def get_data_for_immortal(self, immortal_name: str, data_type: str, symbol: str = None) -> APIResult: + """为特定仙人获取数据""" + print(f"🎭 {immortal_name} 正在获取 {data_type} 数据...") + + # 检查缓存 + cache_key = f"{immortal_name}_{data_type}_{symbol}" + cached_result = self._get_cached_data(cache_key) + if cached_result: + print(f" 📦 使用缓存数据") + return cached_result + + # 获取该仙人的首选API + if data_type not in self.immortal_api_mapping: + return APIResult(False, {}, '', 0, f"Unsupported data type: {data_type}") + + preferred_api = self.immortal_api_mapping[data_type][immortal_name] + + # 尝试首选API + result = self._try_api(preferred_api, data_type, symbol) + if result.success: + self._cache_data(cache_key, result) + print(f" ✅ 成功从 {preferred_api} 获取数据 (响应时间: {result.response_time:.2f}s)") + return result + + # 故障转移到备用API + print(f" ⚠️ {preferred_api} 不可用,尝试备用API...") + backup_apis = self.failover_priority.get(preferred_api, []) + + for backup_api in backup_apis: + if data_type in self.api_configs[backup_api]['endpoints']: + result = self._try_api(backup_api, data_type, symbol) + if result.success: + self._cache_data(cache_key, result) + print(f" ✅ 成功从备用API {backup_api} 获取数据 (响应时间: {result.response_time:.2f}s)") + return result + + # 所有API都失败 + print(f" ❌ 所有API都不可用") + return APIResult(False, {}, '', 0, "All APIs failed") + + def _try_api(self, api_name: str, data_type: str, symbol: str = None) -> APIResult: + """尝试调用指定API""" + # 检查API健康状态和速率限制 + if not self.health_checker.is_healthy(api_name): + return APIResult(False, {}, api_name, 0, "API is unhealthy") + + if self.rate_limiter.is_rate_limited(api_name): + return APIResult(False, {}, api_name, 0, "Rate limited") + + # 构建请求 + config = self.api_configs[api_name] + if data_type not in config['endpoints']: + return APIResult(False, {}, api_name, 0, f"Endpoint {data_type} not supported") + + endpoint = config['endpoints'][data_type] + if symbol and '{symbol}' in endpoint: + endpoint = endpoint.format(symbol=symbol) + + url = f"https://{config['host']}{endpoint}" + headers = { + 'X-RapidAPI-Key': self.rapidapi_key, + 'X-RapidAPI-Host': config['host'] + } + + # 发起请求 + start_time = time.time() + try: + response = requests.get(url, headers=headers, timeout=10) + response_time = time.time() - start_time + + self.rate_limiter.record_call(api_name) + + if response.status_code == 200: + data = response.json() + + # 数据标准化 + if data_type == 'stock_quote': + normalized_data = self.data_normalizer.normalize_stock_quote(data, api_name) + else: + normalized_data = data + + self.health_checker.record_success(api_name) + return APIResult(True, normalized_data, api_name, response_time) + else: + error_msg = f"HTTP {response.status_code}: {response.text[:200]}" + self.health_checker.record_failure(api_name) + return APIResult(False, {}, api_name, response_time, error_msg) + + except Exception as e: + response_time = time.time() - start_time + self.health_checker.record_failure(api_name) + return APIResult(False, {}, api_name, response_time, str(e)) + + def _get_cached_data(self, cache_key: str) -> Optional[APIResult]: + """获取缓存数据""" + if cache_key in self.cache: + cached_item = self.cache[cache_key] + if time.time() - cached_item['timestamp'] < self.cache_ttl: + result = cached_item['result'] + result.cached = True + return result + else: + # 缓存过期,删除 + del self.cache[cache_key] + return None + + def _cache_data(self, cache_key: str, result: APIResult): + """缓存数据""" + self.cache[cache_key] = { + 'result': result, + 'timestamp': time.time() + } + + def get_load_distribution(self) -> dict: + """获取负载分布统计""" + api_calls = {} + total_calls = 0 + + for api_name, calls in self.rate_limiter.api_calls.items(): + call_count = len(calls) + api_calls[api_name] = call_count + total_calls += call_count + + if total_calls == 0: + return {} + + distribution = {} + for api_name, call_count in api_calls.items(): + health_status = self.health_checker.health_status[api_name] + distribution[api_name] = { + 'calls': call_count, + 'percentage': (call_count / total_calls) * 100, + 'healthy': health_status['healthy'], + 'consecutive_failures': health_status['consecutive_failures'] + } + + return distribution + + def conduct_immortal_debate(self, topic_symbol: str) -> Dict[str, APIResult]: + """进行八仙论道,每个仙人获取不同的数据""" + print(f"\n🏛️ 稷下学宫八仙论道开始 - 主题: {topic_symbol}") + print("=" * 60) + + immortals = ['吕洞宾', '何仙姑', '张果老', '韩湘子', '汉钟离', '蓝采和', '曹国舅', '铁拐李'] + debate_results = {} + + # 每个仙人获取股票报价数据 + for immortal in immortals: + result = self.get_data_for_immortal(immortal, 'stock_quote', topic_symbol) + debate_results[immortal] = result + + if result.success: + data = result.data + if 'price' in data: + print(f" 💰 {immortal}: ${data['price']:.2f} ({data.get('change_percent', 'N/A')}) via {result.api_used}") + + time.sleep(0.2) # 避免过快请求 + + print("\n📊 负载分布统计:") + distribution = self.get_load_distribution() + for api_name, stats in distribution.items(): + print(f" {api_name}: {stats['calls']} 次调用 ({stats['percentage']:.1f}%) - {'健康' if stats['healthy'] else '异常'}") + + return debate_results + +# 使用示例 +if __name__ == "__main__": + # 从环境变量获取API密钥 + rapidapi_key = os.getenv('RAPIDAPI_KEY') + if not rapidapi_key: + print("❌ 请设置RAPIDAPI_KEY环境变量") + exit(1) + + # 创建负载均衡器 + load_balancer = JixiaLoadBalancer(rapidapi_key) + + # 进行八仙论道 + results = load_balancer.conduct_immortal_debate('TSLA') + + print("\n🎉 八仙论道完成!") \ No newline at end of file diff --git a/jixia_ollama_swarm.py b/src/jixia/jixia_ollama_swarm.py similarity index 100% rename from jixia_ollama_swarm.py rename to src/jixia/jixia_ollama_swarm.py diff --git a/jixia_swarm_complete.py b/src/jixia/jixia_swarm_complete.py similarity index 100% rename from jixia_swarm_complete.py rename to src/jixia/jixia_swarm_complete.py diff --git a/mongodb_swarm_example.py b/src/jixia/mongodb_swarm_example.py similarity index 100% rename from mongodb_swarm_example.py rename to src/jixia/mongodb_swarm_example.py diff --git a/ollama_swarm_mongodb_integration.py b/src/jixia/ollama_swarm_mongodb_integration.py similarity index 100% rename from ollama_swarm_mongodb_integration.py rename to src/jixia/ollama_swarm_mongodb_integration.py diff --git a/yijing_debate_system.md b/src/jixia/yijing_debate_system.md similarity index 100% rename from yijing_debate_system.md rename to src/jixia/yijing_debate_system.md diff --git a/src/mcp/playground-1.mongodb.js b/src/mcp/playground-1.mongodb.js new file mode 100644 index 0000000..e1fb82a --- /dev/null +++ b/src/mcp/playground-1.mongodb.js @@ -0,0 +1,30 @@ +/* global use, db */ +// MongoDB Playground +// Use Ctrl+Space inside a snippet or a string literal to trigger completions. + +// The current database to use. +use('taigong'); + +// Search for documents in the current collection. +db.getCollection('articles') + .find( + { + /* + * Filter + * fieldA: value or expression + */ + }, + { + /* + * Projection + * _id: 0, // exclude _id + * fieldA: 1 // include field + */ + } + ) + .sort({ + /* + * fieldA: 1 // ascending + * fieldB: -1 // descending + */ + }); diff --git a/src/swarm_trigger.py b/src/swarm_trigger.py new file mode 100644 index 0000000..4cdd332 --- /dev/null +++ b/src/swarm_trigger.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 +""" +Swarm辩论触发器 +基于时间群聚效应和语义相似性触发蜂群辩论 +""" + +import os +from datetime import datetime, timedelta +from pymongo import MongoClient +from typing import List, Dict, Optional +import numpy as np + +class SwarmDebateTrigger: + def __init__(self): + self.mongodb_uri = os.getenv('MONGODB_URI') + self.client = MongoClient(self.mongodb_uri) + self.db = self.client.taigong + self.collection = self.db.articles + + # 配置参数 + self.swarm_threshold = int(os.getenv('SWARM_THRESHOLD', 5)) + self.time_window_hours = int(os.getenv('SWARM_TIME_WINDOW_HOURS', 24)) + + def detect_time_clustering(self) -> List[Dict]: + """检测时间窗口内的文章群聚效应""" + # 计算时间窗口 + now = datetime.utcnow() + time_threshold = now - timedelta(hours=self.time_window_hours) + + # 使用published_time_index查询最近文章 + recent_articles = list(self.collection.find({ + "published_time": {"$gte": time_threshold} + }).sort("published_time", -1)) + + print(f"最近{self.time_window_hours}小时内发现 {len(recent_articles)} 篇文章") + + if len(recent_articles) >= self.swarm_threshold: + print(f"✓ 触发群聚效应!文章数量({len(recent_articles)}) >= 阈值({self.swarm_threshold})") + return recent_articles + else: + print(f"× 未达到群聚阈值,需要至少 {self.swarm_threshold} 篇文章") + return [] + + def find_semantic_clusters(self, articles: List[Dict], similarity_threshold: float = 0.8) -> List[List[Dict]]: + """基于向量相似性找到语义聚类""" + if not articles: + return [] + + # 过滤有embedding的文章 + articles_with_embeddings = [ + article for article in articles + if 'embedding' in article and article['embedding'] + ] + + if len(articles_with_embeddings) < 2: + print("× 没有足够的embedding数据进行语义聚类") + return [articles_with_embeddings] if articles_with_embeddings else [] + + print(f"对 {len(articles_with_embeddings)} 篇文章进行语义聚类分析...") + + # 简单的相似性聚类算法 + clusters = [] + used_indices = set() + + for i, article1 in enumerate(articles_with_embeddings): + if i in used_indices: + continue + + cluster = [article1] + used_indices.add(i) + + for j, article2 in enumerate(articles_with_embeddings): + if j in used_indices or i == j: + continue + + # 计算余弦相似度 + similarity = self.cosine_similarity( + article1['embedding'], + article2['embedding'] + ) + + if similarity >= similarity_threshold: + cluster.append(article2) + used_indices.add(j) + + if len(cluster) >= 2: # 至少2篇文章才算一个有效聚类 + clusters.append(cluster) + print(f"✓ 发现语义聚类,包含 {len(cluster)} 篇相关文章") + + return clusters + + def cosine_similarity(self, vec1: List[float], vec2: List[float]) -> float: + """计算两个向量的余弦相似度""" + try: + vec1 = np.array(vec1) + vec2 = np.array(vec2) + + dot_product = np.dot(vec1, vec2) + norm1 = np.linalg.norm(vec1) + norm2 = np.linalg.norm(vec2) + + if norm1 == 0 or norm2 == 0: + return 0 + + return dot_product / (norm1 * norm2) + except Exception as e: + print(f"计算相似度失败: {e}") + return 0 + + def trigger_swarm_debate(self, clusters: List[List[Dict]]) -> bool: + """触发swarm蜂群辩论""" + if not clusters: + print("× 没有发现有效的语义聚类,不触发辩论") + return False + + print(f"\n🔥 触发Swarm蜂群辩论!") + print(f"发现 {len(clusters)} 个语义聚类") + + for i, cluster in enumerate(clusters): + print(f"\n聚类 {i+1}: {len(cluster)} 篇文章") + for article in cluster: + title = article.get('title', '无标题')[:50] + time_str = article.get('published_time', '').strftime('%Y-%m-%d %H:%M') if article.get('published_time') else '未知时间' + print(f" - {title}... ({time_str})") + + # TODO: 在这里调用实际的辩论系统 + # 例如: jixia_swarm_debate(clusters) + + return True + + def run(self) -> bool: + """运行swarm辩论触发检测""" + print("🔍 开始检测swarm辩论触发条件...") + + # 1. 检测时间群聚效应 + recent_articles = self.detect_time_clustering() + if not recent_articles: + return False + + # 2. 进行语义聚类分析 + semantic_clusters = self.find_semantic_clusters(recent_articles) + + # 3. 触发辩论 + return self.trigger_swarm_debate(semantic_clusters) + +if __name__ == "__main__": + trigger = SwarmDebateTrigger() + trigger.run() \ No newline at end of file diff --git a/test_alpha_vantage_meta.py b/test_alpha_vantage_meta.py new file mode 100644 index 0000000..193a288 --- /dev/null +++ b/test_alpha_vantage_meta.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +""" +Alpha Vantage API 测试脚本 - Meta (META) 财报和分析师评级 +""" + +import os +import requests +import json +from datetime import datetime + +def get_alpha_vantage_key(): + """从环境变量获取 Alpha Vantage API Key""" + api_key = os.getenv('ALPHA_VANTAGE_API_KEY') + if not api_key: + raise ValueError("未找到 ALPHA_VANTAGE_API_KEY 环境变量") + return api_key + +def get_company_overview(symbol, api_key): + """获取公司基本信息和财务概览""" + url = f"https://www.alphavantage.co/query" + params = { + 'function': 'OVERVIEW', + 'symbol': symbol, + 'apikey': api_key + } + + response = requests.get(url, params=params) + return response.json() + +def get_earnings_data(symbol, api_key): + """获取财报数据""" + url = f"https://www.alphavantage.co/query" + params = { + 'function': 'EARNINGS', + 'symbol': symbol, + 'apikey': api_key + } + + response = requests.get(url, params=params) + return response.json() + +def get_analyst_ratings(symbol, api_key): + """获取分析师评级(需要付费版本,这里尝试调用看是否有数据)""" + url = f"https://www.alphavantage.co/query" + params = { + 'function': 'ANALYST_RECOMMENDATIONS', + 'symbol': symbol, + 'apikey': api_key + } + + response = requests.get(url, params=params) + return response.json() + +def get_income_statement(symbol, api_key): + """获取损益表""" + url = f"https://www.alphavantage.co/query" + params = { + 'function': 'INCOME_STATEMENT', + 'symbol': symbol, + 'apikey': api_key + } + + response = requests.get(url, params=params) + return response.json() + +def format_financial_data(data, title): + """格式化财务数据输出""" + print(f"\n{'='*60}") + print(f"{title}") + print(f"{'='*60}") + + if isinstance(data, dict): + if 'Error Message' in data: + print(f"❌ 错误: {data['Error Message']}") + elif 'Note' in data: + print(f"⚠️ 注意: {data['Note']}") + else: + print(json.dumps(data, indent=2, ensure_ascii=False)) + else: + print(data) + +def main(): + """主函数""" + try: + # 获取 API Key + api_key = get_alpha_vantage_key() + print(f"✅ 成功获取 Alpha Vantage API Key: {api_key[:8]}...") + + symbol = "META" # Meta Platforms Inc. + print(f"\n🔍 正在获取 {symbol} 的财务数据...") + + # 1. 公司概览 + print("\n📊 获取公司概览...") + overview = get_company_overview(symbol, api_key) + format_financial_data(overview, f"{symbol} - 公司概览") + + # 2. 财报数据 + print("\n📈 获取财报数据...") + earnings = get_earnings_data(symbol, api_key) + format_financial_data(earnings, f"{symbol} - 财报数据") + + # 3. 分析师评级 + print("\n⭐ 获取分析师评级...") + ratings = get_analyst_ratings(symbol, api_key) + format_financial_data(ratings, f"{symbol} - 分析师评级") + + # 4. 损益表 + print("\n💰 获取损益表...") + income_statement = get_income_statement(symbol, api_key) + format_financial_data(income_statement, f"{symbol} - 损益表") + + print(f"\n✅ {symbol} 数据获取完成!") + print(f"⏰ 完成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") + + except Exception as e: + print(f"❌ 错误: {str(e)}") + return 1 + + return 0 + +if __name__ == "__main__": + exit(main()) \ No newline at end of file diff --git a/test_rss_data_reader.py b/test_rss_data_reader.py deleted file mode 100644 index 64a2772..0000000 --- a/test_rss_data_reader.py +++ /dev/null @@ -1,488 +0,0 @@ -#!/usr/bin/env python3 -""" -RSS数据读取测试器 -测试从MongoDB读取RSS新闻数据,并分析索引需求 -""" - -import asyncio -import json -import logging -import time -from datetime import datetime, timezone, timedelta -from typing import Dict, List, Any, Optional -from src.mcp.swarm_mongodb_client import SwarmMongoDBClient - -class RSSDataReader: - """RSS数据读取器和分析器""" - - def __init__(self, mongodb_client: SwarmMongoDBClient, database_name: str = "news_debate_db"): - self.mongodb_client = mongodb_client - self.database_name = database_name - self.collection_name = "news_articles" - self.logger = logging.getLogger(__name__) - - async def connect_to_database(self) -> bool: - """连接到数据库""" - try: - result = self.mongodb_client.connect(self.database_name) - if result.get('success'): - self.logger.info(f"成功连接到数据库: {self.database_name}") - return True - else: - self.logger.error(f"数据库连接失败: {result}") - return False - except Exception as e: - self.logger.error(f"数据库连接异常: {e}") - return False - - async def get_collection_stats(self) -> Dict[str, Any]: - """获取集合统计信息""" - try: - # 获取文档总数 - count_result = self.mongodb_client.count_documents(self.collection_name) - total_count = count_result.get('count', 0) if count_result.get('success') else 0 - - # 获取最新的几条记录来分析数据结构 - latest_docs = self.mongodb_client.find_documents( - self.collection_name, - query={}, - sort={'collected_at': -1}, - limit=5 - ) - - # 获取最早的记录 - earliest_docs = self.mongodb_client.find_documents( - self.collection_name, - query={}, - sort={'collected_at': 1}, - limit=1 - ) - - stats = { - 'total_documents': total_count, - 'latest_documents': latest_docs.get('documents', []) if latest_docs.get('success') else [], - 'earliest_document': earliest_docs.get('documents', []) if earliest_docs.get('success') else [], - 'collection_exists': total_count > 0 - } - - return stats - - except Exception as e: - self.logger.error(f"获取集合统计信息失败: {e}") - return {'error': str(e)} - - async def analyze_data_structure(self, sample_size: int = 10) -> Dict[str, Any]: - """分析数据结构""" - try: - # 获取样本数据 - sample_result = self.mongodb_client.find_documents( - self.collection_name, - query={}, - limit=sample_size - ) - - if not sample_result.get('success'): - return {'error': '无法获取样本数据'} - - documents = sample_result.get('documents', []) - if not documents: - return {'error': '没有找到任何文档'} - - # 分析字段结构 - field_analysis = {} - for doc in documents: - for field, value in doc.items(): - if field not in field_analysis: - field_analysis[field] = { - 'type': type(value).__name__, - 'sample_values': [], - 'count': 0 - } - - field_analysis[field]['count'] += 1 - if len(field_analysis[field]['sample_values']) < 3: - field_analysis[field]['sample_values'].append(str(value)[:100]) # 限制长度 - - # 分析常见查询字段 - query_fields = { - 'title': '标题搜索', - 'category': '分类筛选', - 'published': '时间范围查询', - 'collected_at': '收集时间排序', - 'tags': '标签搜索', - 'source_title': '来源筛选' - } - - return { - 'sample_count': len(documents), - 'field_analysis': field_analysis, - 'recommended_query_fields': query_fields, - 'sample_document': documents[0] if documents else None - } - - except Exception as e: - self.logger.error(f"数据结构分析失败: {e}") - return {'error': str(e)} - - async def test_query_performance(self) -> Dict[str, Any]: - """测试查询性能""" - performance_results = {} - - # 测试不同类型的查询 - test_queries = [ - { - 'name': '全表扫描', - 'query': {}, - 'sort': None, - 'limit': 10 - }, - { - 'name': '按时间排序', - 'query': {}, - 'sort': {'collected_at': -1}, - 'limit': 10 - }, - { - 'name': '标题文本搜索', - 'query': {'title': {'$regex': '市场', '$options': 'i'}}, - 'sort': None, - 'limit': 10 - }, - { - 'name': '分类筛选', - 'query': {'category': '财经新闻'}, - 'sort': None, - 'limit': 10 - }, - { - 'name': '时间范围查询', - 'query': { - 'collected_at': { - '$gte': datetime.now(timezone.utc) - timedelta(days=7) - } - }, - 'sort': {'collected_at': -1}, - 'limit': 10 - } - ] - - for test in test_queries: - try: - start_time = time.time() - - result = self.mongodb_client.find_documents( - self.collection_name, - query=test['query'], - sort=test.get('sort'), - limit=test['limit'] - ) - - end_time = time.time() - query_time = (end_time - start_time) * 1000 # 转换为毫秒 - - performance_results[test['name']] = { - 'query_time_ms': round(query_time, 2), - 'success': result.get('success', False), - 'document_count': len(result.get('documents', [])), - 'query': test['query'] - } - - except Exception as e: - performance_results[test['name']] = { - 'error': str(e), - 'query': test['query'] - } - - return performance_results - - async def check_existing_indexes(self) -> Dict[str, Any]: - """检查现有索引""" - try: - # 注意:这里需要使用MongoDB的原生命令来获取索引信息 - # 由于SwarmMongoDBClient可能没有直接的索引查询方法,我们尝试其他方式 - - # 尝试通过聚合管道获取索引信息 - pipeline = [ - {"$indexStats": {}} - ] - - # 如果客户端支持聚合查询 - if hasattr(self.mongodb_client, 'aggregate_documents'): - result = self.mongodb_client.aggregate_documents( - self.collection_name, - pipeline=pipeline - ) - - if result.get('success'): - return { - 'indexes': result.get('documents', []), - 'method': 'aggregation' - } - - # 如果无法直接获取索引信息,返回建议 - return { - 'message': '无法直接查询索引信息,建议手动检查', - 'method': 'manual_check_needed' - } - - except Exception as e: - return { - 'error': str(e), - 'message': '索引查询失败' - } - - def generate_index_recommendations(self, performance_results: Dict[str, Any], - data_analysis: Dict[str, Any]) -> Dict[str, Any]: - """生成索引建议""" - recommendations = { - 'basic_indexes': [], - 'compound_indexes': [], - 'text_indexes': [], - 'vector_indexes': [], - 'reasoning': [] - } - - # 基础索引建议 - slow_queries = [name for name, result in performance_results.items() - if isinstance(result, dict) and result.get('query_time_ms', 0) > 100] - - if slow_queries: - recommendations['reasoning'].append(f"发现慢查询: {', '.join(slow_queries)}") - - # 基于数据结构的索引建议 - field_analysis = data_analysis.get('field_analysis', {}) - - # 时间字段索引(用于排序和范围查询) - if 'collected_at' in field_analysis: - recommendations['basic_indexes'].append({ - 'field': 'collected_at', - 'type': 'descending', - 'reason': '用于时间排序和范围查询' - }) - - if 'published' in field_analysis: - recommendations['basic_indexes'].append({ - 'field': 'published', - 'type': 'descending', - 'reason': '用于发布时间查询' - }) - - # 分类字段索引 - if 'category' in field_analysis: - recommendations['basic_indexes'].append({ - 'field': 'category', - 'type': 'ascending', - 'reason': '用于分类筛选' - }) - - # 唯一标识符索引 - if 'article_id' in field_analysis: - recommendations['basic_indexes'].append({ - 'field': 'article_id', - 'type': 'ascending', - 'unique': True, - 'reason': '唯一标识符,防止重复' - }) - - # 复合索引建议 - recommendations['compound_indexes'].append({ - 'fields': ['category', 'collected_at'], - 'reason': '支持按分类筛选并按时间排序' - }) - - # 文本搜索索引 - text_fields = [] - for field in ['title', 'description', 'summary']: - if field in field_analysis: - text_fields.append(field) - - if text_fields: - recommendations['text_indexes'].append({ - 'fields': text_fields, - 'type': 'text', - 'reason': '支持全文搜索' - }) - - # 向量索引建议 - recommendations['vector_indexes'].append({ - 'consideration': '如果需要语义搜索', - 'fields': ['title', 'description'], - 'method': 'embedding + vector_search', - 'reason': '用于基于内容相似性的智能搜索和推荐' - }) - - return recommendations - - async def test_sample_queries(self) -> Dict[str, Any]: - """测试一些示例查询""" - sample_queries = {} - - try: - # 1. 获取最新10条新闻 - latest_news = self.mongodb_client.find_documents( - self.collection_name, - query={}, - sort={'collected_at': -1}, - limit=10 - ) - sample_queries['latest_news'] = { - 'success': latest_news.get('success'), - 'count': len(latest_news.get('documents', [])), - 'sample_titles': [doc.get('title', 'N/A')[:50] + '...' - for doc in latest_news.get('documents', [])[:3]] - } - - # 2. 按分类查询 - category_news = self.mongodb_client.find_documents( - self.collection_name, - query={'category': '财经新闻'}, - limit=5 - ) - sample_queries['category_news'] = { - 'success': category_news.get('success'), - 'count': len(category_news.get('documents', [])), - 'category': '财经新闻' - } - - # 3. 关键词搜索 - keyword_search = self.mongodb_client.find_documents( - self.collection_name, - query={'title': {'$regex': '投资|股票|市场', '$options': 'i'}}, - limit=5 - ) - sample_queries['keyword_search'] = { - 'success': keyword_search.get('success'), - 'count': len(keyword_search.get('documents', [])), - 'keywords': '投资|股票|市场' - } - - except Exception as e: - sample_queries['error'] = str(e) - - return sample_queries - - async def run_comprehensive_analysis(self) -> Dict[str, Any]: - """运行完整的数据分析""" - self.logger.info("开始RSS数据分析...") - - # 连接数据库 - if not await self.connect_to_database(): - return {'error': '无法连接到数据库'} - - analysis_results = {} - - # 1. 获取集合统计信息 - self.logger.info("获取集合统计信息...") - analysis_results['collection_stats'] = await self.get_collection_stats() - - # 2. 分析数据结构 - self.logger.info("分析数据结构...") - analysis_results['data_structure'] = await self.analyze_data_structure() - - # 3. 测试查询性能 - self.logger.info("测试查询性能...") - analysis_results['query_performance'] = await self.test_query_performance() - - # 4. 检查现有索引 - self.logger.info("检查现有索引...") - analysis_results['existing_indexes'] = await self.check_existing_indexes() - - # 5. 生成索引建议 - self.logger.info("生成索引建议...") - analysis_results['index_recommendations'] = self.generate_index_recommendations( - analysis_results['query_performance'], - analysis_results['data_structure'] - ) - - # 6. 测试示例查询 - self.logger.info("测试示例查询...") - analysis_results['sample_queries'] = await self.test_sample_queries() - - return analysis_results - -async def main(): - """主函数""" - # 初始化MongoDB客户端 - mongodb_client = SwarmMongoDBClient( - mcp_server_url="http://localhost:8080", - default_database="news_debate_db" - ) - - # 创建数据读取器 - reader = RSSDataReader(mongodb_client) - - # 运行分析 - results = await reader.run_comprehensive_analysis() - - # 输出结果 - print("\n" + "="*60) - print("RSS数据分析报告") - print("="*60) - - # 集合统计 - stats = results.get('collection_stats', {}) - print(f"\n📊 集合统计:") - print(f" 总文档数: {stats.get('total_documents', 0)}") - print(f" 集合存在: {stats.get('collection_exists', False)}") - - # 数据结构 - structure = results.get('data_structure', {}) - if 'field_analysis' in structure: - print(f"\n🏗️ 数据结构:") - for field, info in structure['field_analysis'].items(): - print(f" {field}: {info['type']} (出现{info['count']}次)") - - # 查询性能 - performance = results.get('query_performance', {}) - print(f"\n⚡ 查询性能:") - for query_name, result in performance.items(): - if isinstance(result, dict) and 'query_time_ms' in result: - print(f" {query_name}: {result['query_time_ms']}ms ({result['document_count']}条结果)") - - # 索引建议 - recommendations = results.get('index_recommendations', {}) - print(f"\n💡 索引建议:") - - basic_indexes = recommendations.get('basic_indexes', []) - if basic_indexes: - print(f" 基础索引:") - for idx in basic_indexes: - print(f" - {idx['field']} ({idx.get('type', 'ascending')}): {idx['reason']}") - - compound_indexes = recommendations.get('compound_indexes', []) - if compound_indexes: - print(f" 复合索引:") - for idx in compound_indexes: - print(f" - {', '.join(idx['fields'])}: {idx['reason']}") - - text_indexes = recommendations.get('text_indexes', []) - if text_indexes: - print(f" 文本索引:") - for idx in text_indexes: - print(f" - {', '.join(idx['fields'])}: {idx['reason']}") - - vector_indexes = recommendations.get('vector_indexes', []) - if vector_indexes: - print(f" 向量索引建议:") - for idx in vector_indexes: - print(f" - {idx['consideration']}: {idx['reason']}") - - # 示例查询结果 - samples = results.get('sample_queries', {}) - print(f"\n🔍 示例查询:") - for query_name, result in samples.items(): - if isinstance(result, dict) and 'count' in result: - print(f" {query_name}: {result['count']}条结果") - - print(f"\n" + "="*60) - print("分析完成!") - print("="*60) - - # 保存详细结果到文件 - with open('/home/ben/liurenchaxin/rss_analysis_report.json', 'w', encoding='utf-8') as f: - json.dump(results, f, ensure_ascii=False, indent=2, default=str) - print("\n详细报告已保存到: rss_analysis_report.json") - -if __name__ == "__main__": - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - asyncio.run(main()) \ No newline at end of file