sharkquant-mcp 0.6.3__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.
@@ -0,0 +1,203 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [quantdinger.com] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: sharkquant-mcp
3
+ Version: 0.6.3
4
+ Summary: Full-surface Model Context Protocol server for SharkQuant research, strategy authoring, backtests, observations, notifications, and safety-gated trading.
5
+ Author-email: SharkQuant <support@sharkv2.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/guofeng201507/sharkquant
8
+ Project-URL: Documentation, https://github.com/guofeng201507/sharkquant/blob/main/docs/agent/AGENT_QUICKSTART.md
9
+ Project-URL: Repository, https://github.com/guofeng201507/sharkquant
10
+ Project-URL: Issues, https://github.com/guofeng201507/sharkquant/issues
11
+ Project-URL: Changelog, https://github.com/guofeng201507/sharkquant/blob/main/mcp_server/RELEASE.md
12
+ Keywords: mcp,model-context-protocol,sharkquant,ai-agent,trading,backtest,quant,cursor,claude,codex,openclaw,nanobot
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Office/Business :: Financial :: Investment
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: mcp<1.29,>=1.28.1
28
+ Requires-Dist: httpx<0.29,>=0.27.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7; extra == "dev"
31
+ Requires-Dist: build>=1.0; extra == "dev"
32
+ Requires-Dist: twine>=4; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # SharkQuant MCP Server
36
+
37
+ The MCP server is a thin, tenant-scoped wrapper over `/api/agent/v1`. It exposes research universes and factors, market data, chart-indicator authoring, Strategy API V2 deployment and backtesting, broker/execution observations, notification automation, bounded jobs, and safety-gated trading.
38
+
39
+ ## Install and run
40
+
41
+ ```bash
42
+ pip install "sharkquant-mcp==0.6.3"
43
+ export QUANTDINGER_BASE_URL=http://localhost:5000
44
+ export QUANTDINGER_AGENT_TOKEN=qd_agent_xxx
45
+ sharkquant-mcp
46
+ ```
47
+
48
+ `pipx install sharkquant-mcp` and `uvx sharkquant-mcp` are also supported. Use `pip install -e ./mcp_server` only when developing from a repository checkout.
49
+
50
+ Legacy compatibility: this package still provides the `quantdinger-mcp` console command and the `quantdinger_mcp` import alias. The old PyPI project `quantdinger-mcp` remains at 0.6.2; new installs should use `sharkquant-mcp`.
51
+
52
+ The default transport is `stdio`. Set `QUANTDINGER_MCP_TRANSPORT` to `sse` or `streamable-http` for a network transport. Optional limits include `QUANTDINGER_TIMEOUT_S`, `QUANTDINGER_MCP_JOB_STREAM_MAX_EVENTS`, `QUANTDINGER_MCP_JOB_STREAM_MAX_SECONDS`, and `QUANTDINGER_MCP_JOB_POLL_MAX_SECONDS`.
53
+
54
+ Network transports bound to a non-loopback host require a separate inbound bearer token. This token authenticates MCP clients and must not be the Agent Gateway token:
55
+
56
+ ```bash
57
+ export QUANTDINGER_MCP_TRANSPORT=streamable-http
58
+ export QUANTDINGER_MCP_HOST=0.0.0.0
59
+ export QUANTDINGER_MCP_PORT=7800
60
+ export QUANTDINGER_MCP_PUBLIC_URL=https://mcp.example.com
61
+ export QUANTDINGER_MCP_AUTH_TOKEN=replace-with-a-random-32-plus-character-secret
62
+ sharkquant-mcp
63
+ ```
64
+
65
+ Clients must send `Authorization: Bearer <QUANTDINGER_MCP_AUTH_TOKEN>` to `/mcp` or `/sse`. Authenticated non-loopback listeners require an HTTPS `QUANTDINGER_MCP_PUBLIC_URL`. `QUANTDINGER_MCP_ALLOW_HTTP=true` is only for a trusted private proxy that terminates TLS. For an unauthenticated private ingress that already authenticates every request, `QUANTDINGER_MCP_ALLOW_INSECURE_HTTP=true` remains a separate escape hatch; never use either setting on a directly reachable public listener.
66
+
67
+ Docker builds use the official PyPI index by default. In regions where it is slow, override it without editing the image definition: `docker build --build-arg PIP_INDEX_URL=https://your-mirror.example/simple .`.
68
+
69
+ Never place an agent token in prompts, logs, screenshots, source control, or MCP configuration that will be shared. Responses redact credential fields, and clients must not attempt to recover them.
70
+
71
+ ## Tool surface
72
+
73
+ | Tool group | Scope | Purpose |
74
+ |---|---:|---|
75
+ | `whoami`, `check_health` | R/public | Identity, allowlists, and liveness |
76
+ | `list_markets`, `search_symbols`, `get_klines`, `get_price` | R | Market discovery and data |
77
+ | Universe and factor tools, `get_macro_liquidity` | R | Point-in-time research inputs and compact USD liquidity regime (no chart history) |
78
+ | `list_watchlist`, `add_watchlist`, `remove_watchlist` | R/W | Watchlist workspace |
79
+ | Indicator authoring, validation, save, link, and read tools | R/W | Chart-only indicators |
80
+ | `list_strategy_templates` | R | Strategy API V2 system templates |
81
+ | `compile_strategy_code` | W | Compile Strategy API V2 code to its canonical manifest |
82
+ | `list_strategy_sources`, `get_strategy_source`, `save_strategy_source` | R/W | Private Strategy API V2 source library |
83
+ | `list_strategy_source_versions`, `restore_strategy_source_version` | R/W | Source history and explicitly confirmed restore |
84
+ | `create_strategy`, `update_strategy`, `list_strategies`, `get_strategy` | R/W | Strategy API V2 deployments |
85
+ | `submit_backtest` | B | Strategy API V2 backtest job |
86
+ | `list_jobs`, `get_job`, `wait_for_job`, `stream_job_until_done`, `cancel_job` | R/B | Bounded jobs and confirmed cancellation |
87
+ | `runtime_overview`, `stop_strategy` | R/T | Runtime inspection and confirmed stop |
88
+ | Broker account, strategy position/trade, and quick-trade observation tools | R | Secret-free execution observations |
89
+ | Signal-alert tools | N | Notification task lifecycle and confirmed delivery evaluation |
90
+ | `place_quick_order` | T | Confirmed order with token notional caps |
91
+ | `list_portfolio_positions`, `list_paper_orders` | R | Portfolio and paper-order reads |
92
+ | `emergency_stop_trading`, `cancel_open_paper_orders` | T | Emergency cancellation and T-token revocation |
93
+
94
+ Every mutating W/B/N/T tool requires a caller-generated `idempotency_key`; retries of the same request must reuse it. `stop_strategy` requires `confirm_stop=true`. `place_quick_order` requires `confirm_order=true`; a live-capable token also requires `confirm_live_trading=true`. Optional `tp_price` and `sl_price` protection are forwarded to the shared Quick Trade execution path. Server-side trading flags, allowlists, and per-order/per-day notional caps still apply.
95
+
96
+ ## Strategy API V2 workflow
97
+
98
+ Executable strategy code must define `initialize(context)` and declare its universe and subscriptions. It must provide `handle_data`, `on_rebalance`, or a scheduled callback. The manifest owns instruments, markets, frequencies, factor dependencies, warmup, and leverage policy.
99
+
100
+ Compile and save a source before creating a stopped deployment:
101
+
102
+ ```text
103
+ compile_strategy_code(code="...Strategy API V2 Python...", idempotency_key="compile-btc-momentum-v1")
104
+ save_strategy_source(name="btc-momentum", code="...Strategy API V2 Python...", idempotency_key="save-btc-momentum-v1")
105
+ ```
106
+
107
+ Use the returned source id:
108
+
109
+ ```text
110
+ create_strategy(
111
+ name="btc-momentum",
112
+ source_id=12,
113
+ initial_capital=10000,
114
+ execution_mode="signal",
115
+ params={"lookback": 40},
116
+ idempotency_key="deploy-btc-momentum-v1"
117
+ )
118
+ ```
119
+
120
+ Run a backtest directly from V2 code:
121
+
122
+ ```text
123
+ submit_backtest(
124
+ code="...Strategy API V2 Python...",
125
+ start_date="2025-01-01",
126
+ end_date="2025-12-31",
127
+ initial_capital=10000,
128
+ params={"lookback": 40},
129
+ idempotency_key="btc-momentum-2025"
130
+ )
131
+ ```
132
+
133
+ Market, symbol, and timeframe are not backtest parameters. They come from the compiled strategy manifest. Use `wait_for_job` or `stream_job_until_done` to obtain the result.
134
+
135
+ Indicators are chart-only. Validate and save them through the indicator tools, then convert the idea into Strategy API V2 code before using `submit_backtest` or `create_strategy`.
136
+
137
+ Restoring a source snapshot requires `confirm_restore=true`. The emergency stop requires confirmation, attempts to cancel agent-originated live orders, cancels paper orders, revokes every active tenant T token, and reports exchange cancellations needing human follow-up.
138
+
139
+ The optional Docker network service is enabled explicitly:
140
+
141
+ ```bash
142
+ QUANTDINGER_AGENT_TOKEN=qd_agent_xxx \
143
+ QUANTDINGER_MCP_AUTH_TOKEN="$(openssl rand -hex 32)" \
144
+ docker compose --profile mcp up -d --build mcp
145
+ ```
146
+
147
+ ## Development
148
+
149
+ ```bash
150
+ pip install -e './mcp_server[dev]'
151
+ pytest mcp_server/tests
152
+ ```
@@ -0,0 +1,118 @@
1
+ # SharkQuant MCP Server
2
+
3
+ The MCP server is a thin, tenant-scoped wrapper over `/api/agent/v1`. It exposes research universes and factors, market data, chart-indicator authoring, Strategy API V2 deployment and backtesting, broker/execution observations, notification automation, bounded jobs, and safety-gated trading.
4
+
5
+ ## Install and run
6
+
7
+ ```bash
8
+ pip install "sharkquant-mcp==0.6.3"
9
+ export QUANTDINGER_BASE_URL=http://localhost:5000
10
+ export QUANTDINGER_AGENT_TOKEN=qd_agent_xxx
11
+ sharkquant-mcp
12
+ ```
13
+
14
+ `pipx install sharkquant-mcp` and `uvx sharkquant-mcp` are also supported. Use `pip install -e ./mcp_server` only when developing from a repository checkout.
15
+
16
+ Legacy compatibility: this package still provides the `quantdinger-mcp` console command and the `quantdinger_mcp` import alias. The old PyPI project `quantdinger-mcp` remains at 0.6.2; new installs should use `sharkquant-mcp`.
17
+
18
+ The default transport is `stdio`. Set `QUANTDINGER_MCP_TRANSPORT` to `sse` or `streamable-http` for a network transport. Optional limits include `QUANTDINGER_TIMEOUT_S`, `QUANTDINGER_MCP_JOB_STREAM_MAX_EVENTS`, `QUANTDINGER_MCP_JOB_STREAM_MAX_SECONDS`, and `QUANTDINGER_MCP_JOB_POLL_MAX_SECONDS`.
19
+
20
+ Network transports bound to a non-loopback host require a separate inbound bearer token. This token authenticates MCP clients and must not be the Agent Gateway token:
21
+
22
+ ```bash
23
+ export QUANTDINGER_MCP_TRANSPORT=streamable-http
24
+ export QUANTDINGER_MCP_HOST=0.0.0.0
25
+ export QUANTDINGER_MCP_PORT=7800
26
+ export QUANTDINGER_MCP_PUBLIC_URL=https://mcp.example.com
27
+ export QUANTDINGER_MCP_AUTH_TOKEN=replace-with-a-random-32-plus-character-secret
28
+ sharkquant-mcp
29
+ ```
30
+
31
+ Clients must send `Authorization: Bearer <QUANTDINGER_MCP_AUTH_TOKEN>` to `/mcp` or `/sse`. Authenticated non-loopback listeners require an HTTPS `QUANTDINGER_MCP_PUBLIC_URL`. `QUANTDINGER_MCP_ALLOW_HTTP=true` is only for a trusted private proxy that terminates TLS. For an unauthenticated private ingress that already authenticates every request, `QUANTDINGER_MCP_ALLOW_INSECURE_HTTP=true` remains a separate escape hatch; never use either setting on a directly reachable public listener.
32
+
33
+ Docker builds use the official PyPI index by default. In regions where it is slow, override it without editing the image definition: `docker build --build-arg PIP_INDEX_URL=https://your-mirror.example/simple .`.
34
+
35
+ Never place an agent token in prompts, logs, screenshots, source control, or MCP configuration that will be shared. Responses redact credential fields, and clients must not attempt to recover them.
36
+
37
+ ## Tool surface
38
+
39
+ | Tool group | Scope | Purpose |
40
+ |---|---:|---|
41
+ | `whoami`, `check_health` | R/public | Identity, allowlists, and liveness |
42
+ | `list_markets`, `search_symbols`, `get_klines`, `get_price` | R | Market discovery and data |
43
+ | Universe and factor tools, `get_macro_liquidity` | R | Point-in-time research inputs and compact USD liquidity regime (no chart history) |
44
+ | `list_watchlist`, `add_watchlist`, `remove_watchlist` | R/W | Watchlist workspace |
45
+ | Indicator authoring, validation, save, link, and read tools | R/W | Chart-only indicators |
46
+ | `list_strategy_templates` | R | Strategy API V2 system templates |
47
+ | `compile_strategy_code` | W | Compile Strategy API V2 code to its canonical manifest |
48
+ | `list_strategy_sources`, `get_strategy_source`, `save_strategy_source` | R/W | Private Strategy API V2 source library |
49
+ | `list_strategy_source_versions`, `restore_strategy_source_version` | R/W | Source history and explicitly confirmed restore |
50
+ | `create_strategy`, `update_strategy`, `list_strategies`, `get_strategy` | R/W | Strategy API V2 deployments |
51
+ | `submit_backtest` | B | Strategy API V2 backtest job |
52
+ | `list_jobs`, `get_job`, `wait_for_job`, `stream_job_until_done`, `cancel_job` | R/B | Bounded jobs and confirmed cancellation |
53
+ | `runtime_overview`, `stop_strategy` | R/T | Runtime inspection and confirmed stop |
54
+ | Broker account, strategy position/trade, and quick-trade observation tools | R | Secret-free execution observations |
55
+ | Signal-alert tools | N | Notification task lifecycle and confirmed delivery evaluation |
56
+ | `place_quick_order` | T | Confirmed order with token notional caps |
57
+ | `list_portfolio_positions`, `list_paper_orders` | R | Portfolio and paper-order reads |
58
+ | `emergency_stop_trading`, `cancel_open_paper_orders` | T | Emergency cancellation and T-token revocation |
59
+
60
+ Every mutating W/B/N/T tool requires a caller-generated `idempotency_key`; retries of the same request must reuse it. `stop_strategy` requires `confirm_stop=true`. `place_quick_order` requires `confirm_order=true`; a live-capable token also requires `confirm_live_trading=true`. Optional `tp_price` and `sl_price` protection are forwarded to the shared Quick Trade execution path. Server-side trading flags, allowlists, and per-order/per-day notional caps still apply.
61
+
62
+ ## Strategy API V2 workflow
63
+
64
+ Executable strategy code must define `initialize(context)` and declare its universe and subscriptions. It must provide `handle_data`, `on_rebalance`, or a scheduled callback. The manifest owns instruments, markets, frequencies, factor dependencies, warmup, and leverage policy.
65
+
66
+ Compile and save a source before creating a stopped deployment:
67
+
68
+ ```text
69
+ compile_strategy_code(code="...Strategy API V2 Python...", idempotency_key="compile-btc-momentum-v1")
70
+ save_strategy_source(name="btc-momentum", code="...Strategy API V2 Python...", idempotency_key="save-btc-momentum-v1")
71
+ ```
72
+
73
+ Use the returned source id:
74
+
75
+ ```text
76
+ create_strategy(
77
+ name="btc-momentum",
78
+ source_id=12,
79
+ initial_capital=10000,
80
+ execution_mode="signal",
81
+ params={"lookback": 40},
82
+ idempotency_key="deploy-btc-momentum-v1"
83
+ )
84
+ ```
85
+
86
+ Run a backtest directly from V2 code:
87
+
88
+ ```text
89
+ submit_backtest(
90
+ code="...Strategy API V2 Python...",
91
+ start_date="2025-01-01",
92
+ end_date="2025-12-31",
93
+ initial_capital=10000,
94
+ params={"lookback": 40},
95
+ idempotency_key="btc-momentum-2025"
96
+ )
97
+ ```
98
+
99
+ Market, symbol, and timeframe are not backtest parameters. They come from the compiled strategy manifest. Use `wait_for_job` or `stream_job_until_done` to obtain the result.
100
+
101
+ Indicators are chart-only. Validate and save them through the indicator tools, then convert the idea into Strategy API V2 code before using `submit_backtest` or `create_strategy`.
102
+
103
+ Restoring a source snapshot requires `confirm_restore=true`. The emergency stop requires confirmation, attempts to cancel agent-originated live orders, cancels paper orders, revokes every active tenant T token, and reports exchange cancellations needing human follow-up.
104
+
105
+ The optional Docker network service is enabled explicitly:
106
+
107
+ ```bash
108
+ QUANTDINGER_AGENT_TOKEN=qd_agent_xxx \
109
+ QUANTDINGER_MCP_AUTH_TOKEN="$(openssl rand -hex 32)" \
110
+ docker compose --profile mcp up -d --build mcp
111
+ ```
112
+
113
+ ## Development
114
+
115
+ ```bash
116
+ pip install -e './mcp_server[dev]'
117
+ pytest mcp_server/tests
118
+ ```
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sharkquant-mcp"
7
+ version = "0.6.3"
8
+ description = "Full-surface Model Context Protocol server for SharkQuant research, strategy authoring, backtests, observations, notifications, and safety-gated trading."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "SharkQuant", email = "support@sharkv2.com" }
15
+ ]
16
+ keywords = [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "sharkquant",
20
+ "ai-agent",
21
+ "trading",
22
+ "backtest",
23
+ "quant",
24
+ "cursor",
25
+ "claude",
26
+ "codex",
27
+ "openclaw",
28
+ "nanobot"
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 4 - Beta",
32
+ "Intended Audience :: Developers",
33
+ "Intended Audience :: Financial and Insurance Industry",
34
+ "Operating System :: OS Independent",
35
+ "Programming Language :: Python :: 3",
36
+ "Programming Language :: Python :: 3.10",
37
+ "Programming Language :: Python :: 3.11",
38
+ "Programming Language :: Python :: 3.12",
39
+ "Programming Language :: Python :: 3.13",
40
+ "Topic :: Office/Business :: Financial :: Investment",
41
+ "Topic :: Software Development :: Libraries :: Python Modules"
42
+ ]
43
+ dependencies = [
44
+ "mcp>=1.28.1,<1.29",
45
+ "httpx>=0.27.0,<0.29"
46
+ ]
47
+
48
+ [project.optional-dependencies]
49
+ dev = [
50
+ "pytest>=7",
51
+ "build>=1.0",
52
+ "twine>=4"
53
+ ]
54
+
55
+ [project.urls]
56
+ Homepage = "https://github.com/guofeng201507/sharkquant"
57
+ Documentation = "https://github.com/guofeng201507/sharkquant/blob/main/docs/agent/AGENT_QUICKSTART.md"
58
+ Repository = "https://github.com/guofeng201507/sharkquant"
59
+ Issues = "https://github.com/guofeng201507/sharkquant/issues"
60
+ Changelog = "https://github.com/guofeng201507/sharkquant/blob/main/mcp_server/RELEASE.md"
61
+
62
+ [project.scripts]
63
+ sharkquant-mcp = "sharkquant_mcp.server:main"
64
+ quantdinger-mcp = "sharkquant_mcp.server:main"
65
+
66
+ [tool.setuptools]
67
+ include-package-data = true
68
+
69
+ [tool.setuptools.packages.find]
70
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ """Compatibility shim for the legacy ``quantdinger_mcp`` import name."""
2
+ from sharkquant_mcp import __version__
3
+
4
+ __all__ = ["__version__"]
@@ -0,0 +1,5 @@
1
+ """Run the legacy module name against the SharkQuant MCP server."""
2
+ from sharkquant_mcp.server import main
3
+
4
+ if __name__ == "__main__":
5
+ main()
@@ -0,0 +1,6 @@
1
+ """Compatibility shim for the legacy ``quantdinger_mcp.security`` import path."""
2
+ import sys
3
+
4
+ from sharkquant_mcp import security as _security
5
+
6
+ sys.modules[__name__] = _security
@@ -0,0 +1,6 @@
1
+ """Compatibility shim for the legacy ``quantdinger_mcp.server`` import path."""
2
+ import sys
3
+
4
+ from sharkquant_mcp import server as _server
5
+
6
+ sys.modules[__name__] = _server
@@ -0,0 +1,6 @@
1
+ """Compatibility shim for the legacy ``quantdinger_mcp.tool_contract`` import path."""
2
+ import sys
3
+
4
+ from sharkquant_mcp import tool_contract as _tool_contract
5
+
6
+ sys.modules[__name__] = _tool_contract
@@ -0,0 +1,2 @@
1
+ """SharkQuant MCP server package."""
2
+ __version__ = "0.6.3"