tt-data-store 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,185 @@
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, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
75
+ to which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
87
+ this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that You
90
+ changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the
102
+ Derivative Works; within the Source form or documentation, if provided along
103
+ with the Derivative Works; or, within a display generated by the Derivative
104
+ Works, if and wherever such third-party notices normally appear. The contents of
105
+ the NOTICE file are for informational purposes only and do not modify the
106
+ License. You may add Your own attribution notices within Derivative Works that
107
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
108
+ provided that such additional attribution notices cannot be construed as
109
+ modifying the License.
110
+
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
118
+ Contribution intentionally submitted for inclusion in the Work by You to the
119
+ Licensor shall be under the terms and conditions of this License, without any
120
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
121
+ supersede or modify the terms of any separate license agreement you may have
122
+ executed with Licensor regarding such Contributions.
123
+
124
+ 6. Trademarks. This License does not grant permission to use the trade names,
125
+ trademarks, service marks, or product names of the Licensor, except as required
126
+ for reasonable and customary use in describing the origin of the Work and
127
+ reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
130
+ writing, Licensor provides the Work (and each Contributor provides its
131
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
132
+ KIND, either express or implied, including, without limitation, any warranties
133
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
134
+ PARTICULAR PURPOSE. You are solely responsible for determining the
135
+ appropriateness of using or redistributing the Work and assume any risks
136
+ associated with Your exercise of permissions under this License.
137
+
138
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
139
+ tort (including negligence), contract, or otherwise, unless required by
140
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any character
143
+ arising as a result of this License or out of the use or inability to use the
144
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
145
+ computer failure or malfunction, or any and all other commercial damages or
146
+ losses), even if such Contributor has been advised of the possibility of such
147
+ damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole responsibility,
154
+ not on behalf of any other Contributor, and only if You agree to indemnify,
155
+ defend, and hold each Contributor harmless for any liability incurred by, or
156
+ claims asserted against, such Contributor by reason of your accepting any such
157
+ warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
160
+
161
+ APPENDIX: How to apply the Apache License to your work.
162
+
163
+ To apply the Apache License to your work, attach the following boilerplate
164
+ notice, with the fields enclosed by brackets "[]" replaced with your own
165
+ identifying information. (Don't include the brackets!) The text should be
166
+ enclosed in the appropriate comment syntax for the file format. We also
167
+ recommend that a file or class name and description of purpose be included on
168
+ the same "printed page" as the copyright notice for easier identification
169
+ within third-party archives.
170
+
171
+ Copyright [yyyy] [name of copyright owner]
172
+
173
+ Licensed under the Apache License, Version 2.0 (the "License");
174
+ you may not use this file except in compliance with the License.
175
+ You may obtain a copy of the License at
176
+
177
+ http://www.apache.org/licenses/LICENSE-2.0
178
+
179
+ Unless required by applicable law or agreed to in writing, software
180
+ distributed under the License is distributed on an "AS IS" BASIS,
181
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
+ See the License for the specific language governing permissions and
183
+ limitations under the License.
184
+
185
+ Copyright 2026 Apurv Salunke
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.4
2
+ Name: tt-data-store
3
+ Version: 0.1.0
4
+ Summary: Canonical market data archive library
5
+ Author-email: Apurv Salunke <salunke.apurv7@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Tiny-Trader/data-store
8
+ Project-URL: Repository, https://github.com/Tiny-Trader/data-store
9
+ Project-URL: Issues, https://github.com/Tiny-Trader/data-store/issues
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pyarrow
14
+ Requires-Dist: tzdata
15
+ Requires-Dist: boto3
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: moto[s3]; extra == "dev"
19
+ Dynamic: license-file
20
+
21
+ # data-store
22
+
23
+ Canonical market data archive library. The only interface through which the filesystem may be modified.
24
+
25
+ PyPI package: [`tt-data-store`](https://pypi.org/project/tt-data-store/) · GitHub: [`Tiny-Trader/data-store`](https://github.com/Tiny-Trader/data-store)
26
+
27
+ **Parquet is the source of truth.** `metadata.db` (SQLite) catalogues instruments, files, ingestions, and validation — it is not a substitute for the archive.
28
+
29
+ ## Responsibilities
30
+
31
+ - Push new data into the FS and maintain metadata
32
+ - Normalize
33
+ - Validate
34
+ - Store
35
+ - Get a slice of data from the FS
36
+
37
+ Callers own acquisition formats (e.g. CSV). Ingress is `candles.write`.
38
+
39
+ ## Mental model
40
+
41
+ ```text
42
+ Your script / collector
43
+
44
+ store.candles.write(...)
45
+
46
+ normalize → validate → merge → atomic Parquet write → update metadata.db
47
+ ```
48
+
49
+ Acquisition (CSV download, API, manual script) is the caller's job. The store only accepts normalized candle data via `candles.write`.
50
+
51
+ On disk, an archive looks like:
52
+
53
+ ```text
54
+ data/
55
+ ├── market/ # Parquet files (human-readable layout)
56
+ ├── reference/ # calendars, etc.
57
+ └── metadata.db # catalogue
58
+ ```
59
+
60
+ Canonical layout and semantics live in [docs/](docs/index.md).
61
+
62
+ ## Install
63
+
64
+ ```bash
65
+ pip install tt-data-store
66
+ # or from source:
67
+ uv pip install -e .
68
+ ```
69
+
70
+ ```python
71
+ from tt_data_store import MarketStore
72
+ ```
73
+
74
+ ## Opening an archive
75
+
76
+ ```python
77
+ from tt_data_store import MarketStore
78
+
79
+ store = MarketStore("/path/to/data")
80
+ ```
81
+
82
+ Optional S3 config (or env vars `MARKETSTORE_S3_BUCKET`, `MARKETSTORE_S3_PREFIX`, `MARKETSTORE_S3_REGION`):
83
+
84
+ ```python
85
+ from tt_data_store import MarketStore, RemoteConfig
86
+
87
+ store = MarketStore(
88
+ "./data",
89
+ remote=RemoteConfig(bucket="my-bucket", prefix="archive", region="ap-south-1"),
90
+ )
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ ### Register instruments
96
+
97
+ ```python
98
+ # NIFTY index
99
+ spot = store.instruments.create(
100
+ exchange="NSE",
101
+ instrument_type="INDEX",
102
+ symbol="NIFTY",
103
+ )
104
+ # → instrument_key: "NSE:INDEX:NIFTY"
105
+
106
+ # NIFTY option
107
+ opt = store.instruments.create(
108
+ exchange="NSE",
109
+ instrument_type="OPTION",
110
+ symbol="NIFTY",
111
+ underlying_id=spot.id,
112
+ expiry_date="2026-08-27",
113
+ strike=25000,
114
+ option_type="CE",
115
+ )
116
+ # → "NSE:OPTION:NIFTY:2026-08-27:25000:CE"
117
+ ```
118
+
119
+ Look up later by key:
120
+
121
+ ```python
122
+ inst = store.instruments.get("NSE:INDEX:NIFTY")
123
+ all_nifty = store.instruments.list(symbol="NIFTY")
124
+ ```
125
+
126
+ ### Write candles (main ingress)
127
+
128
+ Pass a list of dicts or a PyArrow table. Each candle has:
129
+
130
+ `timestamp`, `open`, `high`, `low`, `close`, `volume` (optional), `open_interest` (optional)
131
+
132
+ ```python
133
+ from datetime import datetime
134
+ from zoneinfo import ZoneInfo
135
+
136
+ IST = ZoneInfo("Asia/Kolkata")
137
+
138
+ rows = [
139
+ {
140
+ "timestamp": datetime(2026, 8, 11, 9, 15, tzinfo=IST),
141
+ "open": 100.0,
142
+ "high": 101.0,
143
+ "low": 99.0,
144
+ "close": 100.5,
145
+ "volume": 10,
146
+ "open_interest": 100,
147
+ },
148
+ ]
149
+
150
+ result = store.candles.write(spot, rows, source="upstox")
151
+ ```
152
+
153
+ `write` handles normalization, dedup, merge with existing data, gap detection, atomic file replacement, and ingestion provenance. It returns a `WriteResult` with row counts, gaps, quality status (`VALID` / `PARTIAL` / etc.), and the file path.
154
+
155
+ Files land in deterministic locations — e.g. spot → `market/nifty/spot/2026.parquet`, options → `market/nifty/options/2026-08-27/25000_CE.parquet`.
156
+
157
+ ### Read candles
158
+
159
+ ```python
160
+ table = store.candles.read(
161
+ spot,
162
+ start="2026-08-01",
163
+ end="2026-08-31",
164
+ )
165
+ ```
166
+
167
+ Returns a PyArrow table, filtered and sorted by timestamp. The store resolves which Parquet files to read.
168
+
169
+ ### Inspect files and quality
170
+
171
+ ```python
172
+ file = store.files.get("market/nifty/spot/2026.parquet")
173
+
174
+ result = store.validate(spot) # or store.validate(file.path)
175
+
176
+ report = store.inspect()
177
+ ```
178
+
179
+ ### Sync with S3
180
+
181
+ Local writes go to disk first; S3 is separate:
182
+
183
+ ```python
184
+ store.remote.push(files=["market/nifty/spot/2026.parquet", "metadata.db"])
185
+ store.remote.pull(files=["market/nifty/options/2026-08-27/25000_CE.parquet"])
186
+ store.remote.sync(files=[...])
187
+ ```
188
+
189
+ ## End-to-end producer flow
190
+
191
+ ```python
192
+ store = MarketStore("./data")
193
+
194
+ # 1. Ensure instrument exists
195
+ inst = store.instruments.get("NSE:INDEX:NIFTY")
196
+ if inst is None:
197
+ inst = store.instruments.create(
198
+ exchange="NSE", instrument_type="INDEX", symbol="NIFTY"
199
+ )
200
+
201
+ # 2. Fetch from Upstox/NSE/CSV — convert to candle dicts yourself
202
+ candles = parse_my_csv("NIFTY.csv")
203
+
204
+ # 3. Single write call — store does the rest
205
+ result = store.candles.write(
206
+ inst,
207
+ candles,
208
+ source="upstox",
209
+ source_instrument_id="NSE_INDEX|Nifty 50",
210
+ requested_start="2026-08-01",
211
+ requested_end="2026-08-31",
212
+ )
213
+
214
+ # 4. Optionally push to S3
215
+ store.remote.push()
216
+ ```
217
+
218
+ ## What not to do
219
+
220
+ - Don't write Parquet files directly
221
+ - Don't run SQL against `metadata.db` in normal workflows
222
+ - Don't parse CSV inside `tt_data_store` — convert to candles first
223
+ - Don't use paths as the primary interface (use instrument keys and date ranges)
224
+
225
+ ## Public API
226
+
227
+ ```python
228
+ store.instruments.get(...) / .list(...) / .create(...)
229
+ store.candles.read(...) / .write(...)
230
+ store.files.get(...) / .list(...)
231
+ store.validate(...)
232
+ store.inspect()
233
+ store.remote.pull(...) / .push(...) / .sync(...)
234
+ ```
235
+
236
+ ## Repository layout
237
+
238
+ ```text
239
+ data-store/
240
+ ├── docs/
241
+ ├── pyproject.toml
242
+ ├── src/ # tt_data_store package modules
243
+ └── tests/
244
+ ```
@@ -0,0 +1,224 @@
1
+ # data-store
2
+
3
+ Canonical market data archive library. The only interface through which the filesystem may be modified.
4
+
5
+ PyPI package: [`tt-data-store`](https://pypi.org/project/tt-data-store/) · GitHub: [`Tiny-Trader/data-store`](https://github.com/Tiny-Trader/data-store)
6
+
7
+ **Parquet is the source of truth.** `metadata.db` (SQLite) catalogues instruments, files, ingestions, and validation — it is not a substitute for the archive.
8
+
9
+ ## Responsibilities
10
+
11
+ - Push new data into the FS and maintain metadata
12
+ - Normalize
13
+ - Validate
14
+ - Store
15
+ - Get a slice of data from the FS
16
+
17
+ Callers own acquisition formats (e.g. CSV). Ingress is `candles.write`.
18
+
19
+ ## Mental model
20
+
21
+ ```text
22
+ Your script / collector
23
+
24
+ store.candles.write(...)
25
+
26
+ normalize → validate → merge → atomic Parquet write → update metadata.db
27
+ ```
28
+
29
+ Acquisition (CSV download, API, manual script) is the caller's job. The store only accepts normalized candle data via `candles.write`.
30
+
31
+ On disk, an archive looks like:
32
+
33
+ ```text
34
+ data/
35
+ ├── market/ # Parquet files (human-readable layout)
36
+ ├── reference/ # calendars, etc.
37
+ └── metadata.db # catalogue
38
+ ```
39
+
40
+ Canonical layout and semantics live in [docs/](docs/index.md).
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install tt-data-store
46
+ # or from source:
47
+ uv pip install -e .
48
+ ```
49
+
50
+ ```python
51
+ from tt_data_store import MarketStore
52
+ ```
53
+
54
+ ## Opening an archive
55
+
56
+ ```python
57
+ from tt_data_store import MarketStore
58
+
59
+ store = MarketStore("/path/to/data")
60
+ ```
61
+
62
+ Optional S3 config (or env vars `MARKETSTORE_S3_BUCKET`, `MARKETSTORE_S3_PREFIX`, `MARKETSTORE_S3_REGION`):
63
+
64
+ ```python
65
+ from tt_data_store import MarketStore, RemoteConfig
66
+
67
+ store = MarketStore(
68
+ "./data",
69
+ remote=RemoteConfig(bucket="my-bucket", prefix="archive", region="ap-south-1"),
70
+ )
71
+ ```
72
+
73
+ ## Usage
74
+
75
+ ### Register instruments
76
+
77
+ ```python
78
+ # NIFTY index
79
+ spot = store.instruments.create(
80
+ exchange="NSE",
81
+ instrument_type="INDEX",
82
+ symbol="NIFTY",
83
+ )
84
+ # → instrument_key: "NSE:INDEX:NIFTY"
85
+
86
+ # NIFTY option
87
+ opt = store.instruments.create(
88
+ exchange="NSE",
89
+ instrument_type="OPTION",
90
+ symbol="NIFTY",
91
+ underlying_id=spot.id,
92
+ expiry_date="2026-08-27",
93
+ strike=25000,
94
+ option_type="CE",
95
+ )
96
+ # → "NSE:OPTION:NIFTY:2026-08-27:25000:CE"
97
+ ```
98
+
99
+ Look up later by key:
100
+
101
+ ```python
102
+ inst = store.instruments.get("NSE:INDEX:NIFTY")
103
+ all_nifty = store.instruments.list(symbol="NIFTY")
104
+ ```
105
+
106
+ ### Write candles (main ingress)
107
+
108
+ Pass a list of dicts or a PyArrow table. Each candle has:
109
+
110
+ `timestamp`, `open`, `high`, `low`, `close`, `volume` (optional), `open_interest` (optional)
111
+
112
+ ```python
113
+ from datetime import datetime
114
+ from zoneinfo import ZoneInfo
115
+
116
+ IST = ZoneInfo("Asia/Kolkata")
117
+
118
+ rows = [
119
+ {
120
+ "timestamp": datetime(2026, 8, 11, 9, 15, tzinfo=IST),
121
+ "open": 100.0,
122
+ "high": 101.0,
123
+ "low": 99.0,
124
+ "close": 100.5,
125
+ "volume": 10,
126
+ "open_interest": 100,
127
+ },
128
+ ]
129
+
130
+ result = store.candles.write(spot, rows, source="upstox")
131
+ ```
132
+
133
+ `write` handles normalization, dedup, merge with existing data, gap detection, atomic file replacement, and ingestion provenance. It returns a `WriteResult` with row counts, gaps, quality status (`VALID` / `PARTIAL` / etc.), and the file path.
134
+
135
+ Files land in deterministic locations — e.g. spot → `market/nifty/spot/2026.parquet`, options → `market/nifty/options/2026-08-27/25000_CE.parquet`.
136
+
137
+ ### Read candles
138
+
139
+ ```python
140
+ table = store.candles.read(
141
+ spot,
142
+ start="2026-08-01",
143
+ end="2026-08-31",
144
+ )
145
+ ```
146
+
147
+ Returns a PyArrow table, filtered and sorted by timestamp. The store resolves which Parquet files to read.
148
+
149
+ ### Inspect files and quality
150
+
151
+ ```python
152
+ file = store.files.get("market/nifty/spot/2026.parquet")
153
+
154
+ result = store.validate(spot) # or store.validate(file.path)
155
+
156
+ report = store.inspect()
157
+ ```
158
+
159
+ ### Sync with S3
160
+
161
+ Local writes go to disk first; S3 is separate:
162
+
163
+ ```python
164
+ store.remote.push(files=["market/nifty/spot/2026.parquet", "metadata.db"])
165
+ store.remote.pull(files=["market/nifty/options/2026-08-27/25000_CE.parquet"])
166
+ store.remote.sync(files=[...])
167
+ ```
168
+
169
+ ## End-to-end producer flow
170
+
171
+ ```python
172
+ store = MarketStore("./data")
173
+
174
+ # 1. Ensure instrument exists
175
+ inst = store.instruments.get("NSE:INDEX:NIFTY")
176
+ if inst is None:
177
+ inst = store.instruments.create(
178
+ exchange="NSE", instrument_type="INDEX", symbol="NIFTY"
179
+ )
180
+
181
+ # 2. Fetch from Upstox/NSE/CSV — convert to candle dicts yourself
182
+ candles = parse_my_csv("NIFTY.csv")
183
+
184
+ # 3. Single write call — store does the rest
185
+ result = store.candles.write(
186
+ inst,
187
+ candles,
188
+ source="upstox",
189
+ source_instrument_id="NSE_INDEX|Nifty 50",
190
+ requested_start="2026-08-01",
191
+ requested_end="2026-08-31",
192
+ )
193
+
194
+ # 4. Optionally push to S3
195
+ store.remote.push()
196
+ ```
197
+
198
+ ## What not to do
199
+
200
+ - Don't write Parquet files directly
201
+ - Don't run SQL against `metadata.db` in normal workflows
202
+ - Don't parse CSV inside `tt_data_store` — convert to candles first
203
+ - Don't use paths as the primary interface (use instrument keys and date ranges)
204
+
205
+ ## Public API
206
+
207
+ ```python
208
+ store.instruments.get(...) / .list(...) / .create(...)
209
+ store.candles.read(...) / .write(...)
210
+ store.files.get(...) / .list(...)
211
+ store.validate(...)
212
+ store.inspect()
213
+ store.remote.pull(...) / .push(...) / .sync(...)
214
+ ```
215
+
216
+ ## Repository layout
217
+
218
+ ```text
219
+ data-store/
220
+ ├── docs/
221
+ ├── pyproject.toml
222
+ ├── src/ # tt_data_store package modules
223
+ └── tests/
224
+ ```
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "tt-data-store"
3
+ version = "0.1.0"
4
+ description = "Canonical market data archive library"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "Apache-2.0"
8
+ authors = [{ name = "Apurv Salunke", email = "salunke.apurv7@gmail.com" }]
9
+ dependencies = [
10
+ "pyarrow",
11
+ "tzdata",
12
+ "boto3",
13
+ ]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/Tiny-Trader/data-store"
17
+ Repository = "https://github.com/Tiny-Trader/data-store"
18
+ Issues = "https://github.com/Tiny-Trader/data-store/issues"
19
+
20
+ [project.optional-dependencies]
21
+ dev = ["pytest", "moto[s3]"]
22
+
23
+ [build-system]
24
+ requires = ["setuptools>=61"]
25
+ build-backend = "setuptools.build_meta"
26
+
27
+ [tool.setuptools.package-dir]
28
+ tt_data_store = "src"
29
+
30
+ [tool.setuptools]
31
+ packages = ["tt_data_store"]
32
+
33
+ [tool.setuptools.package-data]
34
+ tt_data_store = ["schema.sql"]
35
+
36
+ [tool.pytest.ini_options]
37
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+