openmarkets 0.1.0.dev117__tar.gz → 0.1.0.dev119__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.
Files changed (134) hide show
  1. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/PKG-INFO +28 -25
  2. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/README.md +3 -3
  3. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/pyproject.toml +31 -35
  4. openmarkets-0.1.0.dev119/src/openmarkets/__init__.py +8 -0
  5. openmarkets-0.1.0.dev119/src/openmarkets/__main__.py +13 -0
  6. openmarkets-0.1.0.dev119/src/openmarkets/core/__init__.py +8 -0
  7. openmarkets-0.1.0.dev119/src/openmarkets/core/config.py +90 -0
  8. openmarkets-0.1.0.dev119/src/openmarkets/core/exceptions.py +22 -0
  9. openmarkets-0.1.0.dev119/src/openmarkets/core/fastmcp.py +79 -0
  10. openmarkets-0.1.0.dev119/src/openmarkets/core/serializers.py +52 -0
  11. openmarkets-0.1.0.dev119/src/openmarkets/core/server.py +87 -0
  12. openmarkets-0.1.0.dev119/src/openmarkets/core/toolset.py +120 -0
  13. openmarkets-0.1.0.dev119/src/openmarkets/core/types.py +11 -0
  14. openmarkets-0.1.0.dev119/src/openmarkets/schemas/analysis.py +104 -0
  15. openmarkets-0.1.0.dev119/src/openmarkets/schemas/company.py +15 -0
  16. openmarkets-0.1.0.dev119/src/openmarkets/schemas/financials.py +457 -0
  17. openmarkets-0.1.0.dev119/src/openmarkets/schemas/funds.py +197 -0
  18. openmarkets-0.1.0.dev119/src/openmarkets/schemas/holdings.py +122 -0
  19. openmarkets-0.1.0.dev119/src/openmarkets/schemas/markets.py +73 -0
  20. openmarkets-0.1.0.dev119/src/openmarkets/schemas/options.py +161 -0
  21. openmarkets-0.1.0.dev119/src/openmarkets/schemas/sector_industry.py +334 -0
  22. openmarkets-0.1.0.dev119/src/openmarkets/schemas/stock.py +358 -0
  23. openmarkets-0.1.0.dev119/src/openmarkets/schemas/technical_analysis.py +34 -0
  24. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/analysis.py +114 -0
  25. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/financials.py +111 -0
  26. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/funds.py +149 -0
  27. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/holdings.py +82 -0
  28. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/markets.py +31 -0
  29. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/options.py +201 -0
  30. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/sector_industry.py +195 -0
  31. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/stock.py +204 -0
  32. openmarkets-0.1.0.dev119/src/openmarkets/services/yfinance/technical_analysis.py +128 -0
  33. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/__init__.py +0 -3
  34. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/analyst_data.py +2 -2
  35. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/calendar.py +13 -5
  36. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/corporate_actions.py +16 -12
  37. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/crypto.py +3 -4
  38. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/extended_market.py +5 -6
  39. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/financial_statements.py +2 -2
  40. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/funds.py +12 -5
  41. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/historical_data.py +2 -2
  42. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/market_data.py +3 -4
  43. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/news.py +24 -5
  44. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/options.py +6 -7
  45. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/screener.py +10 -11
  46. openmarkets-0.1.0.dev119/src/openmarkets/tools/stock_info.py +273 -0
  47. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/tools/technical_analysis.py +2 -2
  48. openmarkets-0.1.0.dev117/.editorconfig +0 -36
  49. openmarkets-0.1.0.dev117/.gemini/config.yaml +0 -10
  50. openmarkets-0.1.0.dev117/.git-blame-ignore-revs +0 -0
  51. openmarkets-0.1.0.dev117/.gitattributes +0 -1
  52. openmarkets-0.1.0.dev117/.github/CODEOWNERS +0 -1
  53. openmarkets-0.1.0.dev117/.github/workflows/mirror.yaml +0 -14
  54. openmarkets-0.1.0.dev117/.gitignore +0 -309
  55. openmarkets-0.1.0.dev117/.pre-commit-config.yaml +0 -44
  56. openmarkets-0.1.0.dev117/.python-version +0 -1
  57. openmarkets-0.1.0.dev117/.vscode/mcp.json +0 -13
  58. openmarkets-0.1.0.dev117/80f5e8f644e3f9.gif +0 -0
  59. openmarkets-0.1.0.dev117/CITATION.cff +0 -14
  60. openmarkets-0.1.0.dev117/LICENSE +0 -661
  61. openmarkets-0.1.0.dev117/docs/80f5e8f644e3f9.gif +0 -0
  62. openmarkets-0.1.0.dev117/docs/CNAME +0 -1
  63. openmarkets-0.1.0.dev117/docs/index.md +0 -185
  64. openmarkets-0.1.0.dev117/mkdocs.yml +0 -118
  65. openmarkets-0.1.0.dev117/other/mcp-server-yfinance/README.md +0 -215
  66. openmarkets-0.1.0.dev117/other/mcp-server-yfinance/mcp_server_yfinance/__main__.py +0 -3
  67. openmarkets-0.1.0.dev117/other/mcp-server-yfinance/pyproject.toml +0 -57
  68. openmarkets-0.1.0.dev117/other/mkt/README.md +0 -215
  69. openmarkets-0.1.0.dev117/other/mkt/mkt/__main__.py +0 -3
  70. openmarkets-0.1.0.dev117/other/mkt/pyproject.toml +0 -57
  71. openmarkets-0.1.0.dev117/pyrightconfig.json +0 -15
  72. openmarkets-0.1.0.dev117/src/openmarkets/__init__.py +0 -5
  73. openmarkets-0.1.0.dev117/src/openmarkets/__main__.py +0 -26
  74. openmarkets-0.1.0.dev117/src/openmarkets/_version.py +0 -21
  75. openmarkets-0.1.0.dev117/src/openmarkets/core/__init__.py +0 -5
  76. openmarkets-0.1.0.dev117/src/openmarkets/core/exceptions.py +0 -16
  77. openmarkets-0.1.0.dev117/src/openmarkets/core/models.py +0 -17
  78. openmarkets-0.1.0.dev117/src/openmarkets/core/registry.py +0 -72
  79. openmarkets-0.1.0.dev117/src/openmarkets/core/serializers.py +0 -34
  80. openmarkets-0.1.0.dev117/src/openmarkets/core/server.py +0 -39
  81. openmarkets-0.1.0.dev117/src/openmarkets/core/utils.py +0 -38
  82. openmarkets-0.1.0.dev117/src/openmarkets/services/__init__.py +0 -1
  83. openmarkets-0.1.0.dev117/src/openmarkets/tools/stock_info.py +0 -138
  84. openmarkets-0.1.0.dev117/tests/core/test_exceptions.py +0 -44
  85. openmarkets-0.1.0.dev117/tests/core/test_models.py +0 -118
  86. openmarkets-0.1.0.dev117/tests/core/test_registry.py +0 -285
  87. openmarkets-0.1.0.dev117/tests/core/test_serializers.py +0 -99
  88. openmarkets-0.1.0.dev117/tests/core/test_server.py +0 -129
  89. openmarkets-0.1.0.dev117/tests/core/test_utils.py +0 -55
  90. openmarkets-0.1.0.dev117/tests/tools/test_analyst_data.py +0 -85
  91. openmarkets-0.1.0.dev117/tests/tools/test_calendar.py +0 -104
  92. openmarkets-0.1.0.dev117/tests/tools/test_corporate_actions.py +0 -309
  93. openmarkets-0.1.0.dev117/tests/tools/test_crypto.py +0 -319
  94. openmarkets-0.1.0.dev117/tests/tools/test_extended_market.py +0 -285
  95. openmarkets-0.1.0.dev117/tests/tools/test_financial_statements.py +0 -448
  96. openmarkets-0.1.0.dev117/tests/tools/test_funds.py +0 -291
  97. openmarkets-0.1.0.dev117/tests/tools/test_funds_2.py +0 -148
  98. openmarkets-0.1.0.dev117/tests/tools/test_historical_data.py +0 -283
  99. openmarkets-0.1.0.dev117/tests/tools/test_market_data.py +0 -96
  100. openmarkets-0.1.0.dev117/tests/tools/test_options.py +0 -363
  101. openmarkets-0.1.0.dev117/tests/tools/test_stock_info.py +0 -186
  102. openmarkets-0.1.0.dev117/typings/yfinance/__init__.pyi +0 -38
  103. openmarkets-0.1.0.dev117/typings/yfinance/base.pyi +0 -69
  104. openmarkets-0.1.0.dev117/typings/yfinance/cache.pyi +0 -141
  105. openmarkets-0.1.0.dev117/typings/yfinance/const.pyi +0 -15
  106. openmarkets-0.1.0.dev117/typings/yfinance/data.pyi +0 -23
  107. openmarkets-0.1.0.dev117/typings/yfinance/domain/__init__.pyi +0 -4
  108. openmarkets-0.1.0.dev117/typings/yfinance/domain/domain.pyi +0 -26
  109. openmarkets-0.1.0.dev117/typings/yfinance/domain/industry.pyi +0 -17
  110. openmarkets-0.1.0.dev117/typings/yfinance/domain/market.pyi +0 -14
  111. openmarkets-0.1.0.dev117/typings/yfinance/domain/sector.pyi +0 -24
  112. openmarkets-0.1.0.dev117/typings/yfinance/exceptions.pyi +0 -33
  113. openmarkets-0.1.0.dev117/typings/yfinance/live.pyi +0 -35
  114. openmarkets-0.1.0.dev117/typings/yfinance/lookup.pyi +0 -41
  115. openmarkets-0.1.0.dev117/typings/yfinance/multi.pyi +0 -31
  116. openmarkets-0.1.0.dev117/typings/yfinance/pricing_pb2.pyi +0 -4
  117. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/__init__.pyi +0 -0
  118. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/analysis.pyi +0 -22
  119. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/fundamentals.pyi +0 -21
  120. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/funds.pyi +0 -26
  121. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/history.pyi +0 -45
  122. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/holders.pyi +0 -19
  123. openmarkets-0.1.0.dev117/typings/yfinance/scrapers/quote.pyi +0 -83
  124. openmarkets-0.1.0.dev117/typings/yfinance/screener/__init__.pyi +0 -8
  125. openmarkets-0.1.0.dev117/typings/yfinance/screener/query.pyi +0 -54
  126. openmarkets-0.1.0.dev117/typings/yfinance/screener/screener.pyi +0 -28
  127. openmarkets-0.1.0.dev117/typings/yfinance/search.pyi +0 -51
  128. openmarkets-0.1.0.dev117/typings/yfinance/shared.pyi +0 -0
  129. openmarkets-0.1.0.dev117/typings/yfinance/ticker.pyi +0 -115
  130. openmarkets-0.1.0.dev117/typings/yfinance/tickers.pyi +0 -48
  131. openmarkets-0.1.0.dev117/typings/yfinance/utils.pyi +0 -82
  132. openmarkets-0.1.0.dev117/typings/yfinance/version.pyi +0 -1
  133. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/py.typed +0 -0
  134. {openmarkets-0.1.0.dev117 → openmarkets-0.1.0.dev119}/src/openmarkets/schemas/__init__.py +0 -0
