openmarkets 0.1.0.dev121__tar.gz → 0.1.0.dev122__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/PKG-INFO +9 -6
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/README.md +4 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/pyproject.toml +34 -9
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/core/config.py +0 -4
- openmarkets-0.1.0.dev122/src/openmarkets/core/constants.py +236 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/core/fastmcp.py +29 -15
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/core/server.py +1 -2
- openmarkets-0.1.0.dev122/src/openmarkets/core/types.py +40 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/analysis.py +105 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/crypto.py +101 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/financials.py +84 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/funds.py +136 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/holdings.py +63 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/markets.py +33 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/options.py +177 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/sector_industry.py +165 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/stock.py +224 -0
- openmarkets-0.1.0.dev122/src/openmarkets/repositories/technical_analysis.py +126 -0
- openmarkets-0.1.0.dev122/src/openmarkets/schemas/crypto.py +37 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/options.py +2 -2
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/sector_industry.py +14 -43
- openmarkets-0.1.0.dev122/src/openmarkets/services/__init__.py +23 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/analysis.py +130 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/crypto.py +79 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/financials.py +143 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/funds.py +138 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/holdings.py +92 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/markets.py +45 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/options.py +141 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/sector_industry.py +182 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/stock.py +193 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/technical_analysis.py +79 -0
- openmarkets-0.1.0.dev122/src/openmarkets/services/utils.py +41 -0
- openmarkets-0.1.0.dev121/src/openmarkets/core/toolset.py +0 -120
- openmarkets-0.1.0.dev121/src/openmarkets/core/types.py +0 -11
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/analysis.py +0 -114
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/financials.py +0 -111
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/funds.py +0 -149
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/holdings.py +0 -82
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/markets.py +0 -31
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/options.py +0 -201
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/sector_industry.py +0 -194
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/stock.py +0 -204
- openmarkets-0.1.0.dev121/src/openmarkets/services/yfinance/technical_analysis.py +0 -128
- openmarkets-0.1.0.dev121/src/openmarkets/tools/__init__.py +0 -4
- openmarkets-0.1.0.dev121/src/openmarkets/tools/analyst_data.py +0 -56
- openmarkets-0.1.0.dev121/src/openmarkets/tools/calendar.py +0 -96
- openmarkets-0.1.0.dev121/src/openmarkets/tools/corporate_actions.py +0 -167
- openmarkets-0.1.0.dev121/src/openmarkets/tools/crypto.py +0 -215
- openmarkets-0.1.0.dev121/src/openmarkets/tools/extended_market.py +0 -325
- openmarkets-0.1.0.dev121/src/openmarkets/tools/financial_statements.py +0 -118
- openmarkets-0.1.0.dev121/src/openmarkets/tools/funds.py +0 -180
- openmarkets-0.1.0.dev121/src/openmarkets/tools/historical_data.py +0 -111
- openmarkets-0.1.0.dev121/src/openmarkets/tools/market_data.py +0 -167
- openmarkets-0.1.0.dev121/src/openmarkets/tools/news.py +0 -172
- openmarkets-0.1.0.dev121/src/openmarkets/tools/options.py +0 -218
- openmarkets-0.1.0.dev121/src/openmarkets/tools/screener.py +0 -391
- openmarkets-0.1.0.dev121/src/openmarkets/tools/stock_info.py +0 -273
- openmarkets-0.1.0.dev121/src/openmarkets/tools/technical_analysis.py +0 -126
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/__init__.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/__main__.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/core/__init__.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/core/exceptions.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/core/serializers.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/py.typed +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/__init__.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/analysis.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/company.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/financials.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/funds.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/holdings.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/markets.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/stock.py +0 -0
- {openmarkets-0.1.0.dev121 → openmarkets-0.1.0.dev122}/src/openmarkets/schemas/technical_analysis.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: openmarkets
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev122
|
|
4
4
|
Summary: OpenMarkets is a modular Model Context Protocol (MCP) server that unifies access to financial market data for AI, research, and quantitative finance. It offers robust APIs for historical prices, corporate actions, fundamentals, and more, enabling advanced agentic retrieval, RAG, and LLM-powered workflows.
|
|
5
5
|
Keywords: machinelearning,finance,investment,mcp,modelcontextprotocol,yahoo finance,financial data retrieval
|
|
6
6
|
Author: Dobri Danchev
|
|
@@ -25,17 +25,16 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.13
|
|
26
26
|
Classifier: Programming Language :: Python :: 3.14
|
|
27
27
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
28
|
-
Requires-Dist: mcp[cli]>=1.
|
|
29
|
-
Requires-Dist: yfinance>=0.
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
28
|
+
Requires-Dist: mcp[cli]>=1.25.0
|
|
29
|
+
Requires-Dist: yfinance>=1.0.0
|
|
30
|
+
Requires-Dist: lxml>=6.0.2
|
|
31
|
+
Requires-Dist: fastmcp>=2.14.1 ; extra == 'fastmcp'
|
|
32
32
|
Requires-Python: >=3.10
|
|
33
33
|
Project-URL: Documentation, https://danchev.github.io/openmarkets/
|
|
34
34
|
Project-URL: Homepage, https://openmarkets.dev
|
|
35
35
|
Project-URL: Issues, https://github.com/danchev/openmarkets/issues
|
|
36
36
|
Project-URL: Source, https://github.com/danchev/openmarkets
|
|
37
37
|
Provides-Extra: fastmcp
|
|
38
|
-
Provides-Extra: lxml
|
|
39
38
|
Description-Content-Type: text/markdown
|
|
40
39
|
|
|
41
40
|

