quantifyme-mcp 0.1.0__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,35 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .eggs/
11
+
12
+ # Virtual environments
13
+ venv/
14
+ env/
15
+ .env
16
+ .venv
17
+
18
+ # Jupyter
19
+ .ipynb_checkpoints/
20
+
21
+ # Database (contains scraped data, no need to track)
22
+ data/orderbook.db
23
+ data/*.db
24
+ v2/data/
25
+ backtest_notebooks/
26
+
27
+ # OS
28
+ .DS_Store
29
+ Thumbs.db
30
+
31
+ # IDE
32
+ .vscode/
33
+ .idea/
34
+ *.swp
35
+ v2/venv_diarize/
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantifyme-mcp
3
+ Version: 0.1.0
4
+ Summary: Claude MCP server for QuantifyMe — deploy trading strategies from natural language.
5
+ Project-URL: Homepage, https://quantifyme.ai
6
+ Project-URL: Documentation, https://api.quantifyme.ai/openapi.json
7
+ Project-URL: Source, https://github.com/malcolm1232/HFTAgent
8
+ Author-email: QuantifyMe <support@quantifyme.ai>
9
+ License: MIT
10
+ Keywords: backtesting,claude,mcp,quantifyme,quantitative,trading
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: httpx>=0.27.0
22
+ Requires-Dist: mcp>=1.0.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # quantifyme-mcp
26
+
27
+ Claude MCP server for [QuantifyMe](https://quantifyme.ai) — deploy algorithmic trading strategies from natural language.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install quantifyme-mcp
33
+ claude mcp add quantifyme quantifyme-mcp
34
+ ```
35
+
36
+ Or with [uvx](https://docs.astral.sh/uv/) (no install):
37
+
38
+ ```bash
39
+ claude mcp add quantifyme uvx quantifyme-mcp
40
+ ```
41
+
42
+ ## Use in Claude
43
+
44
+ Once registered, ask Claude:
45
+
46
+ > Deploy a strategy that buys EURUSD when RSI hits 30 and sells when it hits 70.
47
+
48
+ Claude will call the `one_shot` tool, which generates the strategy code, trains a model on 28 days of OHLC data, and deploys it live. You get a webhook/Telegram-ready URL back.
49
+
50
+ ## Environment
51
+
52
+ - `QUANTIFYME_API_KEY` — your personal key (optional; anonymous trial key auto-created if unset)
53
+ - `QUANTIFYME_BASE_URL` — override API base (default `https://api.quantifyme.ai`)
54
+
55
+ ## Tools exposed
56
+
57
+ | Tool | Purpose |
58
+ |---|---|
59
+ | `one_shot` | Prompt → generate → train → deploy → live signal URL |
60
+ | `list_models` | User's trained models with train/test stats |
61
+ | `list_deployed` | Currently live models |
62
+ | `get_trial_key` | Anonymous trial key (50 credits, no signup) |
63
+ | `generate_strategy` | Code-only generation (no training) |
64
+
65
+ ## License
66
+
67
+ MIT
@@ -0,0 +1,43 @@
1
+ # quantifyme-mcp
2
+
3
+ Claude MCP server for [QuantifyMe](https://quantifyme.ai) — deploy algorithmic trading strategies from natural language.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install quantifyme-mcp
9
+ claude mcp add quantifyme quantifyme-mcp
10
+ ```
11
+
12
+ Or with [uvx](https://docs.astral.sh/uv/) (no install):
13
+
14
+ ```bash
15
+ claude mcp add quantifyme uvx quantifyme-mcp
16
+ ```
17
+
18
+ ## Use in Claude
19
+
20
+ Once registered, ask Claude:
21
+
22
+ > Deploy a strategy that buys EURUSD when RSI hits 30 and sells when it hits 70.
23
+
24
+ Claude will call the `one_shot` tool, which generates the strategy code, trains a model on 28 days of OHLC data, and deploys it live. You get a webhook/Telegram-ready URL back.
25
+
26
+ ## Environment
27
+
28
+ - `QUANTIFYME_API_KEY` — your personal key (optional; anonymous trial key auto-created if unset)
29
+ - `QUANTIFYME_BASE_URL` — override API base (default `https://api.quantifyme.ai`)
30
+
31
+ ## Tools exposed
32
+
33
+ | Tool | Purpose |
34
+ |---|---|
35
+ | `one_shot` | Prompt → generate → train → deploy → live signal URL |
36
+ | `list_models` | User's trained models with train/test stats |
37
+ | `list_deployed` | Currently live models |
38
+ | `get_trial_key` | Anonymous trial key (50 credits, no signup) |
39
+ | `generate_strategy` | Code-only generation (no training) |
40
+
41
+ ## License
42
+
43
+ MIT
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "quantifyme-mcp"
7
+ version = "0.1.0"
8
+ description = "Claude MCP server for QuantifyMe — deploy trading strategies from natural language."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "QuantifyMe", email = "support@quantifyme.ai" }]
13
+ keywords = ["mcp", "claude", "trading", "quantitative", "backtesting", "quantifyme"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Financial and Insurance Industry",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ ]
25
+ dependencies = [
26
+ "mcp>=1.0.0",
27
+ "httpx>=0.27.0",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://quantifyme.ai"
32
+ Documentation = "https://api.quantifyme.ai/openapi.json"
33
+ Source = "https://github.com/malcolm1232/HFTAgent"
34
+
35
+ [project.scripts]
36
+ quantifyme-mcp = "quantifyme_mcp:main"
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+ packages = ["."]
40
+ include = ["quantifyme_mcp.py"]
@@ -0,0 +1,186 @@
1
+ """
2
+ QuantifyMe MCP server.
3
+
4
+ Usage (Claude Desktop / Claude Code):
5
+ claude mcp add quantifyme -- /path/to/python /path/to/quantifyme_mcp.py
6
+
7
+ Env vars:
8
+ QUANTIFYME_API_KEY your personal key (optional — trial key auto-created if unset)
9
+ QUANTIFYME_BASE_URL override API base (default: https://api.quantifyme.ai)
10
+
11
+ Exposes 5 tools:
12
+ - one_shot end-to-end: prompt → generate → train → deploy → live_url
13
+ - list_models user's trained models with pre-computed train/test stats
14
+ - list_deployed currently live (deployed) models
15
+ - get_trial_key creates/returns anonymous trial key (if no personal key set)
16
+ - generate_strategy code-only generation (no training/deploy) from NL
17
+ """
18
+ from __future__ import annotations
19
+
20
+ import asyncio
21
+ import json
22
+ import os
23
+ from typing import Any
24
+
25
+ import httpx
26
+ from mcp.server.fastmcp import FastMCP
27
+
28
+
29
+ BASE_URL = os.environ.get("QUANTIFYME_BASE_URL", "https://api.quantifyme.ai").rstrip("/")
30
+ API_KEY_ENV = "QUANTIFYME_API_KEY"
31
+
32
+ mcp = FastMCP(
33
+ "quantifyme",
34
+ instructions=(
35
+ "QuantifyMe is a no-code quant trading platform. Use `one_shot` to take "
36
+ "a user's natural-language strategy description and deploy a live signal "
37
+ "model in one call. Use `list_models` / `list_deployed` to inspect state. "
38
+ "If QUANTIFYME_API_KEY is unset, call `get_trial_key` first — it returns "
39
+ "an anonymous trial key (50 credits, no signup)."
40
+ ),
41
+ )
42
+
43
+ # Shared trial key cache — so repeated calls in one session reuse the key
44
+ _cached_trial_key: str | None = None
45
+
46
+
47
+ async def _resolve_key(client: httpx.AsyncClient) -> str:
48
+ """Return an API key: env var → cached trial → newly-minted trial."""
49
+ global _cached_trial_key
50
+ env_key = os.environ.get(API_KEY_ENV)
51
+ if env_key:
52
+ return env_key
53
+ if _cached_trial_key:
54
+ return _cached_trial_key
55
+ r = await client.post(f"{BASE_URL}/api/v1/key/trial", timeout=30)
56
+ r.raise_for_status()
57
+ data = r.json()
58
+ _cached_trial_key = data["api_key"]
59
+ return _cached_trial_key
60
+
61
+
62
+ @mcp.tool()
63
+ async def get_trial_key() -> dict[str, Any]:
64
+ """Create an anonymous trial API key (50 credits, no signup). Idempotent within session."""
65
+ async with httpx.AsyncClient() as client:
66
+ key = await _resolve_key(client)
67
+ return {"api_key": key, "cached": _cached_trial_key == key, "base_url": BASE_URL}
68
+
69
+
70
+ @mcp.tool()
71
+ async def one_shot(prompt: str, webhook_url: str | None = None,
72
+ telegram_chat_id: str | None = None) -> dict[str, Any]:
73
+ """End-to-end deploy: generate strategy from prompt → train → deploy live.
74
+
75
+ Args:
76
+ prompt: Natural-language strategy description (e.g. "Buy when RSI < 30, sell > 70").
77
+ webhook_url: Optional webhook to receive live signals.
78
+ telegram_chat_id: Optional Telegram chat ID for signal delivery.
79
+
80
+ Returns:
81
+ dict with live_url, model, stem, channels, and progress log.
82
+ """
83
+ deliver_to: dict[str, Any] = {"webhook": True}
84
+ if webhook_url:
85
+ deliver_to["webhook"] = webhook_url
86
+ if telegram_chat_id:
87
+ deliver_to["telegram"] = telegram_chat_id
88
+
89
+ progress: list[str] = []
90
+ final: dict[str, Any] | None = None
91
+ error: str | None = None
92
+
93
+ async with httpx.AsyncClient(timeout=600) as client:
94
+ key = await _resolve_key(client)
95
+ async with client.stream(
96
+ "POST",
97
+ f"{BASE_URL}/api/v1/one_shot",
98
+ headers={"X-API-Key": key, "Content-Type": "application/json"},
99
+ json={"prompt": prompt, "deliver_to": deliver_to},
100
+ ) as resp:
101
+ event: str | None = None
102
+ async for raw in resp.aiter_lines():
103
+ if not raw:
104
+ continue
105
+ if raw.startswith("event:"):
106
+ event = raw.split(":", 1)[1].strip()
107
+ elif raw.startswith("data:"):
108
+ data = json.loads(raw.split(":", 1)[1])
109
+ if event == "step":
110
+ progress.append(f"[{data.get('pct', 0):>3}%] {data.get('stage')}: {data.get('msg', '')}")
111
+ elif event == "done":
112
+ final = data
113
+ break
114
+ elif event == "error":
115
+ error = data.get("error", "unknown")
116
+ break
117
+
118
+ if error:
119
+ return {"ok": False, "error": error, "progress": progress}
120
+ if not final:
121
+ return {"ok": False, "error": "Stream ended before done event", "progress": progress}
122
+ return {"ok": True, **final, "progress": progress}
123
+
124
+
125
+ @mcp.tool()
126
+ async def list_models() -> dict[str, Any]:
127
+ """List the user's trained models with pre-computed train/test stats."""
128
+ async with httpx.AsyncClient(timeout=30) as client:
129
+ key = await _resolve_key(client)
130
+ r = await client.get(f"{BASE_URL}/api/v1/models", headers={"X-API-Key": key})
131
+ r.raise_for_status()
132
+ return r.json()
133
+
134
+
135
+ @mcp.tool()
136
+ async def list_deployed() -> dict[str, Any]:
137
+ """List the user's currently deployed (live) models."""
138
+ async with httpx.AsyncClient(timeout=30) as client:
139
+ key = await _resolve_key(client)
140
+ r = await client.get(f"{BASE_URL}/api/v1/deployed", headers={"X-API-Key": key})
141
+ r.raise_for_status()
142
+ return r.json()
143
+
144
+
145
+ @mcp.tool()
146
+ async def generate_strategy(
147
+ features: str = "",
148
+ signals: str = "",
149
+ model: str = "Random Forest",
150
+ risk: str = "",
151
+ description: str | None = None,
152
+ ) -> dict[str, Any]:
153
+ """Generate Python strategy code (no training/deploy). Use when the user wants the raw code.
154
+
155
+ Args:
156
+ features: NL description of features (e.g. "RSI 14, Bollinger Bands").
157
+ signals: NL description of signal logic (e.g. "Buy when RSI < 30").
158
+ model: ML model name (default Random Forest).
159
+ risk: NL risk rules (e.g. "0.5% stop loss").
160
+ description: Optional one-line summary; treated as PRIMARY USER REQUEST.
161
+ """
162
+ async with httpx.AsyncClient(timeout=120) as client:
163
+ key = await _resolve_key(client)
164
+ body: dict[str, Any] = {
165
+ "features": features, "signals": signals, "model": model,
166
+ "risk": risk, "optimization": "", "risk_function": "",
167
+ "indicators": {}, "pos_rules": {},
168
+ "claude_model": "sonnet",
169
+ }
170
+ if description:
171
+ body["description"] = description
172
+ r = await client.post(
173
+ f"{BASE_URL}/api/v1/generate",
174
+ headers={"X-API-Key": key, "Content-Type": "application/json"},
175
+ json=body,
176
+ )
177
+ r.raise_for_status()
178
+ return r.json()
179
+
180
+
181
+ def main() -> None:
182
+ mcp.run(transport="stdio")
183
+
184
+
185
+ if __name__ == "__main__":
186
+ main()