immix-datasets 0.1.0rc1__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,48 @@
1
+ # Changelog
2
+
3
+ What changes from one version of `immix_datasets`, the Python client of Immix Datasets, to the
4
+ next, for the code that calls it. Newest first, each heading a version as PyPI names it. Before
5
+ `1.0.0` a version may remove or rename what an earlier one had, and its section says so where it
6
+ does.
7
+
8
+ ## 0.1.0rc1 — The first release candidate
9
+
10
+ The client's first version. It reads the catalogue, downloads files to disk, and loads them into
11
+ pandas data frames. It needs Python 3.11 or newer and one dependency, `httpx`. The `pandas` extra,
12
+ `pip install "immix_datasets[pandas]"`, adds pandas 2.2 or newer and pyarrow 18 or newer, which
13
+ `load` and `instruments` need.
14
+
15
+ - **`Datasets`, the client.** Its key is `api_key`, or `IMMIX_DATASETS_API_KEY`. The key is sent
16
+ to the service alone, over `https`: a file is fetched from storage by a signed link, with a
17
+ session that holds no key, and neither the key nor a link is logged. A client holds
18
+ connections: close it, or use it as a context manager.
19
+ - **The catalogue, never counted against the plan.** `coverage()` lists each exchange in brief,
20
+ and `coverage(exchange)` gives an exchange in full: each closed day's status, and each family's
21
+ symbols with their first and last day and their bytes. `manifest(exchange, day)` gives a closed
22
+ day's files, each with its size, row count and SHA-256, and the gaps and failed hours the day
23
+ does not cover. `usage()` gives the month's bytes and files against the plan, for every key of
24
+ the account.
25
+ - **`download`, to disk.** One family or several, some symbols, a range of days: each file is
26
+ checked against its manifest's SHA-256 before it takes its name, and counted against the plan
27
+ when it is asked for, whole. It syncs: run again, it asks only for what is missing. A day under
28
+ repair is set aside and asked for again for up to `repair_wait`. A download the plan cannot take
29
+ is refused before any of it is counted.
30
+ - **Where the files are kept.** In one directory, said when the client is made: `download_dir`,
31
+ or `IMMIX_DATASETS_DOWNLOAD_DIR`, or `~/immix_datasets`. A file is kept under its key in the
32
+ dataset, which holds the first 12 hex digits of its SHA-256, and is believed on its size when a
33
+ download is run again. `get_filename` names the files another way, as Tardis's client takes
34
+ one: a function of a file's exchange, family, day, symbol and format, given the hash as well
35
+ where it takes a sixth argument.
36
+ - **`load`, into pandas.** One family's rows for some symbols over a range of days, as one data
37
+ frame, from the files in the directory, fetching what is not there first. Each column is the
38
+ type the file contract gives it: a time is `datetime64[ns, UTC]`, and a price, an amount or a
39
+ rate an exact decimal, unless `decimals="float"`. The range's gaps are on
40
+ `frame.attrs["gaps"]`, and a frame with any is warned of with `GapsWarning`.
41
+ - **`gaps` and `instruments`.** `gaps` reads a range's gaps from its manifests without fetching a
42
+ file. `instruments(exchange, day)` is the day's instruments, with each one's names, scales and
43
+ terms, as a data frame. Neither is counted.
44
+ - **Errors.** A refusal of the service's is `ApiError`, with its `code`, and
45
+ `BudgetExhaustedError` where the month's bytes are spent. `download` adds three of its own:
46
+ `OverBudgetError` before anything is counted, `DaysUnavailableError` once every other day's
47
+ files are in place, and `CorruptFileError`. `TransportError` is a service that could not be
48
+ reached, and `UnexpectedResponseError` an answer the client does not understand.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Coinstrats Ltd (IMMIX)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: immix_datasets
3
+ Version: 0.1.0rc1
4
+ Summary: The Python client for Immix Datasets — historical market data as files
5
+ Keywords: immix,market data,historical data,datasets,crypto
6
+ Author: Immix
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Financial and Insurance Industry
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Typing :: Typed
18
+ Requires-Dist: httpx>=0.28,<1
19
+ Requires-Dist: pandas>=2.2,<4 ; extra == 'pandas'
20
+ Requires-Dist: pyarrow>=18 ; extra == 'pandas'
21
+ Requires-Python: >=3.11
22
+ Project-URL: Documentation, https://docs.immix.xyz
23
+ Project-URL: Homepage, https://immix.xyz
24
+ Provides-Extra: pandas
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Immix Datasets — Python client
28
+
29
+ `immix_datasets` is the Python client for Immix Datasets: historical market data as files (trades,
30
+ quotes, order books and derivatives data), one file per family, exchange, day and symbol.
31
+
32
+ **Until `0.1.0` its releases are release candidates**, which `pip` installs when asked for them:
33
+
34
+ ```bash
35
+ pip install --pre immix_datasets
36
+ ```
37
+
38
+ What each version changes is in `CHANGELOG.md`, which the source distribution carries.
39
+
40
+ Today it reads the catalogue (what the dataset holds, a day's files, what an account has used),
41
+ downloads files to disk, and loads them into pandas data frames.
42
+
43
+ ```python
44
+ from immix_datasets import Datasets
45
+
46
+ with Datasets() as data: # the key comes from IMMIX_DATASETS_API_KEY
47
+ for exchange in data.coverage():
48
+ print(exchange.exchange, exchange.first_day, exchange.published_through, exchange.families)
49
+
50
+ okx = data.coverage("OKX") # each closed day, and each family's symbols
51
+ day = data.manifest("OKX", okx.published_through) # the day's files, gaps and failed hours
52
+ for file in day.files:
53
+ print(file.family, file.symbol, file.rows, file.bytes, file.sha256)
54
+
55
+ # A week of trades and quotes for two symbols, to disk: to_day is the day after the last.
56
+ paths = data.download("OKX", ["trades", "quotes"], ["BTC/USDT", "ETH/USDT"], "2026-11-01", "2026-11-08")
57
+
58
+ # The week's trades as one pandas data frame, read from those files: nothing is fetched twice.
59
+ trades = data.load("OKX", "trades", ["BTC/USDT", "ETH/USDT"], "2026-11-01", "2026-11-08")
60
+
61
+ usage = data.usage() # this month's bytes against the plan
62
+ print(usage.bytes, usage.monthly_bytes, usage.remaining_bytes)
63
+ ```
64
+
65
+ A call the service refuses raises `ApiError`, which carries the service's `code`
66
+ (`DAY_NOT_PUBLISHED`, `DAY_UNDER_REPAIR`, ...), its message and the request id to quote to support.
67
+
68
+ ## Where the files are kept
69
+
70
+ A client keeps its files in one directory. It is said once, when the client is made, and not to
71
+ each call:
72
+
73
+ ```python
74
+ Datasets() # ~/immix_datasets
75
+ Datasets(download_dir="/data/immix") # or set IMMIX_DATASETS_DOWNLOAD_DIR=/data/immix
76
+ ```
77
+
78
+ - **Unless told otherwise it is `immix_datasets` in your home directory**: `~/immix_datasets`, on
79
+ Linux and macOS alike. It does not depend on where a script is run from, so the same script run
80
+ from another directory finds the files it fetched before. `data.download_dir` says where it is.
81
+ - **`download`, `load` and `instruments` all keep their files there**, and look there before
82
+ asking the service for one. A range that was downloaded is loaded from disk.
83
+ - **A leading `~` is your home directory**, and a relative path is taken from where the client was
84
+ made. The directory is made when the first file is put in it.
85
+
86
+ ### How the files are named
87
+
88
+ Inside the directory a file is kept under its key in the dataset, which holds the first 12 hex
89
+ digits of its SHA-256:
90
+
91
+ ```
92
+ trades/OKX/2026-11-01/BTC-USDT.55b1844a9178.csv.gz
93
+ ```
94
+
95
+ - **A file is never anything but the bytes its name says.** A result can name the files it was
96
+ computed from, and they will not change under it.
97
+ - **A file in place is believed without being hashed again.** It took its name only once its hash
98
+ was checked, so a download run again compares sizes and reads nothing.
99
+ - **A repaired day's file arrives beside the one it replaces**, which stays. The paths `download`
100
+ returns, and the rows `load` reads, are the dataset's as it is now: read those, and not a
101
+ pattern such as `BTC-USDT.*.csv.gz`, which matches both.
102
+
103
+ To name the files another way, give the client a `get_filename`, as Tardis's client takes one: a
104
+ function of the file's exchange, family, day, symbol and format, in that order, that returns a
105
+ path relative to the directory. A function that takes a sixth argument is given the file's hash
106
+ too, those 12 digits.
107
+
108
+ ```python
109
+ def flat(exchange, family, day, symbol, format, hash):
110
+ # OKX_trades_2026-11-01_BTC-USDT.55b1844a9178.csv.gz
111
+ return f"{exchange}_{family}_{day}_{symbol}.{hash}.{format}.gz"
112
+
113
+
114
+ def by_symbol(exchange, family, day, symbol, format, hash):
115
+ # OKX/BTC-USDT/trades/2026-11-01.55b1844a9178.csv.gz
116
+ return f"{exchange}/{symbol}/{family}/{day}.{hash}.{format}.gz"
117
+
118
+
119
+ def without_the_hash(exchange, family, day, symbol, format): # Tardis's five arguments
120
+ # trades/OKX/2026-11-01/BTC-USDT.csv.gz
121
+ return f"{family}/{exchange}/{day}/{symbol}.{format}.gz"
122
+
123
+
124
+ with Datasets(download_dir="/data/immix", get_filename=flat) as data:
125
+ data.download("OKX", ["trades"], ["BTC/USDT"], "2026-11-01", "2026-11-08")
126
+ ```
127
+
128
+ The day is a `datetime.date`. The symbol is as a file name spells it, `BTC-USDT` for `BTC/USDT` and
129
+ `BTC-USDT_USDT` for `BTC/USDT:USDT`, so it is one name with no `/` in it. The format is `csv`, and
130
+ the files are gzipped: the function adds `.gz`. A function written for Tardis's `get_filename`
131
+ works as it is.
132
+
133
+ A name that holds the hash is believed as the key is. One without it can be had, and costs two
134
+ things: a download run again reads every file in place to hash it, and a repaired day's file takes
135
+ the old one's place, so a path no longer says which bytes it holds. A name outside the directory,
136
+ or one two files share, is refused before anything is counted. A day's instruments file is not a
137
+ data file and is not named this way: it sits at `instruments/OKX/2026-11-01.csv`.
138
+
139
+ ## Downloading
140
+
141
+ `download` puts files on disk, and is the way to have a large range of data locally. It reads
142
+ nothing into memory and needs neither pandas nor pyarrow.
143
+
144
+ ```python
145
+ from immix_datasets import Datasets, DaysUnavailableError
146
+
147
+ with Datasets() as data:
148
+ try:
149
+ paths = data.download(
150
+ "OKX",
151
+ ["trades", "quotes", "book_snapshot_25"], # one family, or several
152
+ ["BTC/USDT", "ETH/USDT"],
153
+ "2026-01-01",
154
+ "2026-11-08", # the day after the last
155
+ )
156
+ except DaysUnavailableError as missing:
157
+ print(missing.days, [missing.refusals[day].code for day in missing.days])
158
+ paths = missing.paths
159
+ ```
160
+
161
+ - **It syncs.** A download run again asks only for what is missing, so the same call brings a
162
+ directory up to date each day, and finishes one that was interrupted. A file in place is left
163
+ alone, and the file of a day repaired since is fetched.
164
+ - **A file in place is complete.** Every file is checked against the SHA-256 its day's manifest
165
+ gives before it takes its name.
166
+ - **A file is counted when it is asked for, whole.** A download that needs more bytes than the
167
+ plan has left this month is refused before any of those bytes is counted (`OverBudgetError`).
168
+ The plan is checked again when a day that was under repair comes to be served: refused then, the
169
+ files fetched before are in place and were counted.
170
+ - **A day that cannot be served yet does not stop the others.** A day under repair is set aside
171
+ and asked for again each minute, for up to `repair_wait` (two hours unless told otherwise). Days
172
+ still missing then, and days not published yet, are named by `DaysUnavailableError`, which also
173
+ carries the paths of the files that were fetched.
174
+ - **A symbol with no file is warned about.** A file exists only for a day its symbol had rows, so
175
+ fewer files than days is ordinary. A family's symbol with no file on any day of the range is
176
+ what a misspelt one looks like, and `coverage("OKX")` lists each family's symbols as they are
177
+ written.
178
+
179
+ `concurrency` is how many files are fetched at a time, five unless told otherwise. The client
180
+ logs to the `immix_datasets` logger: each file fetched at `INFO`, and the first wait for a day
181
+ that cannot be served yet at `WARNING`.
182
+
183
+ ## Loading into pandas
184
+
185
+ `load` returns one family's rows for some symbols over a range of days as one pandas data frame.
186
+ It needs pandas and pyarrow, which the package does not install unless asked:
187
+
188
+ ```bash
189
+ pip install "immix_datasets[pandas]"
190
+ ```
191
+
192
+ ```python
193
+ from immix_datasets import Datasets
194
+
195
+ with Datasets() as data:
196
+ trades = data.load("OKX", "trades", ["BTC/USDT"], "2026-11-01", "2026-11-08")
197
+ instruments = data.instruments("OKX", "2026-11-01") # the day's instruments; never counted
198
+
199
+ notional = (trades["price"] * trades["amount"]).sum() # exact: a Decimal
200
+ by_minute = trades.set_index("timestamp")["amount"].resample("1min").sum()
201
+ ```
202
+
203
+ - **It has its files as `download` has them**, in the same directory, with the same counting and
204
+ the same errors. Files that are there are read from disk; the rest are fetched first, and kept.
205
+ A range loaded again asks the service for no file and counts nothing.
206
+ - **Each column is the type the file contract gives it**, and nothing is guessed from the cells. A
207
+ time is `datetime64[ns, UTC]`, exact to the nanosecond, and `NaT` where the file has none. A
208
+ whole number is `int64`, or `Int64` where it can be missing. A name (`symbol`, `side`) is a
209
+ `category`.
210
+ - **A price, an amount or a rate is an exact decimal**: an Arrow `decimal128(18, scale)` at the
211
+ digits the file is written with, whose cells read as Python `Decimal`s. Two such columns add,
212
+ subtract, multiply, divide, compare, sort and sum with no rounding. Exact decimals do not do
213
+ everything a float does: `cumsum`, `describe` and `resample(...).ohlc()` refuse them, so does a
214
+ product of three columns, and `mean` is rounded to the column's digits. A sum by group or by
215
+ time can be 38 digits wide, the most an exact decimal holds, and Arrow refuses arithmetic that
216
+ would take it past that: take a quotient of two such sums, such as a VWAP, in floats. Pass
217
+ `decimals="float"` to read those columns as `float64` instead, or convert one with
218
+ `.astype("float64")`.
219
+ - **The range's gaps come with the frame.** A gap is a time the dataset was not watching, which a
220
+ frame cannot show: the rows either side of it look adjacent. `frame.attrs["gaps"]` lists the
221
+ gaps for the family and the symbols asked for, and a frame with any is warned of with
222
+ `GapsWarning`. `data.gaps(...)`, with the same arguments, reads them without fetching a file.
223
+ - **A frame holds its whole range in memory.** A busy symbol's day of `book_snapshot_25` is about
224
+ 1.2 GB as exact decimals and 0.6 GB as floats: load a long range a day at a time, or `download`
225
+ it and read the files with whatever suits them.
226
+ - **Rows are in the files' order**: by day, then as the symbols were asked for, and within a file
227
+ in the order of the stream. `frame.sort_values("global_sequence", kind="stable")` puts several
228
+ symbols' rows in the stream's one order.
229
+
230
+ ## What it needs
231
+
232
+ Python 3.11 or newer, and one dependency, `httpx`. Data frames need pandas 2.2 or newer and pyarrow
233
+ 18 or newer, which the `pandas` extra installs. It does not need the trading SDK, `immix_sdk`:
234
+ Datasets is a product of its own, with its own keys.
235
+
236
+ ## Developing
237
+
238
+ ```bash
239
+ uv sync
240
+ uv run pytest -q
241
+ ```
242
+
243
+ `DEVELOPING.md`, beside this file in the repository, has the rest: how the repository changes, how
244
+ a version ships, and the decisions the client is built to. Beside it, `examples/` holds a script for
245
+ each recipe of the cookbook, and `notebooks/` a week of trades and quotes run against the service.
@@ -0,0 +1,219 @@
1
+ # Immix Datasets — Python client
2
+
3
+ `immix_datasets` is the Python client for Immix Datasets: historical market data as files (trades,
4
+ quotes, order books and derivatives data), one file per family, exchange, day and symbol.
5
+
6
+ **Until `0.1.0` its releases are release candidates**, which `pip` installs when asked for them:
7
+
8
+ ```bash
9
+ pip install --pre immix_datasets
10
+ ```
11
+
12
+ What each version changes is in `CHANGELOG.md`, which the source distribution carries.
13
+
14
+ Today it reads the catalogue (what the dataset holds, a day's files, what an account has used),
15
+ downloads files to disk, and loads them into pandas data frames.
16
+
17
+ ```python
18
+ from immix_datasets import Datasets
19
+
20
+ with Datasets() as data: # the key comes from IMMIX_DATASETS_API_KEY
21
+ for exchange in data.coverage():
22
+ print(exchange.exchange, exchange.first_day, exchange.published_through, exchange.families)
23
+
24
+ okx = data.coverage("OKX") # each closed day, and each family's symbols
25
+ day = data.manifest("OKX", okx.published_through) # the day's files, gaps and failed hours
26
+ for file in day.files:
27
+ print(file.family, file.symbol, file.rows, file.bytes, file.sha256)
28
+
29
+ # A week of trades and quotes for two symbols, to disk: to_day is the day after the last.
30
+ paths = data.download("OKX", ["trades", "quotes"], ["BTC/USDT", "ETH/USDT"], "2026-11-01", "2026-11-08")
31
+
32
+ # The week's trades as one pandas data frame, read from those files: nothing is fetched twice.
33
+ trades = data.load("OKX", "trades", ["BTC/USDT", "ETH/USDT"], "2026-11-01", "2026-11-08")
34
+
35
+ usage = data.usage() # this month's bytes against the plan
36
+ print(usage.bytes, usage.monthly_bytes, usage.remaining_bytes)
37
+ ```
38
+
39
+ A call the service refuses raises `ApiError`, which carries the service's `code`
40
+ (`DAY_NOT_PUBLISHED`, `DAY_UNDER_REPAIR`, ...), its message and the request id to quote to support.
41
+
42
+ ## Where the files are kept
43
+
44
+ A client keeps its files in one directory. It is said once, when the client is made, and not to
45
+ each call:
46
+
47
+ ```python
48
+ Datasets() # ~/immix_datasets
49
+ Datasets(download_dir="/data/immix") # or set IMMIX_DATASETS_DOWNLOAD_DIR=/data/immix
50
+ ```
51
+
52
+ - **Unless told otherwise it is `immix_datasets` in your home directory**: `~/immix_datasets`, on
53
+ Linux and macOS alike. It does not depend on where a script is run from, so the same script run
54
+ from another directory finds the files it fetched before. `data.download_dir` says where it is.
55
+ - **`download`, `load` and `instruments` all keep their files there**, and look there before
56
+ asking the service for one. A range that was downloaded is loaded from disk.
57
+ - **A leading `~` is your home directory**, and a relative path is taken from where the client was
58
+ made. The directory is made when the first file is put in it.
59
+
60
+ ### How the files are named
61
+
62
+ Inside the directory a file is kept under its key in the dataset, which holds the first 12 hex
63
+ digits of its SHA-256:
64
+
65
+ ```
66
+ trades/OKX/2026-11-01/BTC-USDT.55b1844a9178.csv.gz
67
+ ```
68
+
69
+ - **A file is never anything but the bytes its name says.** A result can name the files it was
70
+ computed from, and they will not change under it.
71
+ - **A file in place is believed without being hashed again.** It took its name only once its hash
72
+ was checked, so a download run again compares sizes and reads nothing.
73
+ - **A repaired day's file arrives beside the one it replaces**, which stays. The paths `download`
74
+ returns, and the rows `load` reads, are the dataset's as it is now: read those, and not a
75
+ pattern such as `BTC-USDT.*.csv.gz`, which matches both.
76
+
77
+ To name the files another way, give the client a `get_filename`, as Tardis's client takes one: a
78
+ function of the file's exchange, family, day, symbol and format, in that order, that returns a
79
+ path relative to the directory. A function that takes a sixth argument is given the file's hash
80
+ too, those 12 digits.
81
+
82
+ ```python
83
+ def flat(exchange, family, day, symbol, format, hash):
84
+ # OKX_trades_2026-11-01_BTC-USDT.55b1844a9178.csv.gz
85
+ return f"{exchange}_{family}_{day}_{symbol}.{hash}.{format}.gz"
86
+
87
+
88
+ def by_symbol(exchange, family, day, symbol, format, hash):
89
+ # OKX/BTC-USDT/trades/2026-11-01.55b1844a9178.csv.gz
90
+ return f"{exchange}/{symbol}/{family}/{day}.{hash}.{format}.gz"
91
+
92
+
93
+ def without_the_hash(exchange, family, day, symbol, format): # Tardis's five arguments
94
+ # trades/OKX/2026-11-01/BTC-USDT.csv.gz
95
+ return f"{family}/{exchange}/{day}/{symbol}.{format}.gz"
96
+
97
+
98
+ with Datasets(download_dir="/data/immix", get_filename=flat) as data:
99
+ data.download("OKX", ["trades"], ["BTC/USDT"], "2026-11-01", "2026-11-08")
100
+ ```
101
+
102
+ The day is a `datetime.date`. The symbol is as a file name spells it, `BTC-USDT` for `BTC/USDT` and
103
+ `BTC-USDT_USDT` for `BTC/USDT:USDT`, so it is one name with no `/` in it. The format is `csv`, and
104
+ the files are gzipped: the function adds `.gz`. A function written for Tardis's `get_filename`
105
+ works as it is.
106
+
107
+ A name that holds the hash is believed as the key is. One without it can be had, and costs two
108
+ things: a download run again reads every file in place to hash it, and a repaired day's file takes
109
+ the old one's place, so a path no longer says which bytes it holds. A name outside the directory,
110
+ or one two files share, is refused before anything is counted. A day's instruments file is not a
111
+ data file and is not named this way: it sits at `instruments/OKX/2026-11-01.csv`.
112
+
113
+ ## Downloading
114
+
115
+ `download` puts files on disk, and is the way to have a large range of data locally. It reads
116
+ nothing into memory and needs neither pandas nor pyarrow.
117
+
118
+ ```python
119
+ from immix_datasets import Datasets, DaysUnavailableError
120
+
121
+ with Datasets() as data:
122
+ try:
123
+ paths = data.download(
124
+ "OKX",
125
+ ["trades", "quotes", "book_snapshot_25"], # one family, or several
126
+ ["BTC/USDT", "ETH/USDT"],
127
+ "2026-01-01",
128
+ "2026-11-08", # the day after the last
129
+ )
130
+ except DaysUnavailableError as missing:
131
+ print(missing.days, [missing.refusals[day].code for day in missing.days])
132
+ paths = missing.paths
133
+ ```
134
+
135
+ - **It syncs.** A download run again asks only for what is missing, so the same call brings a
136
+ directory up to date each day, and finishes one that was interrupted. A file in place is left
137
+ alone, and the file of a day repaired since is fetched.
138
+ - **A file in place is complete.** Every file is checked against the SHA-256 its day's manifest
139
+ gives before it takes its name.
140
+ - **A file is counted when it is asked for, whole.** A download that needs more bytes than the
141
+ plan has left this month is refused before any of those bytes is counted (`OverBudgetError`).
142
+ The plan is checked again when a day that was under repair comes to be served: refused then, the
143
+ files fetched before are in place and were counted.
144
+ - **A day that cannot be served yet does not stop the others.** A day under repair is set aside
145
+ and asked for again each minute, for up to `repair_wait` (two hours unless told otherwise). Days
146
+ still missing then, and days not published yet, are named by `DaysUnavailableError`, which also
147
+ carries the paths of the files that were fetched.
148
+ - **A symbol with no file is warned about.** A file exists only for a day its symbol had rows, so
149
+ fewer files than days is ordinary. A family's symbol with no file on any day of the range is
150
+ what a misspelt one looks like, and `coverage("OKX")` lists each family's symbols as they are
151
+ written.
152
+
153
+ `concurrency` is how many files are fetched at a time, five unless told otherwise. The client
154
+ logs to the `immix_datasets` logger: each file fetched at `INFO`, and the first wait for a day
155
+ that cannot be served yet at `WARNING`.
156
+
157
+ ## Loading into pandas
158
+
159
+ `load` returns one family's rows for some symbols over a range of days as one pandas data frame.
160
+ It needs pandas and pyarrow, which the package does not install unless asked:
161
+
162
+ ```bash
163
+ pip install "immix_datasets[pandas]"
164
+ ```
165
+
166
+ ```python
167
+ from immix_datasets import Datasets
168
+
169
+ with Datasets() as data:
170
+ trades = data.load("OKX", "trades", ["BTC/USDT"], "2026-11-01", "2026-11-08")
171
+ instruments = data.instruments("OKX", "2026-11-01") # the day's instruments; never counted
172
+
173
+ notional = (trades["price"] * trades["amount"]).sum() # exact: a Decimal
174
+ by_minute = trades.set_index("timestamp")["amount"].resample("1min").sum()
175
+ ```
176
+
177
+ - **It has its files as `download` has them**, in the same directory, with the same counting and
178
+ the same errors. Files that are there are read from disk; the rest are fetched first, and kept.
179
+ A range loaded again asks the service for no file and counts nothing.
180
+ - **Each column is the type the file contract gives it**, and nothing is guessed from the cells. A
181
+ time is `datetime64[ns, UTC]`, exact to the nanosecond, and `NaT` where the file has none. A
182
+ whole number is `int64`, or `Int64` where it can be missing. A name (`symbol`, `side`) is a
183
+ `category`.
184
+ - **A price, an amount or a rate is an exact decimal**: an Arrow `decimal128(18, scale)` at the
185
+ digits the file is written with, whose cells read as Python `Decimal`s. Two such columns add,
186
+ subtract, multiply, divide, compare, sort and sum with no rounding. Exact decimals do not do
187
+ everything a float does: `cumsum`, `describe` and `resample(...).ohlc()` refuse them, so does a
188
+ product of three columns, and `mean` is rounded to the column's digits. A sum by group or by
189
+ time can be 38 digits wide, the most an exact decimal holds, and Arrow refuses arithmetic that
190
+ would take it past that: take a quotient of two such sums, such as a VWAP, in floats. Pass
191
+ `decimals="float"` to read those columns as `float64` instead, or convert one with
192
+ `.astype("float64")`.
193
+ - **The range's gaps come with the frame.** A gap is a time the dataset was not watching, which a
194
+ frame cannot show: the rows either side of it look adjacent. `frame.attrs["gaps"]` lists the
195
+ gaps for the family and the symbols asked for, and a frame with any is warned of with
196
+ `GapsWarning`. `data.gaps(...)`, with the same arguments, reads them without fetching a file.
197
+ - **A frame holds its whole range in memory.** A busy symbol's day of `book_snapshot_25` is about
198
+ 1.2 GB as exact decimals and 0.6 GB as floats: load a long range a day at a time, or `download`
199
+ it and read the files with whatever suits them.
200
+ - **Rows are in the files' order**: by day, then as the symbols were asked for, and within a file
201
+ in the order of the stream. `frame.sort_values("global_sequence", kind="stable")` puts several
202
+ symbols' rows in the stream's one order.
203
+
204
+ ## What it needs
205
+
206
+ Python 3.11 or newer, and one dependency, `httpx`. Data frames need pandas 2.2 or newer and pyarrow
207
+ 18 or newer, which the `pandas` extra installs. It does not need the trading SDK, `immix_sdk`:
208
+ Datasets is a product of its own, with its own keys.
209
+
210
+ ## Developing
211
+
212
+ ```bash
213
+ uv sync
214
+ uv run pytest -q
215
+ ```
216
+
217
+ `DEVELOPING.md`, beside this file in the repository, has the rest: how the repository changes, how
218
+ a version ships, and the decisions the client is built to. Beside it, `examples/` holds a script for
219
+ each recipe of the cookbook, and `notebooks/` a week of trades and quotes run against the service.
@@ -0,0 +1,89 @@
1
+ [project]
2
+ name = "immix_datasets"
3
+ version = "0.1.0rc1"
4
+ description = "The Python client for Immix Datasets — historical market data as files"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ keywords = [
10
+ "immix",
11
+ "market data",
12
+ "historical data",
13
+ "datasets",
14
+ "crypto",
15
+ ]
16
+ classifiers = [
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Financial and Insurance Industry",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Typing :: Typed",
26
+ ]
27
+ dependencies = ["httpx>=0.28,<1"]
28
+
29
+ [[project.authors]]
30
+ name = "Immix"
31
+
32
+ [project.optional-dependencies]
33
+ pandas = [
34
+ "pandas>=2.2,<4",
35
+ "pyarrow>=18",
36
+ ]
37
+
38
+ [project.urls]
39
+ Documentation = "https://docs.immix.xyz"
40
+ Homepage = "https://immix.xyz"
41
+
42
+ [dependency-groups]
43
+ dev = [
44
+ "immix_datasets[pandas]",
45
+ "mypy>=1.13",
46
+ "pytest>=9.0.3,<10",
47
+ "ruff>=0.11.5",
48
+ ]
49
+
50
+ [build-system]
51
+ requires = ["uv_build>=0.12.1,<0.13.0"]
52
+ build-backend = "uv_build"
53
+
54
+ [tool.uv.build-backend]
55
+ source-include = ["CHANGELOG.md"]
56
+
57
+ [tool.pytest.ini_options]
58
+ testpaths = ["tests"]
59
+ addopts = "-m 'not live'"
60
+ markers = ["live: calls a deployed Datasets service; needs IMMIX_DATASETS_API_KEY, and never runs in CI"]
61
+
62
+ [tool.mypy]
63
+ strict = true
64
+ files = [
65
+ "src",
66
+ "tests",
67
+ "examples",
68
+ ]
69
+
70
+ [[tool.mypy.overrides]]
71
+ module = [
72
+ "pandas",
73
+ "pandas.*",
74
+ "pyarrow",
75
+ "pyarrow.*",
76
+ ]
77
+ ignore_missing_imports = true
78
+
79
+ [tool.ruff]
80
+ line-length = 120
81
+
82
+ [tool.ruff.lint]
83
+ select = [
84
+ "E",
85
+ "F",
86
+ "I",
87
+ "B",
88
+ "UP",
89
+ ]