@@ -1,28 +1,15 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: openmarkets
3
- Version: 0.1.0.dev117
4
- Summary: A Model Context Protocol (MCP) server for agentic retrieval of financial market data. This server leverages YFinance to provide a simple and efficient way to access historical stock prices, dividends, stock splits, company information, and other financial metrics.
5
- Project-URL: Homepage, https://openmarkets.dev
6
- Project-URL: Source, https://github.com/danchev/openmarkets
7
- Project-URL: Documentation, https://danchev.github.io/openmarkets/
8
- Project-URL: Issues, https://github.com/danchev/openmarkets/issues
9
- Author-email: Dobri Danchev <python-dist@danchev.net>
3
+ Version: 0.1.0.dev119
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
+ Keywords: machinelearning,finance,investment,mcp,modelcontextprotocol,yahoo finance,financial data retrieval
6
+ Author: Dobri Danchev
10
7
  License: AGPL-3.0-or-later
11
- License-File: LICENSE
12
- Keywords: finance,financial data retrieval,investment,machinelearning,mcp,modelcontextprotocol,yahoo finance
8
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
13
9
  Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Operating System :: OS Independent
14
11
  Classifier: Intended Audience :: Developers
15
12
  Classifier: Intended Audience :: Financial and Insurance Industry
16
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Programming Language :: Python
19
- Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3 :: Only
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
- Classifier: Programming Language :: Python :: 3.12
24
- Classifier: Programming Language :: Python :: 3.13
25
- Classifier: Programming Language :: Python :: 3.14
26
13
  Classifier: Topic :: Office/Business :: Financial
