probalytics 0.2.1__tar.gz → 0.2.2__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.
- {probalytics-0.2.1 → probalytics-0.2.2}/PKG-INFO +29 -7
- {probalytics-0.2.1 → probalytics-0.2.2}/README.md +28 -6
- {probalytics-0.2.1 → probalytics-0.2.2}/pyproject.toml +1 -1
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/models.py +1 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/tests/test_clickhouse_integration.py +16 -1
- {probalytics-0.2.1 → probalytics-0.2.2}/tests/test_models.py +4 -3
- {probalytics-0.2.1 → probalytics-0.2.2}/.gitignore +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/LICENSE +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/__init__.py +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/_filters.py +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/_frames.py +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/clickhouse.py +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/client.py +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/src/probalytics/py.typed +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/tests/conftest.py +0 -0
- {probalytics-0.2.1 → probalytics-0.2.2}/tests/sample_clickhouse_data.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: probalytics
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Python client for Probalytics market, fill, and orderbook data
|
|
5
5
|
Project-URL: Homepage, https://github.com/Probalytics/probalytics-python
|
|
6
6
|
Project-URL: Repository, https://github.com/Probalytics/probalytics-python
|
|
@@ -179,6 +179,10 @@ fills = client.fills(
|
|
|
179
179
|
Use a market selector or a bounded time range when querying fills. This keeps
|
|
180
180
|
queries fast and avoids scanning more data than you need.
|
|
181
181
|
|
|
182
|
+
`start_time` / `end_time` filter `timestamp` (the exchange time) on `fills` and
|
|
183
|
+
`orderbook_snapshots`, and `created_at` on `markets` — a market created months
|
|
184
|
+
ago still returns today's fills.
|
|
185
|
+
|
|
182
186
|
Filter by participant or taker side:
|
|
183
187
|
|
|
184
188
|
```python
|
|
@@ -224,9 +228,16 @@ Each snapshot is a complete replacement book for one outcome. Rows include
|
|
|
224
228
|
`indexed_at`, `hash`, `state`, `continuity`, and `path_index` in addition to the
|
|
225
229
|
market identifiers, outcome, bids, asks, and source timestamp.
|
|
226
230
|
|
|
227
|
-
|
|
228
|
-
`
|
|
229
|
-
|
|
231
|
+
`state` is `VERIFIED` or `INTERMEDIATE`. `continuity` is `CONTIGUOUS` (the
|
|
232
|
+
transition from the previous book was provable), `RESET` (it was not — the first
|
|
233
|
+
state of a book is deliberately `RESET`), or `UNKNOWN` for rows predating
|
|
234
|
+
continuity tracking. Several distinct states can share one millisecond; `hash`
|
|
235
|
+
separates them and `path_index` orders them within a recovered path.
|
|
236
|
+
|
|
237
|
+
Note that these columns were added to the warehouse in August 2026. Rows written
|
|
238
|
+
before then read the column default rather than a measured value: `hash` is 0
|
|
239
|
+
before 2026-08-02, `state` reads `VERIFIED` before 2026-08-21, and `continuity`
|
|
240
|
+
reads `UNKNOWN` before 2026-08-22.
|
|
230
241
|
|
|
231
242
|
## Choose Polars or pandas
|
|
232
243
|
|
|
@@ -262,6 +273,8 @@ Use `query()` for read-only ClickHouse queries when the convenience methods do
|
|
|
262
273
|
not cover your use case.
|
|
263
274
|
|
|
264
275
|
```python
|
|
276
|
+
from datetime import datetime, timezone
|
|
277
|
+
|
|
265
278
|
df = client.query(
|
|
266
279
|
"""
|
|
267
280
|
SELECT platform, count() AS fills
|
|
@@ -270,15 +283,24 @@ df = client.query(
|
|
|
270
283
|
GROUP BY platform
|
|
271
284
|
ORDER BY fills DESC
|
|
272
285
|
""",
|
|
273
|
-
parameters={"start_time":
|
|
286
|
+
parameters={"start_time": datetime(2026, 3, 15, tzinfo=timezone.utc)},
|
|
274
287
|
)
|
|
275
288
|
```
|
|
276
289
|
|
|
277
290
|
Always pass user-provided values through `parameters` instead of formatting them
|
|
278
291
|
directly into SQL strings.
|
|
279
292
|
|
|
293
|
+
Unlike the convenience methods, `query()` passes parameters straight to
|
|
294
|
+
ClickHouse — it does not parse date strings for you. Pass a `datetime`, or a
|
|
295
|
+
string ClickHouse accepts such as `"2026-03-15 00:00:00"`. An ISO string with a
|
|
296
|
+
trailing `Z` is rejected by the server.
|
|
297
|
+
|
|
280
298
|
## Supported Filters
|
|
281
299
|
|
|
300
|
+
The convenience methods return at most `limit` rows, and **`limit` defaults to 1000**.
|
|
301
|
+
Raise it explicitly when you want more than that — results are truncated
|
|
302
|
+
silently, not flagged.
|
|
303
|
+
|
|
282
304
|
`markets()` and `markets_frame()` support:
|
|
283
305
|
|
|
284
306
|
- `start_time`
|
|
@@ -305,8 +327,8 @@ directly into SQL strings.
|
|
|
305
327
|
|
|
306
328
|
`orderbook_snapshots()` supports:
|
|
307
329
|
|
|
308
|
-
- `start_time`
|
|
309
|
-
- `end_time`
|
|
330
|
+
- `start_time` (**required**)
|
|
331
|
+
- `end_time` (**required**)
|
|
310
332
|
- `platform` or list of platforms
|
|
311
333
|
- `market`
|
|
312
334
|
- `market_id` or list of market IDs
|
|
@@ -145,6 +145,10 @@ fills = client.fills(
|
|
|
145
145
|
Use a market selector or a bounded time range when querying fills. This keeps
|
|
146
146
|
queries fast and avoids scanning more data than you need.
|
|
147
147
|
|
|
148
|
+
`start_time` / `end_time` filter `timestamp` (the exchange time) on `fills` and
|
|
149
|
+
`orderbook_snapshots`, and `created_at` on `markets` — a market created months
|
|
150
|
+
ago still returns today's fills.
|
|
151
|
+
|
|
148
152
|
Filter by participant or taker side:
|
|
149
153
|
|
|
150
154
|
```python
|
|
@@ -190,9 +194,16 @@ Each snapshot is a complete replacement book for one outcome. Rows include
|
|
|
190
194
|
`indexed_at`, `hash`, `state`, `continuity`, and `path_index` in addition to the
|
|
191
195
|
market identifiers, outcome, bids, asks, and source timestamp.
|
|
192
196
|
|
|
193
|
-
|
|
194
|
-
`
|
|
195
|
-
|
|
197
|
+
`state` is `VERIFIED` or `INTERMEDIATE`. `continuity` is `CONTIGUOUS` (the
|
|
198
|
+
transition from the previous book was provable), `RESET` (it was not — the first
|
|
199
|
+
state of a book is deliberately `RESET`), or `UNKNOWN` for rows predating
|
|
200
|
+
continuity tracking. Several distinct states can share one millisecond; `hash`
|
|
201
|
+
separates them and `path_index` orders them within a recovered path.
|
|
202
|
+
|
|
203
|
+
Note that these columns were added to the warehouse in August 2026. Rows written
|
|
204
|
+
before then read the column default rather than a measured value: `hash` is 0
|
|
205
|
+
before 2026-08-02, `state` reads `VERIFIED` before 2026-08-21, and `continuity`
|
|
206
|
+
reads `UNKNOWN` before 2026-08-22.
|
|
196
207
|
|
|
197
208
|
## Choose Polars or pandas
|
|
198
209
|
|
|
@@ -228,6 +239,8 @@ Use `query()` for read-only ClickHouse queries when the convenience methods do
|
|
|
228
239
|
not cover your use case.
|
|
229
240
|
|
|
230
241
|
```python
|
|
242
|
+
from datetime import datetime, timezone
|
|
243
|
+
|
|
231
244
|
df = client.query(
|
|
232
245
|
"""
|
|
233
246
|
SELECT platform, count() AS fills
|
|
@@ -236,15 +249,24 @@ df = client.query(
|
|
|
236
249
|
GROUP BY platform
|
|
237
250
|
ORDER BY fills DESC
|
|
238
251
|
""",
|
|
239
|
-
parameters={"start_time":
|
|
252
|
+
parameters={"start_time": datetime(2026, 3, 15, tzinfo=timezone.utc)},
|
|
240
253
|
)
|
|
241
254
|
```
|
|
242
255
|
|
|
243
256
|
Always pass user-provided values through `parameters` instead of formatting them
|
|
244
257
|
directly into SQL strings.
|
|
245
258
|
|
|
259
|
+
Unlike the convenience methods, `query()` passes parameters straight to
|
|
260
|
+
ClickHouse — it does not parse date strings for you. Pass a `datetime`, or a
|
|
261
|
+
string ClickHouse accepts such as `"2026-03-15 00:00:00"`. An ISO string with a
|
|
262
|
+
trailing `Z` is rejected by the server.
|
|
263
|
+
|
|
246
264
|
## Supported Filters
|
|
247
265
|
|
|
266
|
+
The convenience methods return at most `limit` rows, and **`limit` defaults to 1000**.
|
|
267
|
+
Raise it explicitly when you want more than that — results are truncated
|
|
268
|
+
silently, not flagged.
|
|
269
|
+
|
|
248
270
|
`markets()` and `markets_frame()` support:
|
|
249
271
|
|
|
250
272
|
- `start_time`
|
|
@@ -271,8 +293,8 @@ directly into SQL strings.
|
|
|
271
293
|
|
|
272
294
|
`orderbook_snapshots()` supports:
|
|
273
295
|
|
|
274
|
-
- `start_time`
|
|
275
|
-
- `end_time`
|
|
296
|
+
- `start_time` (**required**)
|
|
297
|
+
- `end_time` (**required**)
|
|
276
298
|
- `platform` or list of platforms
|
|
277
299
|
- `market`
|
|
278
300
|
- `market_id` or list of market IDs
|
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import time
|
|
5
|
+
from datetime import datetime, timezone
|
|
5
6
|
|
|
6
7
|
import pandas as pd
|
|
7
8
|
import polars as pl
|
|
@@ -58,7 +59,6 @@ def client(clickhouse_config) -> ProbalyticsClient:
|
|
|
58
59
|
password=PASSWORD,
|
|
59
60
|
database=DATABASE,
|
|
60
61
|
secure=False,
|
|
61
|
-
compression=False,
|
|
62
62
|
frame="pandas",
|
|
63
63
|
)
|
|
64
64
|
|
|
@@ -82,6 +82,21 @@ def test_sample_data_matches_production_shapes(client: ProbalyticsClient) -> Non
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
|
|
85
|
+
@pytest.mark.parametrize(
|
|
86
|
+
"start_time",
|
|
87
|
+
[datetime(2026, 3, 15, tzinfo=timezone.utc), "2026-03-15 00:00:00"],
|
|
88
|
+
)
|
|
89
|
+
def test_query_accepts_documented_time_parameters(
|
|
90
|
+
client: ProbalyticsClient, start_time: datetime | str
|
|
91
|
+
) -> None:
|
|
92
|
+
result = client.query(
|
|
93
|
+
"SELECT count() AS rows FROM fills WHERE timestamp >= %(start_time)s",
|
|
94
|
+
parameters={"start_time": start_time},
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
assert result["rows"].iloc[0] == len(FILL_ROWS)
|
|
98
|
+
|
|
99
|
+
|
|
85
100
|
def test_markets_filters_accept_arrays_against_clickhouse(client: ProbalyticsClient) -> None:
|
|
86
101
|
markets = client.markets(
|
|
87
102
|
market_id=[MARKET_A, MARKET_B],
|
|
@@ -72,7 +72,8 @@ def test_public_enums_only_include_current_values() -> None:
|
|
|
72
72
|
MarketType("UNKNOWN")
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
@pytest.mark.parametrize("continuity", ["RESET", "CONTIGUOUS", "UNKNOWN"])
|
|
76
|
+
def test_orderbook_snapshot_models_current_quality_fields(continuity: str) -> None:
|
|
76
77
|
snapshot = OrderbookSnapshot.model_validate(
|
|
77
78
|
{
|
|
78
79
|
"market_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
@@ -90,13 +91,13 @@ def test_orderbook_snapshot_models_current_quality_fields() -> None:
|
|
|
90
91
|
"indexed_at": "2026-03-15T00:00:00.001Z",
|
|
91
92
|
"hash": 101,
|
|
92
93
|
"state": "VERIFIED",
|
|
93
|
-
"continuity":
|
|
94
|
+
"continuity": continuity,
|
|
94
95
|
"path_index": 0,
|
|
95
96
|
}
|
|
96
97
|
)
|
|
97
98
|
|
|
98
99
|
assert snapshot.state == "VERIFIED"
|
|
99
|
-
assert snapshot.continuity ==
|
|
100
|
+
assert snapshot.continuity == continuity
|
|
100
101
|
assert snapshot.hash == 101
|
|
101
102
|
assert snapshot.path_index == 0
|
|
102
103
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|