xrtm-data 0.2.1__tar.gz → 0.2.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.
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/PKG-INFO +2 -2
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/pyproject.toml +2 -3
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/cli/__init__.py +13 -6
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/core/schemas/forecast.py +45 -8
- xrtm_data-0.2.3/src/xrtm/data/corpora/__init__.py +36 -0
- xrtm_data-0.2.3/src/xrtm/data/corpora/real_binary.py +506 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/kit/processors/__init__.py +11 -5
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/local/csv.py +74 -29
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/online/polymarket.py +37 -2
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/version.py +1 -1
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm_data.egg-info/PKG-INFO +2 -2
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm_data.egg-info/SOURCES.txt +6 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/tests/test_beta_fitter.py +6 -0
- xrtm_data-0.2.3/tests/test_cli_loading.py +42 -0
- xrtm_data-0.2.3/tests/test_cli_ux.py +41 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/tests/test_local_datasource.py +74 -0
- xrtm_data-0.2.3/tests/test_polymarket_source.py +101 -0
- xrtm_data-0.2.3/tests/test_real_binary_corpus.py +110 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/tests/test_schemas.py +26 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/LICENSE +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/README.md +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/setup.cfg +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/core/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/core/interfaces.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/core/schemas/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/core/schemas/prior.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/core/schemas/trade.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/kit/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/local/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/online/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/subgraph/__init__.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm/data/providers/subgraph/polymarket.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm_data.egg-info/dependency_links.txt +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm_data.egg-info/entry_points.txt +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm_data.egg-info/requires.txt +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/src/xrtm_data.egg-info/top_level.txt +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/tests/test_polymarket_subgraph.py +0 -0
- {xrtm_data-0.2.1 → xrtm_data-0.2.3}/tests/test_prior_schemas.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xrtm-data
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: The Snapshot Vault for XRTM.
|
|
5
5
|
Author-email: XRTM Team <moy@xrtm.org>
|
|
6
|
-
License: Apache-2.0
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "xrtm-data"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "The Snapshot Vault for XRTM."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
|
-
license =
|
|
11
|
+
license = "Apache-2.0"
|
|
12
12
|
authors = [
|
|
13
13
|
{name = "XRTM Team", email = "moy@xrtm.org"}
|
|
14
14
|
]
|
|
@@ -38,7 +38,6 @@ package-dir = {"" = "src"}
|
|
|
38
38
|
packages = {find = {where = ["src"], include = ["xrtm*"], namespaces = true}}
|
|
39
39
|
|
|
40
40
|
[tool.pytest.ini_options]
|
|
41
|
-
pythonpath = ["src"]
|
|
42
41
|
testpaths = ["tests"]
|
|
43
42
|
asyncio_mode = "strict"
|
|
44
43
|
|
|
@@ -75,6 +75,9 @@ def collect(
|
|
|
75
75
|
xrtm-data collect -m 0x1234... -d 30 -o data/trades.parquet
|
|
76
76
|
"""
|
|
77
77
|
output_path = Path(output)
|
|
78
|
+
output_suffix = output_path.suffix.lower()
|
|
79
|
+
if output_suffix not in {".parquet", ".json"}:
|
|
80
|
+
raise click.ClickException("Output path must end with .parquet or .json")
|
|
78
81
|
|
|
79
82
|
# Check cache
|
|
80
83
|
if output_path.exists() and not force:
|
|
@@ -124,10 +127,12 @@ def collect(
|
|
|
124
127
|
# Save output
|
|
125
128
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
126
129
|
|
|
127
|
-
if
|
|
130
|
+
if output_suffix == ".parquet":
|
|
128
131
|
_save_parquet(window, output_path)
|
|
129
|
-
|
|
132
|
+
elif output_suffix == ".json":
|
|
130
133
|
_save_json(window, output_path)
|
|
134
|
+
else: # pragma: no cover - guarded before collection
|
|
135
|
+
raise click.ClickException("Output path must end with .parquet or .json")
|
|
131
136
|
|
|
132
137
|
console.print(f"[green]✓ Saved {len(window.trades)} trades to:[/green] {output_path}")
|
|
133
138
|
|
|
@@ -214,8 +219,9 @@ def info(file_path: str):
|
|
|
214
219
|
Displays summary statistics for trade files or prior files.
|
|
215
220
|
"""
|
|
216
221
|
path = Path(file_path)
|
|
222
|
+
suffix = path.suffix.lower()
|
|
217
223
|
|
|
218
|
-
if
|
|
224
|
+
if suffix == ".json":
|
|
219
225
|
with open(path) as f:
|
|
220
226
|
data = json.load(f)
|
|
221
227
|
|
|
@@ -230,7 +236,7 @@ def info(file_path: str):
|
|
|
230
236
|
))
|
|
231
237
|
else:
|
|
232
238
|
console.print(f"JSON file with {len(data)} keys")
|
|
233
|
-
elif
|
|
239
|
+
elif suffix == ".parquet":
|
|
234
240
|
import pyarrow.parquet as pq
|
|
235
241
|
|
|
236
242
|
table = pq.read_table(path)
|
|
@@ -240,6 +246,8 @@ def info(file_path: str):
|
|
|
240
246
|
f"Columns: {table.column_names}",
|
|
241
247
|
title=path.name,
|
|
242
248
|
))
|
|
249
|
+
else:
|
|
250
|
+
raise click.ClickException("Unsupported file type. Expected .json or .parquet")
|
|
243
251
|
|
|
244
252
|
|
|
245
253
|
def _save_parquet(window, path: Path) -> None:
|
|
@@ -289,7 +297,6 @@ def _load_trades(path: Path) -> list:
|
|
|
289
297
|
import pyarrow.parquet as pq
|
|
290
298
|
|
|
291
299
|
table = pq.read_table(path)
|
|
292
|
-
df = table.to_pandas()
|
|
293
300
|
return [
|
|
294
301
|
TradeEvent(
|
|
295
302
|
price=row["price"],
|
|
@@ -298,7 +305,7 @@ def _load_trades(path: Path) -> list:
|
|
|
298
305
|
maker=row["maker"],
|
|
299
306
|
taker=row["taker"],
|
|
300
307
|
)
|
|
301
|
-
for
|
|
308
|
+
for row in table.to_pylist()
|
|
302
309
|
]
|
|
303
310
|
else:
|
|
304
311
|
with open(path) as f:
|
|
@@ -28,7 +28,7 @@ Example:
|
|
|
28
28
|
from datetime import datetime, timezone
|
|
29
29
|
from typing import Any, Dict, List, Optional
|
|
30
30
|
|
|
31
|
-
from pydantic import AliasChoices, BaseModel, ConfigDict, Field
|
|
31
|
+
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, model_validator
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
class MetadataBase(BaseModel):
|
|
@@ -202,6 +202,41 @@ class ForecastOutput(BaseModel):
|
|
|
202
202
|
calibration_metrics: Dict[str, Any] = Field(default_factory=dict, description="Performance metrics")
|
|
203
203
|
metadata: MetadataBase = Field(default_factory=MetadataBase) # type: ignore[arg-type]
|
|
204
204
|
|
|
205
|
+
@model_validator(mode="before")
|
|
206
|
+
@classmethod
|
|
207
|
+
def _apply_reasoning_trace_alias(cls, data: Any) -> Any:
|
|
208
|
+
r"""Accept governance ``reasoning_trace`` as an alias for runtime trace fields."""
|
|
209
|
+
if not isinstance(data, dict) or "reasoning_trace" not in data:
|
|
210
|
+
return data
|
|
211
|
+
|
|
212
|
+
trace = data["reasoning_trace"]
|
|
213
|
+
updated = dict(data)
|
|
214
|
+
if isinstance(trace, dict):
|
|
215
|
+
if "reasoning" not in updated and isinstance(trace.get("narrative"), str):
|
|
216
|
+
updated["reasoning"] = trace["narrative"]
|
|
217
|
+
|
|
218
|
+
causal_graph = trace.get("causal_graph")
|
|
219
|
+
if isinstance(causal_graph, dict):
|
|
220
|
+
if "logical_trace" not in updated and "nodes" in causal_graph:
|
|
221
|
+
updated["logical_trace"] = causal_graph["nodes"]
|
|
222
|
+
if "logical_edges" not in updated and "edges" in causal_graph:
|
|
223
|
+
updated["logical_edges"] = causal_graph["edges"]
|
|
224
|
+
elif isinstance(trace, list) and "logical_trace" not in updated:
|
|
225
|
+
updated["logical_trace"] = trace
|
|
226
|
+
|
|
227
|
+
return updated
|
|
228
|
+
|
|
229
|
+
@property
|
|
230
|
+
def reasoning_trace(self) -> Dict[str, Any]:
|
|
231
|
+
r"""Governance-compatible alias for the narrative and causal graph trace."""
|
|
232
|
+
return {
|
|
233
|
+
"narrative": self.reasoning,
|
|
234
|
+
"causal_graph": {
|
|
235
|
+
"nodes": [node.model_dump(exclude_none=True) for node in self.logical_trace],
|
|
236
|
+
"edges": [edge.model_dump(exclude_none=True) for edge in self.logical_edges],
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
|
|
205
240
|
@property
|
|
206
241
|
def confidence(self) -> float:
|
|
207
242
|
r"""Backward compatibility alias for probability."""
|
|
@@ -227,15 +262,17 @@ class ForecastOutput(BaseModel):
|
|
|
227
262
|
except ImportError:
|
|
228
263
|
raise ImportError("networkx is required for to_networkx(). Install it with 'uv add networkx'.")
|
|
229
264
|
dg = nx.DiGraph()
|
|
230
|
-
|
|
231
|
-
|
|
265
|
+
dg.add_nodes_from(
|
|
266
|
+
(
|
|
232
267
|
node.node_id,
|
|
233
|
-
event
|
|
234
|
-
probability=node.probability,
|
|
235
|
-
description=node.description,
|
|
268
|
+
{"event": node.event, "probability": node.probability, "description": node.description},
|
|
236
269
|
)
|
|
237
|
-
|
|
238
|
-
|
|
270
|
+
for node in self.logical_trace
|
|
271
|
+
)
|
|
272
|
+
dg.add_edges_from(
|
|
273
|
+
(edge.source, edge.target, {"weight": edge.weight, "description": edge.description})
|
|
274
|
+
for edge in self.logical_edges
|
|
275
|
+
)
|
|
239
276
|
return dg
|
|
240
277
|
|
|
241
278
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
# Copyright 2026 XRTM Team. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
r"""Deterministic fixture corpora for offline validation."""
|
|
17
|
+
|
|
18
|
+
from xrtm.data.corpora.real_binary import (
|
|
19
|
+
REAL_BINARY_CORPUS_ID,
|
|
20
|
+
RealBinaryCorpusSource,
|
|
21
|
+
RealBinaryQuestionRecord,
|
|
22
|
+
load_real_binary_corpus,
|
|
23
|
+
load_real_binary_questions,
|
|
24
|
+
load_real_binary_resolved_outcomes,
|
|
25
|
+
validate_real_binary_corpus,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"REAL_BINARY_CORPUS_ID",
|
|
30
|
+
"RealBinaryQuestionRecord",
|
|
31
|
+
"RealBinaryCorpusSource",
|
|
32
|
+
"load_real_binary_corpus",
|
|
33
|
+
"load_real_binary_questions",
|
|
34
|
+
"load_real_binary_resolved_outcomes",
|
|
35
|
+
"validate_real_binary_corpus",
|
|
36
|
+
]
|