27
14
  Classifier: Topic :: Office/Business :: Financial :: Investment
28
15
  Classifier: Topic :: Scientific/Engineering
@@ -30,14 +17,30 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
30
17
  Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
31
18
  Classifier: Topic :: Software Development :: Libraries
32
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Classifier: Programming Language :: Python :: 3 :: Only
28
+ Requires-Dist: mcp[cli]>=1.21.0
29
+ Requires-Dist: yfinance>=0.2.66
30
+ Requires-Dist: fastmcp>=2.13.0 ; extra == 'fastmcp'
31
+ Requires-Dist: lxml>=6.0.2 ; extra == 'lxml'
33
32
  Requires-Python: >=3.10
34
- Requires-Dist: mcp[cli]>=1.9.4
35
- Requires-Dist: yfinance>=0.2.63
33
+ Project-URL: Documentation, https://danchev.github.io/openmarkets/
34
+ Project-URL: Homepage, https://openmarkets.dev
35
+ Project-URL: Issues, https://github.com/danchev/openmarkets/issues
36
+ Project-URL: Source, https://github.com/danchev/openmarkets
37
+ Provides-Extra: fastmcp
38
+ Provides-Extra: lxml
36
39
  Description-Content-Type: text/markdown
37
40
 
38
41
  ![PyPI](https://img.shields.io/pypi/v/openmarkets)
39
- [![PyPI - Downloads](https://static.pepy.tech/badge/openmarkets)](https://pepy.tech/project/openmarkets)
40
- ![PyPI - Monthly Downloads](https://static.pepy.tech/badge/openmarkets/month)
42
+ [![PyPI - Downloads](https://static.pepy.tech/badge/openmarkets)](https://pypi.org/project/openmarkets)
43
+ [![PyPI - Monthly Downloads](https://static.pepy.tech/badge/openmarkets/month)](https://pypi.org/project/openmarkets)
41
44
 
42
45
  # Open Markets
43
46
 
@@ -45,7 +48,7 @@ A Model Context Protocol (MCP) server for agentic retrieval of financial data fr
45
48
 
46
49
  This MCP server is designed to be used with various LLM applications that support the Model Context Protocol, such as Claude Desktop, n8n, and Cursor. It allows users to retrieve financial data in a structured way, making it easy to integrate into AI applications.
47
50
 
48
- ![MCP with OpenMarkets](80f5e8f644e3f9.gif)
51
+ ![MCP with OpenMarkets](https://r2.openmarkets.dev/80f5e8f644e3f9.gif)
49
52
 
50
53
  ## Features
51
54
 
@@ -1,6 +1,6 @@
1
1
  ![PyPI](https://img.shields.io/pypi/v/openmarkets)
2
- [![PyPI - Downloads](https://static.pepy.tech/badge/openmarkets)](https://pepy.tech/project/openmarkets)
3
- ![PyPI - Monthly Downloads](https://static.pepy.tech/badge/openmarkets/month)
2
+ [![PyPI - Downloads](https://static.pepy.tech/badge/openmarkets)](https://pypi.org/project/openmarkets)
3
+ [![PyPI - Monthly Downloads](https://static.pepy.tech/badge/openmarkets/month)](https://pypi.org/project/openmarkets)
4
4
 
5
5
  # Open Markets
6
6
 
@@ -8,7 +8,7 @@ A Model Context Protocol (MCP) server for agentic retrieval of financial data fr
8
8
 
9
9
  This MCP server is designed to be used with various LLM applications that support the Model Context Protocol, such as Claude Desktop, n8n, and Cursor. It allows users to retrieve financial data in a structured way, making it easy to integrate into AI applications.
10
10
 
11
- ![MCP with OpenMarkets](80f5e8f644e3f9.gif)
11
+ ![MCP with OpenMarkets](https://r2.openmarkets.dev/80f5e8f644e3f9.gif)
12
12
 
13
13
  ## Features
14
14
 
@@ -1,8 +1,8 @@
1
1
  [project]
2
2
  name = "openmarkets"
3
- dynamic = ["version"]
4
- description = "A Model Context Protocol (MCP) server for agentic retrieval of financial market data. This server leverages YFinance to provide a simple and efficient way to access historical stock prices, dividends, stock splits, company information, and other financial metrics."
5
- authors = [{ name = "Dobri Danchev", email = "python-dist@danchev.net" }]
3
+ version = "0.1.0.dev119"
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
+ authors = [{ name = "Dobri Danchev" }]
6
6
  classifiers = [
7
7
  "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
8
8
  "Development Status :: 3 - Alpha",
@@ -38,9 +38,10 @@ 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.9.4",
42
- "yfinance>=0.2.63", # Licensed under Apache-2.0
41
+ "mcp[cli]>=1.21.0",
42
+ "yfinance>=0.2.66",
43
43
  ]
44
+ optional-dependencies = {"fastmcp" = ["fastmcp>=2.13.0",], "lxml" = ["lxml>=6.0.2",]}
44
45
 
45
46
  [project.urls]
46
47
  Homepage = "https://openmarkets.dev"
@@ -53,48 +54,34 @@ openmarkets = "openmarkets.core.server:main"
53
54
  mcp-server-yfinance = "openmarkets.core.server:main"
54
55
 
55
56
  [build-system]
56
- requires = ["hatchling", "hatch-vcs"]
57
- build-backend = "hatchling.build"
58
-
59
- [tool.hatch.build.targets.wheel]
60
- packages = ["src/openmarkets"]
61
-
62
- [tool.hatch.build.hooks.vcs]
63
- version-file = "src/openmarkets/_version.py"
64
-
65
- [tool.hatch.envs.default]
66
- installer = "uv"
67
-
68
- [tool.hatch.version]
69
- source = "vcs"
70
- raw-options.version_scheme = "release-branch-semver" # "calver-by-date"
71
- raw-options.local_scheme = "no-local-version"
72
- raw-options.fallback_version = "0.0.0"
57
+ requires = ["uv_build>=0.9.9,<0.10.0"]
58
+ build-backend = "uv_build"
73
59
 
74
60
  [dependency-groups]
75
61
  dev = [
76
- "pyright>=1.1.402",
77
- "refurb>=2.1.0",
78
- "ruff>=0.12.0",
79
- "ty>=0.0.1a11",
62
+ "debugpy>=1.8.17",
63
+ "pyright>=1.1.407",
64
+ "refurb>=2.2.0",
65
+ "ruff>=0.14.4",
66
+ "ty>=0.0.1a26",
80
67
  {include-group = "test"},
81
68
  {include-group = "commit"},
82
69
  ]
83
70
  test = [
84
- "pytest>=8.4.1",
85
- "pytest-cov>=6.2.1",
86
- "pytest-xdist>=3.7.0",
87
- "pytest-asyncio>= 1.0.0",
71
+ "pytest>=9.0.1",
72
+ "pytest-cov>=7.0.0",
73
+ "pytest-xdist>=3.8.0",
74
+ "pytest-asyncio>=1.3.0",
88
75
  ]
89
76
  docs = [
90
77
  "mkdocs>=1.6.1",
91
- "mkdocs-glightbox>=0.4.0",
92
- "mkdocs-material[imaging]>=9.6.14",
93
- "mkdocstrings-python>=1.16.12",
78
+ "mkdocs-glightbox>=0.5.1",
79
+ "mkdocs-material[imaging]>=9.6.22",
80
+ "mkdocstrings-python>=1.18.2",
94
81
  ]
95
82
  commit = [
96
- "commitizen>=4.8.3",
97
- "pre-commit>=4.2.0",
83
+ "commitizen>=4.10.0",
84
+ "pre-commit>=4.4.0",
98
85
  ]
99
86
 
100
87
  [tool.ruff]
@@ -125,3 +112,12 @@ python_functions = "test_*"
125
112
  [tool.mypy]
126
113
  custom_typeshed_dir = "typings"
127
114
  plugins = ["mypy_ruff"]
115
+
116
+ [tool.commitizen]
117
+ name = "cz_conventional_commits"
118
+ version = "0.1.0.alpha"
119
+ tag_format = "$version"
120
+ version_files = [
121
+ "pyproject.toml:version"
122
+ ]
123
+ update_changelog_on_bump = true
@@ -0,0 +1,8 @@
1
+ try:
2
+ from importlib.metadata import version
3
+
4
+ __version__ = version("openmarkets")
5
+ except Exception:
6
+ __version__ = "unknown"
7
+
8
+ __all__ = ["__version__"]
@@ -0,0 +1,13 @@
1
+ # Application entry point (starts the server)
2
+
3
+ import logging
4
+ import sys
5
+
6
+ from openmarkets.core.server import main
7
+
8
+ logging.basicConfig(
9
+ level=logging.INFO, stream=sys.stdout, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
10
+ )
11
+
12
+ if __name__ == "__main__":
13
+ main()
@@ -0,0 +1,8 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ try:
4
+ __version__: str = version("openmarkets")
5
+ except PackageNotFoundError:
6
+ __version__ = "unknown"
7
+
8
+ __all__ = ["__version__"]
@@ -0,0 +1,90 @@
1
+ from functools import lru_cache
2
+
3
+ from pydantic import Field
4
+ from pydantic_settings import BaseSettings, CliSettingsSource, PydanticBaseSettingsSource, SettingsConfigDict
5
+
6
+
7
+ class Settings(BaseSettings):
8
+ """Application configuration settings.
9
+
10
+ This class defines the configuration options for the Open Markets Server.
11
+ Settings can be loaded from environment variables, .env files, or CLI arguments.
12
+ """
13
+
14
+ name: str = Field(
15
+ "Open Markets Server",
16
+ description="The name of the application/server.",
17
+ )
18
+ environment: str = Field(
19
+ "development",
20
+ description="The environment in which the server is running (e.g., development, production).",
21
+ )
22
+ transport: str = Field(
23
+ "stdio",
24
+ description="The transport protocol to use (e.g., stdio, http, etc.).",
25
+ )
26
+ host: str = Field(
27
+ "127.0.0.1",
28
+ description="The host address for the server.",
29
+ )
30
+ port: int = Field(
31
+ 8000,
32
+ description="The port number for the server.",
33
+ )
34
+ debug: bool = Field(
35
+ False,
36
+ description="Enable or disable debug mode.",
37
+ )
38
+ timeout: float = Field(
39
+ 5.0,
40
+ description="Default timeout (in seconds) for server operations.",
41
+ )
42
+ cors_allow_origins: str = Field(
43
+ "*",
44
+ description="Allowed origins for CORS (Cross-Origin Resource Sharing).",
45
+ )
46
+ toolset: str = Field(
47
+ "openmarkets.tools",
48
+ description="The Python module path for the toolset to use.",
49
+ )
50
+
51
+ model_config = SettingsConfigDict(env_file=".env")
52
+
53
+ @classmethod
54
+ def settings_customise_sources(
55
+ cls,
56
+ settings_cls: type[BaseSettings],
57
+ init_settings: PydanticBaseSettingsSource,
58
+ env_settings: PydanticBaseSettingsSource,
59
+ dotenv_settings: PydanticBaseSettingsSource,
60
+ file_secret_settings: PydanticBaseSettingsSource,
61
+ ) -> tuple[PydanticBaseSettingsSource, ...]:
62
+ """Customize the order of settings sources.
63
+
64
+ Args:
65
+ settings_cls: The settings class.
66
+ init_settings: Settings from __init__ arguments.
67
+ env_settings: Settings from environment variables.
68
+ dotenv_settings: Settings from .env files.
69
+ file_secret_settings: Settings from secret files.
70
+
71
+ Returns:
72
+ A tuple of settings sources in the desired order.
73
+ """
74
+ return (
75
+ init_settings,
76
+ CliSettingsSource(settings_cls, cli_parse_args=True, cli_ignore_unknown_args=True),
77
+ env_settings,
78
+ dotenv_settings,
79
+ file_secret_settings,
80
+ )
81
+
82
+
83
+ @lru_cache
84
+ def get_settings() -> Settings:
85
+ """Get a cached instance of the application settings.
86
+
87
+ Returns:
88
+ Settings: The application settings instance.
89
+ """
90
+ return Settings() # type: ignore
@@ -0,0 +1,22 @@
1
+ class OpenMarketsException(Exception):
2
+ """
3
+ Base class for all custom exceptions in OpenMarkets.
4
+ """
5
+
6
+ pass
7
+
8
+
9
+ class APIError(OpenMarketsException):
10
+ """
11
+ Exception raised for API related errors.
12
+ """
13
+
14
+ pass
15
+
16
+
17
+ class InvalidSymbolError(OpenMarketsException):
18
+ """
19
+ Exception raised for invalid symbols.
20
+ """
21
+
22
+ pass
@@ -0,0 +1,79 @@
1
+ import logging
2
+
3
+ try:
4
+ from fastmcp import FastMCP
5
+ except ImportError:
6
+ from mcp.server.fastmcp import FastMCP
7
+
8
+ from starlette.applications import Starlette
9
+ from starlette.middleware.cors import CORSMiddleware
10
+
11
+ from openmarkets.core.config import Settings
12
+ from openmarkets.core.toolset import register_toolset
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+
17
+ class FastMCPWithCORS(FastMCP):
18
+ def streamable_http_app(self) -> Starlette:
19
+ """Return StreamableHTTP server app with CORS middleware"""
20
+ # Get the original Starlette app
21
+ app = super().streamable_http_app()
22
+
23
+ # Add CORS middleware
24
+ app.add_middleware(
25
+ CORSMiddleware,
26
+ allow_origins=["*"], # In production, should set specific domains
27
+ allow_credentials=True,
28
+ allow_methods=["*"],
29
+ allow_headers=["*"],
30
+ )
31
+
32
+ return app
33
+
34
+ def sse_app(self, mount_path: str | None = None) -> Starlette:
35
+ """Return SSE server app with CORS middleware"""
36
+ # Get the original Starlette app
37
+ app = super().sse_app(mount_path)
38
+
39
+ # Add CORS middleware
40
+ app.add_middleware(
41
+ CORSMiddleware,
42
+ allow_origins=["*"], # In production, should set specific domains
43
+ allow_credentials=True,
44
+ allow_methods=["*"],
45
+ allow_headers=["*"],
46
+ )
47
+
48
+ return app
49
+
50
+
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.
57
+
58
+ Args:
59
+ config (Settings): Configuration object containing tool module reference.
60
+
61
+ Returns:
62
+ FastMCP: Configured MCP server instance.
63
+
64
+ Raises:
65
+ RuntimeError: If tool registration fails.
66
+ """
67
+ mcp = FastMCP(
68
+ name="Open Markets Server",
69
+ instructions=("This server allows for the integration of various market data tools."),
70
+ )
71
+
72
+ try:
73
+ register_toolset(mcp, config.toolset)
74
+ logger.info("Tool registration completed successfully.")
75
+ except Exception as exc:
76
+ logger.exception("Failed to initialize ToolRegistry or register tools.")
77
+ raise RuntimeError("Tool registration failed. See logs for details.") from exc
78
+
79
+ return mcp
@@ -0,0 +1,52 @@
1
+ import json
2
+
3
+ import numpy as np
4
+ import pandas as pd
5
+
6
+
7
+ class JSONSerializer(json.JSONEncoder):
8
+ """
9
+ Custom JSON encoder for pandas and numpy objects.
10
+
11
+ Handles:
12
+ - pandas.Timestamp (as ISO string)
13
+ - numpy integer/floating types
14
+ - numpy.ndarray, pandas.Series, pandas.DataFrame
15
+ - NaN and None values
16
+ """
17
+
18
+ def default(self, o: object) -> object:
19
+ if isinstance(o, pd.Timestamp):
20
+ return o.isoformat()
21
+ if isinstance(o, np.integer):
22
+ return int(o)
23
+ if isinstance(o, np.floating):
24
+ return float(o)
25
+ if isinstance(o, (np.ndarray, pd.Series)):
26
+ return o.tolist()
27
+ if isinstance(o, pd.DataFrame):
28
+ return o.to_dict(orient="records")
29
+ if o is None or (isinstance(o, float) and np.isnan(o)):
30
+ return None
31
+ return super().default(o)
32
+
33
+
34
+ def safe_json_dumps(data: object, indent: int | None = None) -> str:
35
+ """
36
+ Serialize data to a JSON string, converting pandas/numpy objects to JSON serializable types.
37
+
38
+ Args:
39
+ data (object): The data to serialize.
40
+ indent (Optional[int], optional): If not None, pretty-print with this indent level.
41
+
42
+ Returns:
43
+ str: JSON string.
44
+
45
+ Raises:
46
+ TypeError: If the data cannot be serialized.
47
+ """
48
+ try:
49
+ return json.dumps(data, cls=JSONSerializer, indent=indent)
50
+ except TypeError as exc:
51
+ # Log or handle serialization errors as needed
52
+ raise TypeError(f"Failed to serialize data: {exc}") from exc
@@ -0,0 +1,87 @@
1
+ """
2
+ Open Markets Server
3
+
4
+ Initializes and runs the Open Markets MCP server, handling tool registration
5
+ and server lifecycle management.
6
+ Follows Google Python Style Guide for documentation and formatting.
7
+ """
8
+
9
+ import logging
10
+ import sys
11
+
12
+ import uvicorn
13
+ from starlette.middleware.cors import CORSMiddleware
14
+
15
+ from openmarkets.core.config import Settings, get_settings
16
+ from openmarkets.core.fastmcp import FastMCP, create_mcp
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+ settings = get_settings()
21
+ mcp: FastMCP = create_mcp(settings)
22
+
23
+
24
+ def run_stdio_server(mcp: FastMCP) -> None:
25
+ """
26
+ Runs the MCP server using stdio transport.
27
+
28
+ Args:
29
+ mcp: FastMCP server instance.
30
+
31
+ Raises:
32
+ Exception: If the server encounters an error during runtime.
33
+ """
34
+ try:
35
+ mcp.run()
36
+ except Exception as exc:
37
+ logger.exception("Server encountered an error during stdio runtime.")
38
+ raise exc
39
+
40
+
41
+ def run_http_server(mcp: FastMCP, settings: Settings) -> None:
42
+ """
43
+ Runs the MCP server using HTTP transport.
44
+
45
+ Args:
46
+ mcp: FastMCP server instance.
47
+ settings: Server settings/configuration.
48
+
49
+ Raises:
50
+ Exception: If the server encounters an error during runtime.
51
+ """
52
+ try:
53
+ app = mcp.streamable_http_app()
54
+ app.add_middleware(
55
+ CORSMiddleware,
56
+ allow_origins=settings.cors_allow_origins.split(","),
57
+ allow_credentials=True,
58
+ allow_methods=["*"],
59
+ allow_headers=["*"],
60
+ )
61
+ uvicorn.run(app, host=settings.host, port=settings.port)
62
+ except KeyboardInterrupt:
63
+ logger.info(msg="Server shutdown requested by user.")
64
+ sys.exit(0)
65
+ except Exception:
66
+ logger.exception("Server encountered an error during HTTP runtime.")
67
+ sys.exit(1)
68
+
69
+
70
+ def main() -> None:
71
+ """
72
+ Orchestrates the startup of the Open Markets MCP server based on transport type.
73
+
74
+ Returns:
75
+ None
76
+ """
77
+ if settings.transport == "stdio":
78
+ run_stdio_server(mcp)
79
+ elif settings.transport == "http":
80
+ run_http_server(mcp, settings)
81
+ else:
82
+ logger.error(f"Unsupported transport type: {settings.transport}")
83
+ sys.exit(2)
84
+
85
+
86
+ if __name__ == "__main__":
87
+ main()