Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files
README.md
CHANGED
|
@@ -1,13 +1,39 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: mit
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: SEC Financial Data Query Assistant
|
| 3 |
+
emoji: 📊
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.0.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# SEC Financial Data Query Assistant
|
| 14 |
+
|
| 15 |
+
A Gradio-based web application for querying SEC financial data through MCP Server.
|
| 16 |
+
|
| 17 |
+
## Features
|
| 18 |
+
|
| 19 |
+
- 🔍 Search companies by name or ticker symbol
|
| 20 |
+
- 📈 View latest financial data
|
| 21 |
+
- 📊 Analyze 3-year and 5-year financial trends
|
| 22 |
+
- 💰 Display revenue, net income, EPS, operating expenses, and cash flow metrics
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
Simply enter a company name or ticker symbol (e.g., NVIDIA, AAPL, Microsoft) and select the query type:
|
| 27 |
+
- **Latest Financial Data**: Shows the most recent fiscal year data
|
| 28 |
+
- **3-Year Trend**: Displays financial trends over 3 years
|
| 29 |
+
- **5-Year Trend**: Displays financial trends over 5 years
|
| 30 |
+
|
| 31 |
+
## Data Source
|
| 32 |
+
|
| 33 |
+
SEC EDGAR data via MCP Server: https://jc321-easyreportdatemcp.hf.space
|
| 34 |
+
|
| 35 |
+
## Technology Stack
|
| 36 |
+
|
| 37 |
+
- **Frontend**: Gradio 4.0+
|
| 38 |
+
- **Backend**: Python with requests
|
| 39 |
+
- **Data Source**: SEC EDGAR via MCP Server
|
app.py
CHANGED
|
@@ -68,6 +68,8 @@ def query_financial_data(company_name, query_type):
|
|
| 68 |
result += f"- **总收入**: ${data.get('total_revenue', 0):,.0f} (${data.get('total_revenue', 0)/1e9:.2f}B)\n"
|
| 69 |
result += f"- **净利润**: ${data.get('net_income', 0):,.0f} (${data.get('net_income', 0)/1e9:.2f}B)\n"
|
| 70 |
result += f"- **每股收益**: ${data.get('earnings_per_share', 0):.2f}\n"
|
|
|
|
|
|
|
| 71 |
result += f"- **来源**: {data.get('source_form', 'N/A')}\n"
|
| 72 |
|
| 73 |
elif query_type == "3年趋势":
|
|
@@ -89,20 +91,22 @@ def query_financial_data(company_name, query_type):
|
|
| 89 |
if isinstance(metrics, dict) and metrics.get("error"):
|
| 90 |
return result + f"❌ {metrics['error']}"
|
| 91 |
|
| 92 |
-
result += f"##
|
| 93 |
|
| 94 |
# 只显示年度数据
|
| 95 |
annual_data = [m for m in metrics.get('metrics', []) if 'Q' not in m.get('period', '')][:3]
|
| 96 |
|
| 97 |
-
result += "|
|
| 98 |
-
result += "
|
| 99 |
|
| 100 |
for m in annual_data:
|
| 101 |
-
period = m
|
| 102 |
rev = m.get('total_revenue', 0) / 1e9
|
| 103 |
inc = m.get('net_income', 0) / 1e9
|
| 104 |
eps = m.get('earnings_per_share', 0)
|
| 105 |
-
|
|
|
|
|
|
|
| 106 |
|
| 107 |
elif query_type == "5年趋势":
|
| 108 |
metrics_resp = requests.post(
|
|
@@ -125,15 +129,18 @@ def query_financial_data(company_name, query_type):
|
|
| 125 |
|
| 126 |
annual_data = [m for m in metrics.get('metrics', []) if 'Q' not in m.get('period', '')][:5]
|
| 127 |
|
| 128 |
-
result += f"## 5
|
| 129 |
-
result += "|
|
| 130 |
-
result += "
|
| 131 |
|
| 132 |
for m in annual_data:
|
|
|
|
| 133 |
rev = m.get('total_revenue', 0) / 1e9
|
| 134 |
inc = m.get('net_income', 0) / 1e9
|
| 135 |
eps = m.get('earnings_per_share', 0)
|
| 136 |
-
|
|
|
|
|
|
|
| 137 |
|
| 138 |
return result
|
| 139 |
|
|
|
|
| 68 |
result += f"- **总收入**: ${data.get('total_revenue', 0):,.0f} (${data.get('total_revenue', 0)/1e9:.2f}B)\n"
|
| 69 |
result += f"- **净利润**: ${data.get('net_income', 0):,.0f} (${data.get('net_income', 0)/1e9:.2f}B)\n"
|
| 70 |
result += f"- **每股收益**: ${data.get('earnings_per_share', 0):.2f}\n"
|
| 71 |
+
result += f"- **运营花费**: ${data.get('operating_expenses', 0):,.0f} (${data.get('operating_expenses', 0)/1e9:.2f}B)\n"
|
| 72 |
+
result += f"- **运营现金流**: ${data.get('operating_cash_flow', 0):,.0f} (${data.get('operating_cash_flow', 0)/1e9:.2f}B)\n"
|
| 73 |
result += f"- **来源**: {data.get('source_form', 'N/A')}\n"
|
| 74 |
|
| 75 |
elif query_type == "3年趋势":
|
|
|
|
| 91 |
if isinstance(metrics, dict) and metrics.get("error"):
|
| 92 |
return result + f"❌ {metrics['error']}"
|
| 93 |
|
| 94 |
+
result += f"## Financial Trends ({metrics.get('count', 0)} periods)\n\n"
|
| 95 |
|
| 96 |
# 只显示年度数据
|
| 97 |
annual_data = [m for m in metrics.get('metrics', []) if 'Q' not in m.get('period', '')][:3]
|
| 98 |
|
| 99 |
+
result += "| Period | Revenue (B) | Net Income (B) | EPS | Operating Expenses (B) | Operating Cash Flow (B) |\n"
|
| 100 |
+
result += "|--------|-------------|----------------|-----|------------------------|-------------------------|\n"
|
| 101 |
|
| 102 |
for m in annual_data:
|
| 103 |
+
period = m.get('period', 'N/A')
|
| 104 |
rev = m.get('total_revenue', 0) / 1e9
|
| 105 |
inc = m.get('net_income', 0) / 1e9
|
| 106 |
eps = m.get('earnings_per_share', 0)
|
| 107 |
+
opex = m.get('operating_expenses', 0) / 1e9
|
| 108 |
+
ocf = m.get('operating_cash_flow', 0) / 1e9
|
| 109 |
+
result += f"| FY{period} | ${rev:.2f}B | ${inc:.2f}B | ${eps:.2f} | ${opex:.2f}B | ${ocf:.2f}B |\n"
|
| 110 |
|
| 111 |
elif query_type == "5年趋势":
|
| 112 |
metrics_resp = requests.post(
|
|
|
|
| 129 |
|
| 130 |
annual_data = [m for m in metrics.get('metrics', []) if 'Q' not in m.get('period', '')][:5]
|
| 131 |
|
| 132 |
+
result += f"## 5-Year Financial Trends\n\n"
|
| 133 |
+
result += "| Period | Revenue (B) | Net Income (B) | EPS | Operating Expenses (B) | Operating Cash Flow (B) |\n"
|
| 134 |
+
result += "|--------|-------------|----------------|-----|------------------------|-------------------------|\n"
|
| 135 |
|
| 136 |
for m in annual_data:
|
| 137 |
+
period = m.get('period', 'N/A')
|
| 138 |
rev = m.get('total_revenue', 0) / 1e9
|
| 139 |
inc = m.get('net_income', 0) / 1e9
|
| 140 |
eps = m.get('earnings_per_share', 0)
|
| 141 |
+
opex = m.get('operating_expenses', 0) / 1e9
|
| 142 |
+
ocf = m.get('operating_cash_flow', 0) / 1e9
|
| 143 |
+
result += f"| FY{period} | ${rev:.2f}B | ${inc:.2f}B | ${eps:.2f} | ${opex:.2f}B | ${ocf:.2f}B |\n"
|
| 144 |
|
| 145 |
return result
|
| 146 |
|