|
|
@@ -66,6 +65,10 @@ This MCP server can be used with various LLM applications that support the Model
|
|
|
66
65
|
- **Cursor**: AI-powered code editor with MCP support
|
|
67
66
|
- **Custom MCP clients**: Any application implementing the MCP client specification
|
|
68
67
|
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
[](https://cursor.com/en-US/install-mcp?name=openmarkets&config=eyJjb21tYW5kIjoidXZ4IG9wZW5tYXJrZXRzQGxhdGVzdCJ9)
|
|
71
|
+
|
|
69
72
|
## Usage with Claude Desktop
|
|
70
73
|
|
|
71
74
|
1. Install Claude Desktop from https://claude.ai/download
|
|
@@ -26,6 +26,10 @@ This MCP server can be used with various LLM applications that support the Model
|
|
|
26
26
|
- **Cursor**: AI-powered code editor with MCP support
|
|
27
27
|
- **Custom MCP clients**: Any application implementing the MCP client specification
|
|
28
28
|
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
[](https://cursor.com/en-US/install-mcp?name=openmarkets&config=eyJjb21tYW5kIjoidXZ4IG9wZW5tYXJrZXRzQGxhdGVzdCJ9)
|
|
32
|
+
|
|
29
33
|
## Usage with Claude Desktop
|
|
30
34
|
|
|
31
35
|
1. Install Claude Desktop from https://claude.ai/download
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "openmarkets"
|
|
3
|
-
version = "0.1.0.
|
|
3
|
+
version = "0.1.0.dev122"
|
|
4
4
|
description = "OpenMarkets is a modular Model Context Protocol (MCP) server that unifies access to financial market data for AI, research, and quantitative finance. It offers robust APIs for historical prices, corporate actions, fundamentals, and more, enabling advanced agentic retrieval, RAG, and LLM-powered workflows."
|
|
5
5
|
authors = [{ name = "Dobri Danchev" }]
|
|
6
6
|
classifiers = [
|
|
@@ -38,10 +38,12 @@ readme = "README.md"
|
|
|
38
38
|
license = { text = "AGPL-3.0-or-later" }
|
|
39
39
|
requires-python = ">=3.10"
|
|
40
40
|
dependencies = [
|
|
41
|
-
"mcp[cli]>=1.
|
|
42
|
-
"yfinance>=0.
|
|
41
|
+
"mcp[cli]>=1.25.0",
|
|
42
|
+
"yfinance>=1.0.0",
|
|
43
|
+
"lxml>=6.0.2",
|
|
44
|
+
|
|
43
45
|
]
|
|
44
|
-
optional-dependencies = {"fastmcp" = ["fastmcp>=2.
|
|
46
|
+
optional-dependencies = {"fastmcp" = ["fastmcp>=2.14.1"]}
|
|
45
47
|
|
|
46
48
|
[project.urls]
|
|
47
49
|
Homepage = "https://openmarkets.dev"
|
|
@@ -62,16 +64,17 @@ dev = [
|
|
|
62
64
|
"debugpy>=1.8.17",
|
|
63
65
|
"pyright>=1.1.407",
|
|
64
66
|
"refurb>=2.2.0",
|
|
65
|
-
"ruff>=0.14.
|
|
66
|
-
"ty>=0.0.
|
|
67
|
+
"ruff>=0.14.10",
|
|
68
|
+
"ty>=0.0.7",
|
|
67
69
|
{include-group = "test"},
|
|
68
70
|
{include-group = "commit"},
|
|
69
71
|
]
|
|
70
72
|
test = [
|
|
71
|
-
"pytest>=9.0.
|
|
73
|
+
"pytest>=9.0.2",
|
|
72
74
|
"pytest-cov>=7.0.0",
|
|
73
75
|
"pytest-xdist>=3.8.0",
|
|
74
76
|
"pytest-asyncio>=1.3.0",
|
|
77
|
+
"coverage>=7.13.0",
|
|
75
78
|
]
|
|
76
79
|
docs = [
|
|
77
80
|
"mkdocs>=1.6.1",
|
|
@@ -80,8 +83,8 @@ docs = [
|
|
|
80
83
|
"mkdocstrings-python>=1.18.2",
|
|
81
84
|
]
|
|
82
85
|
commit = [
|
|
83
|
-
"commitizen>=4.10.
|
|
84
|
-
"pre-commit>=4.
|
|
86
|
+
"commitizen>=4.10.1",
|
|
87
|
+
"pre-commit>=4.5.1",
|
|
85
88
|
]
|
|
86
89
|
|
|
87
90
|
[tool.ruff]
|
|
@@ -121,3 +124,25 @@ version_files = [
|
|
|
121
124
|
"pyproject.toml:version"
|
|
122
125
|
]
|
|
123
126
|
update_changelog_on_bump = true
|
|
127
|
+
|
|
128
|
+
[tool.coverage.run]
|
|
129
|
+
command_line = "-m openmarkets"
|
|
130
|
+
branch = true
|
|
131
|
+
source = ["openmarkets"]
|
|
132
|
+
omit = [
|
|
133
|
+
"tests/*",
|
|
134
|
+
"src/openmarkets/__init__.py",
|
|
135
|
+
"src/openmarkets/core/__init__.py",
|
|
136
|
+
"src/openmarkets/services/__init__.py",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[tool.coverage.report]
|
|
140
|
+
show_missing = true
|
|
141
|
+
skip_covered = true
|
|
142
|
+
precision = 2
|
|
143
|
+
|
|
144
|
+
[tool.ty.src]
|
|
145
|
+
exclude = [
|
|
146
|
+
"generated",
|
|
147
|
+
"typings",
|
|
148
|
+
]
|
|
@@ -43,10 +43,6 @@ class Settings(BaseSettings):
|
|
|
43
43
|
"*",
|
|
44
44
|
description="Allowed origins for CORS (Cross-Origin Resource Sharing).",
|
|
45
45
|
)
|
|
46
|
-
toolset: str = Field(
|
|
47
|
-
"openmarkets.tools",
|
|
48
|
-
description="The Python module path for the toolset to use.",
|
|
49
|
-
)
|
|
50
46
|
|
|
51
47
|
model_config = SettingsConfigDict(env_file=".env")
|
|
52
48
|
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Domain constants for crypto module (DDD domain layer).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# Top cryptocurrencies by market cap (approximate list)
|
|
6
|
+
TOP_CRYPTO_TICKERS = [
|
|
7
|
+
"BTC-USD",
|
|
8
|
+
"ETH-USD",
|
|
9
|
+
"USDT-USD",
|
|
10
|
+
"XRP-USD",
|
|
11
|
+
"BNB-USD",
|
|
12
|
+
"SOL-USD",
|
|
13
|
+
"USDC-USD",
|
|
14
|
+
"TRX-USD",
|
|
15
|
+
"STETH-USD",
|
|
16
|
+
"WTRX-USD",
|
|
17
|
+
"DOGE-USD",
|
|
18
|
+
"ADA-USD",
|
|
19
|
+
"HYPE32196-USD",
|
|
20
|
+
"WSTETH-USD",
|
|
21
|
+
"WBTC-USD",
|
|
22
|
+
"WETH-USD",
|
|
23
|
+
"BCH-USD",
|
|
24
|
+
"ZEC-USD",
|
|
25
|
+
"LINK-USD",
|
|
26
|
+
"USDS33039-USD",
|
|
27
|
+
"AETHWETH-USD",
|
|
28
|
+
"LEO-USD",
|
|
29
|
+
"XLM-USD",
|
|
30
|
+
"WEETH-USD",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
DEFAULT_SENTIMENT_TICKERS = [
|
|
34
|
+
"BTC-USD",
|
|
35
|
+
"ETH-USD",
|
|
36
|
+
"BNB-USD",
|
|
37
|
+
"XRP-USD",
|
|
38
|
+
"SOL-USD",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
MARKETS = [
|
|
42
|
+
"US",
|
|
43
|
+
"GB",
|
|
44
|
+
"ASIA",
|
|
45
|
+
"EUROPE",
|
|
46
|
+
"RATES",
|
|
47
|
+
"COMMODITIES",
|
|
48
|
+
"CURRENCIES",
|
|
49
|
+
"CRYPTOCURRENCIES",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
SECTORS = [
|
|
53
|
+
"technology",
|
|
54
|
+
"healthcare",
|
|
55
|
+
"financial-services",
|
|
56
|
+
"consumer-cyclical",
|
|
57
|
+
"communication-services",
|
|
58
|
+
"industrials",
|
|
59
|
+
"consumer-defensive",
|
|
60
|
+
"energy",
|
|
61
|
+
"utilities",
|
|
62
|
+
"real-estate",
|
|
63
|
+
"basic-materials",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
SECTOR_INDUSTRY_MAPPING: dict[str, list[str]] = {
|
|
67
|
+
"basic-materials": [
|
|
68
|
+
"agricultural-inputs",
|
|
69
|
+
"aluminum",
|
|
70
|
+
"building-materials",
|
|
71
|
+
"chemicals",
|
|
72
|
+
"coking-coal",
|
|
73
|
+
"copper",
|
|
74
|
+
"gold",
|
|
75
|
+
"lumber-wood-production",
|
|
76
|
+
"other-industrial-metals-mining",
|
|
77
|
+
"other-precious-metals-mining",
|
|
78
|
+
"paper-paper-products",
|
|
79
|
+
"silver",
|
|
80
|
+
"specialty-chemicals",
|
|
81
|
+
"steel",
|
|
82
|
+
],
|
|
83
|
+
"communication-services": [
|
|
84
|
+
"advertising-agencies",
|
|
85
|
+
"broadcasting",
|
|
86
|
+
"electronic-gaming-multimedia",
|
|
87
|
+
"entertainment",
|
|
88
|
+
"internet-content-information",
|
|
89
|
+
"publishing",
|
|
90
|
+
"telecom-services",
|
|
91
|
+
],
|
|
92
|
+
"consumer-cyclical": [
|
|
93
|
+
"apparel-manufacturing",
|
|
94
|
+
"apparel-retail",
|
|
95
|
+
"auto-manufacturers",
|
|
96
|
+
"auto-parts",
|
|
97
|
+
"auto-truck-dealerships",
|
|
98
|
+
"department-stores",
|
|
99
|
+
"footwear-accessories",
|
|
100
|
+
"furnishings-fixtures-appliances",
|
|
101
|
+
"gambling",
|
|
102
|
+
"home-improvement-retail",
|
|
103
|
+
"internet-retail",
|
|
104
|
+
"leisure",
|
|
105
|
+
"lodging",
|
|
106
|
+
"luxury-goods",
|
|
107
|
+
"packaging-containers",
|
|
108
|
+
"personal-services",
|
|
109
|
+
"recreational-vehicles",
|
|
110
|
+
"residential-construction",
|
|
111
|
+
"resorts-casinos",
|
|
112
|
+
"restaurants",
|
|
113
|
+
"specialty-retail",
|
|
114
|
+
"textile-manufacturing",
|
|
115
|
+
"travel-services",
|
|
116
|
+
],
|
|
117
|
+
"consumer-defensive": [
|
|
118
|
+
"beverages-brewers",
|
|
119
|
+
"beverages-non-alcoholic",
|
|
120
|
+
"beverages-wineries-distilleries",
|
|
121
|
+
"confectioners",
|
|
122
|
+
"discount-stores",
|
|
123
|
+
"education-training-services",
|
|
124
|
+
"farm-products",
|
|
125
|
+
"food-distribution",
|
|
126
|
+
"grocery-stores",
|
|
127
|
+
"household-personal-products",
|
|
128
|
+
"packaged-foods",
|
|
129
|
+
"tobacco",
|
|
130
|
+
],
|
|
131
|
+
"energy": [
|
|
132
|
+
"oil-gas-drilling",
|
|
133
|
+
"oil-gas-e-p",
|
|
134
|
+
"oil-gas-equipment-services",
|
|
135
|
+
"oil-gas-integrated",
|
|
136
|
+
"oil-gas-midstream",
|
|
137
|
+
"oil-gas-refining-marketing",
|
|
138
|
+
"thermal-coal",
|
|
139
|
+
"uranium",
|
|
140
|
+
],
|
|
141
|
+
"financial-services": [
|
|
142
|
+
"asset-management",
|
|
143
|
+
"banks-diversified",
|
|
144
|
+
"banks-regional",
|
|
145
|
+
"capital-markets",
|
|
146
|
+
"credit-services",
|
|
147
|
+
"financial-conglomerates",
|
|
148
|
+
"financial-data-stock-exchanges",
|
|
149
|
+
"insurance-brokers",
|
|
150
|
+
"insurance-diversified",
|
|
151
|
+
"insurance-life",
|
|
152
|
+
"insurance-property-casualty",
|
|
153
|
+
"insurance-reinsurance",
|
|
154
|
+
"insurance-specialty",
|
|
155
|
+
"mortgage-finance",
|
|
156
|
+
"shell-companies",
|
|
157
|
+
],
|
|
158
|
+
"healthcare": [
|
|
159
|
+
"biotechnology",
|
|
160
|
+
"diagnostics-research",
|
|
161
|
+
"drug-manufacturers-general",
|
|
162
|
+
"drug-manufacturers-specialty-generic",
|
|
163
|
+
"health-information-services",
|
|
164
|
+
"healthcare-plans",
|
|
165
|
+
"medical-care-facilities",
|
|
166
|
+
"medical-devices",
|
|
167
|
+
"medical-distribution",
|
|
168
|
+
"medical-instruments-supplies",
|
|
169
|
+
"pharmaceutical-retailers",
|
|
170
|
+
],
|
|
171
|
+
"industrials": [
|
|
172
|
+
"aerospace-defense",
|
|
173
|
+
"airlines",
|
|
174
|
+
"airports-air-services",
|
|
175
|
+
"building-products-equipment",
|
|
176
|
+
"business-equipment-supplies",
|
|
177
|
+
"conglomerates",
|
|
178
|
+
"consulting-services",
|
|
179
|
+
"electrical-equipment-parts",
|
|
180
|
+
"engineering-construction",
|
|
181
|
+
"farm-heavy-construction-machinery",
|
|
182
|
+
"industrial-distribution",
|
|
183
|
+
"infrastructure-operations",
|
|
184
|
+
"integrated-freight-logistics",
|
|
185
|
+
"marine-shipping",
|
|
186
|
+
"metal-fabrication",
|
|
187
|
+
"pollution-treatment-controls",
|
|
188
|
+
"railroads",
|
|
189
|
+
"rental-leasing-services",
|
|
190
|
+
"security-protection-services",
|
|
191
|
+
"specialty-business-services",
|
|
192
|
+
"specialty-industrial-machinery",
|
|
193
|
+
"staffing-employment-services",
|
|
194
|
+
"tools-accessories",
|
|
195
|
+
"trucking",
|
|
196
|
+
"waste-management",
|
|
197
|
+
],
|
|
198
|
+
"real-estate": [
|
|
199
|
+
"real-estate-development",
|
|
200
|
+
"real-estate-diversified",
|
|
201
|
+
"real-estate-services",
|
|
202
|
+
"reit-diversified",
|
|
203
|
+
"reit-healthcare-facilities",
|
|
204
|
+
"reit-hotel-motel",
|
|
205
|
+
"reit-industrial",
|
|
206
|
+
"reit-mortgage",
|
|
207
|
+
"reit-office",
|
|
208
|
+
"reit-residential",
|
|
209
|
+
"reit-retail",
|
|
210
|
+
"reit-specialty",
|
|
211
|
+
],
|
|
212
|
+
"technology": [
|
|
213
|
+
"communication-equipment",
|
|
214
|
+
"computer-hardware",
|
|
215
|
+
"consumer-electronics",
|
|
216
|
+
"electronic-components",
|
|
217
|
+
"electronics-computer-distribution",
|
|
218
|
+
"information-technology-services",
|
|
219
|
+
"scientific-technical-instruments",
|
|
220
|
+
"semiconductor-equipment-materials",
|
|
221
|
+
"semiconductors",
|
|
222
|
+
"software-application",
|
|
223
|
+
"software-infrastructure",
|
|
224
|
+
"solar",
|
|
225
|
+
],
|
|
226
|
+
"utilities": [
|
|
227
|
+
"utilities-diversified",
|
|
228
|
+
"utilities-independent-power-producers",
|
|
229
|
+
"utilities-regulated-electric",
|
|
230
|
+
"utilities-regulated-gas",
|
|
231
|
+
"utilities-regulated-water",
|
|
232
|
+
"utilities-renewable",
|
|
233
|
+
],
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
INDUSTRIES = [industry for industries in SECTOR_INDUSTRY_MAPPING.values() for industry in industries]
|
|
@@ -8,8 +8,19 @@ except ImportError:
|
|
|
8
8
|
from starlette.applications import Starlette
|
|
9
9
|
from starlette.middleware.cors import CORSMiddleware
|
|
10
10
|
|
|
11
|
-
from openmarkets.core.config import Settings
|
|
12
|
-
from openmarkets.
|
|
11
|
+
from openmarkets.core.config import Settings, get_settings
|
|
12
|
+
from openmarkets.services import (
|
|
13
|
+
analysis_service,
|
|
14
|
+
crypto_service,
|
|
15
|
+
financials_service,
|
|
16
|
+
funds_service,
|
|
17
|
+
holdings_service,
|
|
18
|
+
markets_service,
|
|
19
|
+
options_service,
|
|
20
|
+
sector_industry_service,
|
|
21
|
+
stock_service,
|
|
22
|
+
technical_analysis_service,
|
|
23
|
+
)
|
|
13
24
|
|
|
14
25
|
logger = logging.getLogger(__name__)
|
|
15
26
|
|
|
@@ -48,29 +59,32 @@ class FastMCPWithCORS(FastMCP):
|
|
|
48
59
|
return app
|
|
49
60
|
|
|
50
61
|
|
|
51
|
-
def create_mcp(config: Settings) -> FastMCP:
|
|
52
|
-
"""
|
|
53
|
-
Create and configure the MCP server instance.
|
|
54
|
-
|
|
55
|
-
Initializes the MCP server and registers all available tools
|
|
56
|
-
using the ToolRegistry. Logs any errors during tool registration.
|
|
62
|
+
def create_mcp(config: Settings | None = None) -> FastMCP:
|
|
63
|
+
"""Create and configure the FastMCP server with registered tool methods.
|
|
57
64
|
|
|
58
65
|
Args:
|
|
59
|
-
config (Settings):
|
|
60
|
-
|
|
66
|
+
config (Settings | None): Application configuration settings.
|
|
61
67
|
Returns:
|
|
62
|
-
FastMCP: Configured
|
|
63
|
-
|
|
64
|
-
Raises:
|
|
65
|
-
RuntimeError: If tool registration fails.
|
|
68
|
+
FastMCP: Configured FastMCP server instance.
|
|
66
69
|
"""
|
|
70
|
+
if config is None:
|
|
71
|
+
config = get_settings()
|
|
67
72
|
mcp = FastMCP(
|
|
68
73
|
name="Open Markets Server",
|
|
69
74
|
instructions=("This server allows for the integration of various market data tools."),
|
|
70
75
|
)
|
|
71
76
|
|
|
72
77
|
try:
|
|
73
|
-
|
|
78
|
+
analysis_service.register_tool_methods(mcp)
|
|
79
|
+
crypto_service.register_tool_methods(mcp)
|
|
80
|
+
financials_service.register_tool_methods(mcp)
|
|
81
|
+
funds_service.register_tool_methods(mcp)
|
|
82
|
+
holdings_service.register_tool_methods(mcp)
|
|
83
|
+
markets_service.register_tool_methods(mcp)
|
|
84
|
+
options_service.register_tool_methods(mcp)
|
|
85
|
+
sector_industry_service.register_tool_methods(mcp)
|
|
86
|
+
stock_service.register_tool_methods(mcp)
|
|
87
|
+
technical_analysis_service.register_tool_methods(mcp)
|
|
74
88
|
logger.info("Tool registration completed successfully.")
|
|
75
89
|
except Exception as exc:
|
|
76
90
|
logger.exception("Failed to initialize ToolRegistry or register tools.")
|
|
@@ -3,7 +3,6 @@ Open Markets Server
|
|
|
3
3
|
|
|
4
4
|
Initializes and runs the Open Markets MCP server, handling tool registration
|
|
5
5
|
and server lifecycle management.
|
|
6
|
-
Follows Google Python Style Guide for documentation and formatting.
|
|
7
6
|
"""
|
|
8
7
|
|
|
9
8
|
import logging
|
|
@@ -17,7 +16,7 @@ from openmarkets.core.fastmcp import FastMCP, create_mcp
|
|
|
17
16
|
|
|
18
17
|
logger = logging.getLogger(__name__)
|
|
19
18
|
|
|
20
|
-
settings = get_settings()
|
|
19
|
+
settings: Settings = get_settings()
|
|
21
20
|
mcp: FastMCP = create_mcp(settings)
|
|
22
21
|
|
|
23
22
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from typing import Annotated
|
|
2
|
+
|
|
3
|
+
from openmarkets.core.constants import INDUSTRIES, MARKETS, SECTORS
|
|
4
|
+
|
|
5
|
+
Ticker = Annotated[
|
|
6
|
+
str,
|
|
7
|
+
"""
|
|
8
|
+
Security ticker string.
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
'AAPL', 'GOOG', 'MSFT'
|
|
12
|
+
""",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
Sector = Annotated[
|
|
16
|
+
str,
|
|
17
|
+
"""
|
|
18
|
+
Sector name.
|
|
19
|
+
Example:
|
|
20
|
+
{SECTORS}
|
|
21
|
+
""".format(SECTORS=", ".join(f"'{sec}'" for sec in SECTORS)),
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
Industry = Annotated[
|
|
25
|
+
str,
|
|
26
|
+
"""
|
|
27
|
+
Industry name.
|
|
28
|
+
Example:
|
|
29
|
+
{INDUSTRIES}
|
|
30
|
+
""".format(INDUSTRIES=", ".join(f"'{ind}'" for ind in INDUSTRIES)),
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
Market = Annotated[
|
|
34
|
+
str,
|
|
35
|
+
"""
|
|
36
|
+
Market type.
|
|
37
|
+
Example:
|
|
38
|
+
{MARKETS}
|
|
39
|
+
""".format(MARKETS=", ".join(f"'{m}'" for m in MARKETS)),
|
|
40
|
+
]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
import yfinance as yf
|
|
4
|
+
from curl_cffi.requests import Session
|
|
5
|
+
|
|
6
|
+
from openmarkets.schemas.analysis import (
|
|
7
|
+
AnalystPriceTargets,
|
|
8
|
+
AnalystRecommendation,
|
|
9
|
+
AnalystRecommendationChange,
|
|
10
|
+
EarningsEstimate,
|
|
11
|
+
EPSTrend,
|
|
12
|
+
GrowthEstimates,
|
|
13
|
+
RevenueEstimate,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class IAnalysisRepository(ABC):
|
|
18
|
+
"""Repository interface for analysis data access."""
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def get_analyst_recommendations(self, ticker: str, session: Session | None = None) -> list[AnalystRecommendation]:
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
@abstractmethod
|
|
25
|
+
def get_recommendation_changes(
|
|
26
|
+
self, ticker: str, session: Session | None = None
|
|
27
|
+
) -> list[AnalystRecommendationChange]:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def get_revenue_estimates(self, ticker: str, session: Session | None = None) -> list[RevenueEstimate]:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def get_earnings_estimates(self, ticker: str, session: Session | None = None) -> list[EarningsEstimate]:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def get_growth_estimates(self, ticker: str, session: Session | None = None) -> list[GrowthEstimates]:
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def get_eps_trends(self, ticker: str, session: Session | None = None) -> list[EPSTrend]:
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
def get_price_targets(self, ticker: str, session: Session | None = None) -> AnalystPriceTargets:
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class YFinanceAnalysisRepository(IAnalysisRepository):
|
|
52
|
+
"""YFinance implementation of IAnalysisRepository."""
|
|
53
|
+
|
|
54
|
+
def get_analyst_recommendations(self, ticker: str, session: Session | None = None) -> list[AnalystRecommendation]:
|
|
55
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
56
|
+
data = getattr(yf_ticker, "recommendations_summary", None)
|
|
57
|
+
if data is None or getattr(data, "empty", True):
|
|
58
|
+
return []
|
|
59
|
+
# Assume DataFrame with columns matching AnalystRecommendation
|
|
60
|
+
return [AnalystRecommendation(**rec) for rec in data.to_dict("records")]
|
|
61
|
+
|
|
62
|
+
def get_recommendation_changes(
|
|
63
|
+
self, ticker: str, session: Session | None = None
|
|
64
|
+
) -> list[AnalystRecommendationChange]:
|
|
65
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
66
|
+
data = getattr(yf_ticker, "upgrades_downgrades", None)
|
|
67
|
+
if data is None or getattr(data, "empty", True):
|
|
68
|
+
return []
|
|
69
|
+
return [AnalystRecommendationChange(**rec) for rec in data.to_dict("records")]
|
|
70
|
+
|
|
71
|
+
def get_revenue_estimates(self, ticker: str, session: Session | None = None) -> list[RevenueEstimate]:
|
|
72
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
73
|
+
data = getattr(yf_ticker, "revenue_estimate", None)
|
|
74
|
+
if data is None or getattr(data, "empty", True):
|
|
75
|
+
return []
|
|
76
|
+
return [RevenueEstimate(**rec) for rec in data.to_dict("records")]
|
|
77
|
+
|
|
78
|
+
def get_earnings_estimates(self, ticker: str, session: Session | None = None) -> list[EarningsEstimate]:
|
|
79
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
80
|
+
data = getattr(yf_ticker, "earnings_estimate", None)
|
|
81
|
+
if data is None or getattr(data, "empty", True):
|
|
82
|
+
return []
|
|
83
|
+
return [EarningsEstimate(**rec) for rec in data.to_dict("records")]
|
|
84
|
+
|
|
85
|
+
def get_growth_estimates(self, ticker: str, session: Session | None = None) -> list[GrowthEstimates]:
|
|
86
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
87
|
+
data = getattr(yf_ticker, "growth_estimates", None)
|
|
88
|
+
if data is None or getattr(data, "empty", True):
|
|
89
|
+
return []
|
|
90
|
+
return [GrowthEstimates(**rec) for rec in data.to_dict("records")]
|
|
91
|
+
|
|
92
|
+
def get_eps_trends(self, ticker: str, session: Session | None = None) -> list[EPSTrend]:
|
|
93
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
94
|
+
data = getattr(yf_ticker, "eps_trend", None)
|
|
95
|
+
if data is None or getattr(data, "empty", True):
|
|
96
|
+
return []
|
|
97
|
+
return [EPSTrend(**rec) for rec in data.to_dict("records")]
|
|
98
|
+
|
|
99
|
+
def get_price_targets(self, ticker: str, session: Session | None = None) -> AnalystPriceTargets:
|
|
100
|
+
yf_ticker = yf.Ticker(ticker, session=session)
|
|
101
|
+
data = getattr(yf_ticker, "analyst_price_target", None)
|
|
102
|
+
if not data or not isinstance(data, dict):
|
|
103
|
+
# Provide default values for all required fields
|
|
104
|
+
return AnalystPriceTargets(current=None, high=None, low=None, mean=None, median=None)
|
|
105
|
+
return AnalystPriceTargets(**data)
|