fin3 0.4.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.
- fin3-0.4.0/LICENSE +202 -0
- fin3-0.4.0/PKG-INFO +188 -0
- fin3-0.4.0/README.md +160 -0
- fin3-0.4.0/fin3/__init__.py +55 -0
- fin3-0.4.0/fin3/calendar/__init__.py +1 -0
- fin3-0.4.0/fin3/calendar/exchange.py +142 -0
- fin3-0.4.0/fin3/cli.py +366 -0
- fin3-0.4.0/fin3/config/__init__.py +1 -0
- fin3-0.4.0/fin3/config/settings.py +300 -0
- fin3-0.4.0/fin3/core.py +611 -0
- fin3-0.4.0/fin3/exceptions.py +126 -0
- fin3-0.4.0/fin3/inspect.py +239 -0
- fin3-0.4.0/fin3/manifest.py +631 -0
- fin3-0.4.0/fin3/metadata/__init__.py +1 -0
- fin3-0.4.0/fin3/metadata/asset_profile.py +126 -0
- fin3-0.4.0/fin3/monitoring/__init__.py +15 -0
- fin3-0.4.0/fin3/monitoring/collector.py +172 -0
- fin3-0.4.0/fin3/monitoring/display.py +114 -0
- fin3-0.4.0/fin3/monitoring/render.py +128 -0
- fin3-0.4.0/fin3/monitoring/tmux.py +96 -0
- fin3-0.4.0/fin3/monitoring/tracker.py +453 -0
- fin3-0.4.0/fin3/options.py +653 -0
- fin3-0.4.0/fin3/options_schemas.py +481 -0
- fin3-0.4.0/fin3/providers/__init__.py +144 -0
- fin3-0.4.0/fin3/providers/base.py +79 -0
- fin3-0.4.0/fin3/providers/binance.py +358 -0
- fin3-0.4.0/fin3/providers/cboe.py +306 -0
- fin3-0.4.0/fin3/providers/databento.py +253 -0
- fin3-0.4.0/fin3/providers/eodhd_options.py +1257 -0
- fin3-0.4.0/fin3/providers/massive.py +404 -0
- fin3-0.4.0/fin3/providers/yfinance.py +303 -0
- fin3-0.4.0/fin3/schemas.py +164 -0
- fin3-0.4.0/fin3/storage/__init__.py +1 -0
- fin3-0.4.0/fin3/storage/arctic.py +601 -0
- fin3-0.4.0/fin3/storage/defrag.py +225 -0
- fin3-0.4.0/fin3/storage/locking.py +314 -0
- fin3-0.4.0/fin3/sync.py +1078 -0
- fin3-0.4.0/fin3/utils/__init__.py +1 -0
- fin3-0.4.0/fin3/utils/date_utils.py +119 -0
- fin3-0.4.0/fin3/utils/integrity.py +127 -0
- fin3-0.4.0/fin3/utils/logging.py +48 -0
- fin3-0.4.0/fin3/utils/options_validation.py +245 -0
- fin3-0.4.0/fin3/utils/rules.py +573 -0
- fin3-0.4.0/fin3/utils/symbols.py +34 -0
- fin3-0.4.0/fin3/utils/validation.py +104 -0
- fin3-0.4.0/fin3.egg-info/PKG-INFO +188 -0
- fin3-0.4.0/fin3.egg-info/SOURCES.txt +73 -0
- fin3-0.4.0/fin3.egg-info/dependency_links.txt +1 -0
- fin3-0.4.0/fin3.egg-info/entry_points.txt +2 -0
- fin3-0.4.0/fin3.egg-info/requires.txt +22 -0
- fin3-0.4.0/fin3.egg-info/top_level.txt +1 -0
- fin3-0.4.0/pyproject.toml +59 -0
- fin3-0.4.0/setup.cfg +4 -0
- fin3-0.4.0/tests/test_calendar.py +117 -0
- fin3-0.4.0/tests/test_config.py +277 -0
- fin3-0.4.0/tests/test_core.py +1004 -0
- fin3-0.4.0/tests/test_core_helpers.py +437 -0
- fin3-0.4.0/tests/test_defrag.py +333 -0
- fin3-0.4.0/tests/test_exceptions.py +67 -0
- fin3-0.4.0/tests/test_gap_detection.py +115 -0
- fin3-0.4.0/tests/test_inspect.py +624 -0
- fin3-0.4.0/tests/test_integrity.py +324 -0
- fin3-0.4.0/tests/test_locking.py +411 -0
- fin3-0.4.0/tests/test_manifest.py +640 -0
- fin3-0.4.0/tests/test_manifest_cli.py +492 -0
- fin3-0.4.0/tests/test_manifest_sync.py +1288 -0
- fin3-0.4.0/tests/test_metadata.py +177 -0
- fin3-0.4.0/tests/test_monitoring.py +818 -0
- fin3-0.4.0/tests/test_options.py +889 -0
- fin3-0.4.0/tests/test_options_schemas.py +512 -0
- fin3-0.4.0/tests/test_providers.py +54 -0
- fin3-0.4.0/tests/test_quality.py +1085 -0
- fin3-0.4.0/tests/test_schemas.py +170 -0
- fin3-0.4.0/tests/test_storage.py +563 -0
- fin3-0.4.0/tests/test_validation.py +300 -0
fin3-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
fin3-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fin3
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Declarative financial time-series data library for VectorBT Pro backtesting
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: arcticdb>=5.0
|
|
9
|
+
Requires-Dist: exchange-calendars>=4.13.2
|
|
10
|
+
Requires-Dist: numpy>=1.24
|
|
11
|
+
Requires-Dist: pandas>=2.0
|
|
12
|
+
Requires-Dist: psutil>=5.9
|
|
13
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
14
|
+
Requires-Dist: python-dotenv>=1.0
|
|
15
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
16
|
+
Requires-Dist: rich>=13.0
|
|
17
|
+
Requires-Dist: structlog>=24.0
|
|
18
|
+
Provides-Extra: databento
|
|
19
|
+
Requires-Dist: databento; extra == "databento"
|
|
20
|
+
Provides-Extra: yfinance
|
|
21
|
+
Requires-Dist: yfinance; extra == "yfinance"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# fin3
|
|
30
|
+
|
|
31
|
+
Financial time-series data tooling for downloading, normalizing, validating,
|
|
32
|
+
storing, and retrieving OHLCV bars as pandas DataFrames. Built on
|
|
33
|
+
[ArcticDB](https://arcticdb.io/) and [MinIO](https://min.io/), with Databento,
|
|
34
|
+
Binance, Yahoo Finance, and Massive (formerly Polygon.io) provider implementations.
|
|
35
|
+
|
|
36
|
+
Maintained by [Nathan Peet](https://github.com/nathanpt). Nathan uses fin3 to
|
|
37
|
+
download, normalize, and prepare market data for analysis in his automated
|
|
38
|
+
portfolio workflow. This describes data preparation and analysis, not live trade
|
|
39
|
+
execution or investment performance; no external adoption is claimed.
|
|
40
|
+
|
|
41
|
+
## Implemented functionality
|
|
42
|
+
|
|
43
|
+
- Canonical OHLCV columns (`open`, `high`, `low`, `close`, `volume`) with UTC timestamps.
|
|
44
|
+
- Exchange-session and continuous calendars, gap detection, incremental fetching,
|
|
45
|
+
and calendar alignment.
|
|
46
|
+
- ArcticDB storage backed by MinIO/S3-compatible storage; local LMDB support for tests.
|
|
47
|
+
- Raw-provider and post-alignment validation, metadata bootstrap, and per-symbol
|
|
48
|
+
cross-process file locking.
|
|
49
|
+
- Integrity auditing, HTML inspection reports, defragmentation, and resource monitoring.
|
|
50
|
+
- Declarative YAML/JSON dataset manifests with an installed `fin3` command
|
|
51
|
+
(`ensure`, `sync`, and read-only `status`), including dry-run previews and
|
|
52
|
+
drift detection.
|
|
53
|
+
- Standalone download, audit, inspection, and Databento normalization scripts.
|
|
54
|
+
|
|
55
|
+
These are implemented capabilities, not a guarantee of error-free data or universal
|
|
56
|
+
provider/asset coverage. Data availability, licensing, entitlements, and rate limits
|
|
57
|
+
remain subject to each source.
|
|
58
|
+
|
|
59
|
+
### Provider status
|
|
60
|
+
|
|
61
|
+
All four providers are registered in the public implementation. Live-verification
|
|
62
|
+
notes below refer to historical public PR evidence, not a fresh live-API test of
|
|
63
|
+
every provider on each checkout.
|
|
64
|
+
|
|
65
|
+
| Provider key | Implemented scope | Verification and limitations |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
1: @ours
|
|
68
|
+
|
|
69
|
+
`max_cost` checks provider-reported estimates before fetching. Databento queries
|
|
70
|
+
its cost API; Binance and Yahoo report zero, while subscription-based Massive also
|
|
71
|
+
reports zero. **A zero estimate does not make subscriptions or entitlements free,
|
|
72
|
+
and `max_cost` does not cap Massive subscription charges.**
|
|
73
|
+
|
|
74
|
+
## Quick start (from source)
|
|
75
|
+
|
|
76
|
+
Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/). Use this repository
|
|
77
|
+
checkout; these instructions do not assume that a published PyPI package is available.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/nathanpt/fin3.git
|
|
81
|
+
cd fin3
|
|
82
|
+
uv sync --extra databento
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For Yahoo support, add `--extra yfinance`. Binance and Massive use stdlib HTTP and
|
|
86
|
+
need no provider-specific extra. ArcticDB storage still requires its core dependencies.
|
|
87
|
+
|
|
88
|
+
### Configure
|
|
89
|
+
|
|
90
|
+
Start a local MinIO instance and supply its credentials plus your Databento key in
|
|
91
|
+
an uncommitted `.env` file (the credentials below are development placeholders):
|
|
92
|
+
|
|
93
|
+
```dotenv
|
|
94
|
+
FIN3_MINIO__ENDPOINT=localhost:9000
|
|
95
|
+
FIN3_MINIO__ACCESS_KEY=minioadmin
|
|
96
|
+
FIN3_MINIO__SECRET_KEY=minioadmin
|
|
97
|
+
FIN3_PROVIDERS__DATABENTO__PROVIDER_TYPE=databento
|
|
98
|
+
FIN3_PROVIDERS__DATABENTO__API_KEY=db-your-key-here
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Do not use placeholder storage credentials in production. See the
|
|
102
|
+
[usage guide](docs/USAGE.md) for storage configuration and other providers.
|
|
103
|
+
|
|
104
|
+
### Fetch and analyze
|
|
105
|
+
|
|
106
|
+
The following performs network requests and may incur Databento charges. Choose
|
|
107
|
+
symbols, dates, dataset, and entitlements appropriate to your account before running.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from datetime import datetime, timezone
|
|
111
|
+
|
|
112
|
+
from fin3 import AssetType, ClientConfig, MarketDataFetcher, Resolution
|
|
113
|
+
|
|
114
|
+
fetcher = MarketDataFetcher(ClientConfig.from_env())
|
|
115
|
+
df = fetcher.get_data(
|
|
116
|
+
asset_type=AssetType.EQUITY_US,
|
|
117
|
+
provider="databento",
|
|
118
|
+
resolution=Resolution.ONE_MINUTE,
|
|
119
|
+
symbols=["AAPL"],
|
|
120
|
+
start=datetime(2024, 1, 2, tzinfo=timezone.utc),
|
|
121
|
+
end=datetime(2024, 1, 2, 23, 59, tzinfo=timezone.utc),
|
|
122
|
+
)
|
|
123
|
+
aapl = df["AAPL"]
|
|
124
|
+
closes = df[("AAPL", "close")]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`get_data()` checks existing coverage, fetches missing ranges, validates raw data,
|
|
128
|
+
aligns bars to a calendar, validates again, and writes to ArcticDB before returning
|
|
129
|
+
a symbol/field MultiIndex DataFrame. Library names follow
|
|
130
|
+
`{asset_prefix}-{resolution}-{provider}`, for example `equities-1m-databento` or
|
|
131
|
+
`crypto-1h-binance`. Missing in-session bars are represented by NaN OHLC and zero
|
|
132
|
+
volume. Trading sessions depend on the asset calendar and daylight-saving time;
|
|
133
|
+
NYSE hours are not a fixed UTC interval year-round.
|
|
134
|
+
|
|
135
|
+
## Standalone tools
|
|
136
|
+
|
|
137
|
+
The installed `fin3` command drives the declarative manifest workflow
|
|
138
|
+
(`fin3 ensure`, `fin3 sync`, and read-only `fin3 status`; see docs/USAGE.md).
|
|
139
|
+
The scripts below remain standalone: run them from the checkout with
|
|
140
|
+
`uv run python scripts/<name>.py --help` before using them.
|
|
141
|
+
Some commands download paid data or modify storage; review their options first.
|
|
142
|
+
|
|
143
|
+
| Script | Purpose |
|
|
144
|
+
|---|---|
|
|
145
|
+
| [download_symbols.py](scripts/download_symbols.py) | Download data for multiple symbols with cost estimation |
|
|
146
|
+
| [audit_library.py](scripts/audit_library.py) | Integrity checks and HTML dashboard |
|
|
147
|
+
| [inspect_library.py](scripts/inspect_library.py) | Per-symbol library overview and HTML reports |
|
|
148
|
+
| [defragment_library.py](scripts/defragment_library.py) | Compact ArcticDB segments, with dry-run support |
|
|
149
|
+
| [normalize_databento.py](scripts/normalize_databento.py) | Convert raw Databento parquet to canonical schema |
|
|
150
|
+
| [fix_meta_rename.py](scripts/fix_meta_rename.py) | Handle the FB-to-META symbol rename gap |
|
|
151
|
+
|
|
152
|
+
## Unfinished / planned
|
|
153
|
+
|
|
154
|
+
- High-level `DataManager` retrieval, alignment, and multi-format output API.
|
|
155
|
+
- Additional providers such as ThetaData; no ThetaData provider is in the public tree.
|
|
156
|
+
|
|
157
|
+
Binance, Yahoo, and Massive are implemented, not future provider stubs. The older
|
|
158
|
+
[Massive implementation plan](PLAN.md) is historical context, not current status.
|
|
159
|
+
The internal `.docs/ROADMAP.md` referenced in repository conventions is not included
|
|
160
|
+
in the public checkout; this README summarizes public implemented/planned status.
|
|
161
|
+
|
|
162
|
+
## Documentation and development
|
|
163
|
+
|
|
164
|
+
- [Usage guide](docs/USAGE.md): configuration, fetching, concurrency, monitoring,
|
|
165
|
+
exceptions, and adding providers. For installation, use the source instructions above.
|
|
166
|
+
- [Provider comparison](docs/dataset-comparison.md).
|
|
167
|
+
- [API reference source](docs/api/index.md).
|
|
168
|
+
- [Resource monitoring notes](docs/resource-monitoring-notes.md).
|
|
169
|
+
- [Repository guidelines](AGENTS.md).
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
uv sync --all-extras
|
|
173
|
+
uv run pytest tests/ -m "not integration"
|
|
174
|
+
uv run ruff check .
|
|
175
|
+
uv run mypy fin3/
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Live integration tests require explicit opt-in and relevant keys/infrastructure.
|
|
179
|
+
Mocked tests alone do not establish live provider compatibility; see the live-test
|
|
180
|
+
requirements in `AGENTS.md`. Do not point validation runs at production stores.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
Copyright 2026 Nathan Peet.
|
|
185
|
+
|
|
186
|
+
Licensed under the [Apache License, Version 2.0](LICENSE). The license covers this
|
|
187
|
+
repository's code; it does not grant rights to redistribute third-party market data
|
|
188
|
+
or replace provider agreements.
|
fin3-0.4.0/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# fin3
|
|
2
|
+
|
|
3
|
+
Financial time-series data tooling for downloading, normalizing, validating,
|
|
4
|
+
storing, and retrieving OHLCV bars as pandas DataFrames. Built on
|
|
5
|
+
[ArcticDB](https://arcticdb.io/) and [MinIO](https://min.io/), with Databento,
|
|
6
|
+
Binance, Yahoo Finance, and Massive (formerly Polygon.io) provider implementations.
|
|
7
|
+
|
|
8
|
+
Maintained by [Nathan Peet](https://github.com/nathanpt). Nathan uses fin3 to
|
|
9
|
+
download, normalize, and prepare market data for analysis in his automated
|
|
10
|
+
portfolio workflow. This describes data preparation and analysis, not live trade
|
|
11
|
+
execution or investment performance; no external adoption is claimed.
|
|
12
|
+
|
|
13
|
+
## Implemented functionality
|
|
14
|
+
|
|
15
|
+
- Canonical OHLCV columns (`open`, `high`, `low`, `close`, `volume`) with UTC timestamps.
|
|
16
|
+
- Exchange-session and continuous calendars, gap detection, incremental fetching,
|
|
17
|
+
and calendar alignment.
|
|
18
|
+
- ArcticDB storage backed by MinIO/S3-compatible storage; local LMDB support for tests.
|
|
19
|
+
- Raw-provider and post-alignment validation, metadata bootstrap, and per-symbol
|
|
20
|
+
cross-process file locking.
|
|
21
|
+
- Integrity auditing, HTML inspection reports, defragmentation, and resource monitoring.
|
|
22
|
+
- Declarative YAML/JSON dataset manifests with an installed `fin3` command
|
|
23
|
+
(`ensure`, `sync`, and read-only `status`), including dry-run previews and
|
|
24
|
+
drift detection.
|
|
25
|
+
- Standalone download, audit, inspection, and Databento normalization scripts.
|
|
26
|
+
|
|
27
|
+
These are implemented capabilities, not a guarantee of error-free data or universal
|
|
28
|
+
provider/asset coverage. Data availability, licensing, entitlements, and rate limits
|
|
29
|
+
remain subject to each source.
|
|
30
|
+
|
|
31
|
+
### Provider status
|
|
32
|
+
|
|
33
|
+
All four providers are registered in the public implementation. Live-verification
|
|
34
|
+
notes below refer to historical public PR evidence, not a fresh live-API test of
|
|
35
|
+
every provider on each checkout.
|
|
36
|
+
|
|
37
|
+
| Provider key | Implemented scope | Verification and limitations |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
1: @ours
|
|
40
|
+
|
|
41
|
+
`max_cost` checks provider-reported estimates before fetching. Databento queries
|
|
42
|
+
its cost API; Binance and Yahoo report zero, while subscription-based Massive also
|
|
43
|
+
reports zero. **A zero estimate does not make subscriptions or entitlements free,
|
|
44
|
+
and `max_cost` does not cap Massive subscription charges.**
|
|
45
|
+
|
|
46
|
+
## Quick start (from source)
|
|
47
|
+
|
|
48
|
+
Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/). Use this repository
|
|
49
|
+
checkout; these instructions do not assume that a published PyPI package is available.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/nathanpt/fin3.git
|
|
53
|
+
cd fin3
|
|
54
|
+
uv sync --extra databento
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
For Yahoo support, add `--extra yfinance`. Binance and Massive use stdlib HTTP and
|
|
58
|
+
need no provider-specific extra. ArcticDB storage still requires its core dependencies.
|
|
59
|
+
|
|
60
|
+
### Configure
|
|
61
|
+
|
|
62
|
+
Start a local MinIO instance and supply its credentials plus your Databento key in
|
|
63
|
+
an uncommitted `.env` file (the credentials below are development placeholders):
|
|
64
|
+
|
|
65
|
+
```dotenv
|
|
66
|
+
FIN3_MINIO__ENDPOINT=localhost:9000
|
|
67
|
+
FIN3_MINIO__ACCESS_KEY=minioadmin
|
|
68
|
+
FIN3_MINIO__SECRET_KEY=minioadmin
|
|
69
|
+
FIN3_PROVIDERS__DATABENTO__PROVIDER_TYPE=databento
|
|
70
|
+
FIN3_PROVIDERS__DATABENTO__API_KEY=db-your-key-here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Do not use placeholder storage credentials in production. See the
|
|
74
|
+
[usage guide](docs/USAGE.md) for storage configuration and other providers.
|
|
75
|
+
|
|
76
|
+
### Fetch and analyze
|
|
77
|
+
|
|
78
|
+
The following performs network requests and may incur Databento charges. Choose
|
|
79
|
+
symbols, dates, dataset, and entitlements appropriate to your account before running.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from datetime import datetime, timezone
|
|
83
|
+
|
|
84
|
+
from fin3 import AssetType, ClientConfig, MarketDataFetcher, Resolution
|
|
85
|
+
|
|
86
|
+
fetcher = MarketDataFetcher(ClientConfig.from_env())
|
|
87
|
+
df = fetcher.get_data(
|
|
88
|
+
asset_type=AssetType.EQUITY_US,
|
|
89
|
+
provider="databento",
|
|
90
|
+
resolution=Resolution.ONE_MINUTE,
|
|
91
|
+
symbols=["AAPL"],
|
|
92
|
+
start=datetime(2024, 1, 2, tzinfo=timezone.utc),
|
|
93
|
+
end=datetime(2024, 1, 2, 23, 59, tzinfo=timezone.utc),
|
|
94
|
+
)
|
|
95
|
+
aapl = df["AAPL"]
|
|
96
|
+
closes = df[("AAPL", "close")]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`get_data()` checks existing coverage, fetches missing ranges, validates raw data,
|
|
100
|
+
aligns bars to a calendar, validates again, and writes to ArcticDB before returning
|
|
101
|
+
a symbol/field MultiIndex DataFrame. Library names follow
|
|
102
|
+
`{asset_prefix}-{resolution}-{provider}`, for example `equities-1m-databento` or
|
|
103
|
+
`crypto-1h-binance`. Missing in-session bars are represented by NaN OHLC and zero
|
|
104
|
+
volume. Trading sessions depend on the asset calendar and daylight-saving time;
|
|
105
|
+
NYSE hours are not a fixed UTC interval year-round.
|
|
106
|
+
|
|
107
|
+
## Standalone tools
|
|
108
|
+
|
|
109
|
+
The installed `fin3` command drives the declarative manifest workflow
|
|
110
|
+
(`fin3 ensure`, `fin3 sync`, and read-only `fin3 status`; see docs/USAGE.md).
|
|
111
|
+
The scripts below remain standalone: run them from the checkout with
|
|
112
|
+
`uv run python scripts/<name>.py --help` before using them.
|
|
113
|
+
Some commands download paid data or modify storage; review their options first.
|
|
114
|
+
|
|
115
|
+
| Script | Purpose |
|
|
116
|
+
|---|---|
|
|
117
|
+
| [download_symbols.py](scripts/download_symbols.py) | Download data for multiple symbols with cost estimation |
|
|
118
|
+
| [audit_library.py](scripts/audit_library.py) | Integrity checks and HTML dashboard |
|
|
119
|
+
| [inspect_library.py](scripts/inspect_library.py) | Per-symbol library overview and HTML reports |
|
|
120
|
+
| [defragment_library.py](scripts/defragment_library.py) | Compact ArcticDB segments, with dry-run support |
|
|
121
|
+
| [normalize_databento.py](scripts/normalize_databento.py) | Convert raw Databento parquet to canonical schema |
|
|
122
|
+
| [fix_meta_rename.py](scripts/fix_meta_rename.py) | Handle the FB-to-META symbol rename gap |
|
|
123
|
+
|
|
124
|
+
## Unfinished / planned
|
|
125
|
+
|
|
126
|
+
- High-level `DataManager` retrieval, alignment, and multi-format output API.
|
|
127
|
+
- Additional providers such as ThetaData; no ThetaData provider is in the public tree.
|
|
128
|
+
|
|
129
|
+
Binance, Yahoo, and Massive are implemented, not future provider stubs. The older
|
|
130
|
+
[Massive implementation plan](PLAN.md) is historical context, not current status.
|
|
131
|
+
The internal `.docs/ROADMAP.md` referenced in repository conventions is not included
|
|
132
|
+
in the public checkout; this README summarizes public implemented/planned status.
|
|
133
|
+
|
|
134
|
+
## Documentation and development
|
|
135
|
+
|
|
136
|
+
- [Usage guide](docs/USAGE.md): configuration, fetching, concurrency, monitoring,
|
|
137
|
+
exceptions, and adding providers. For installation, use the source instructions above.
|
|
138
|
+
- [Provider comparison](docs/dataset-comparison.md).
|
|
139
|
+
- [API reference source](docs/api/index.md).
|
|
140
|
+
- [Resource monitoring notes](docs/resource-monitoring-notes.md).
|
|
141
|
+
- [Repository guidelines](AGENTS.md).
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
uv sync --all-extras
|
|
145
|
+
uv run pytest tests/ -m "not integration"
|
|
146
|
+
uv run ruff check .
|
|
147
|
+
uv run mypy fin3/
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Live integration tests require explicit opt-in and relevant keys/infrastructure.
|
|
151
|
+
Mocked tests alone do not establish live provider compatibility; see the live-test
|
|
152
|
+
requirements in `AGENTS.md`. Do not point validation runs at production stores.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
Copyright 2026 Nathan Peet.
|
|
157
|
+
|
|
158
|
+
Licensed under the [Apache License, Version 2.0](LICENSE). The license covers this
|
|
159
|
+
repository's code; it does not grant rights to redistribute third-party market data
|
|
160
|
+
or replace provider agreements.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""fin3 — Declarative financial time-series data library."""
|
|
2
|
+
|
|
3
|
+
from fin3.config.settings import ClientConfig
|
|
4
|
+
from fin3.core import MarketDataFetcher
|
|
5
|
+
from fin3.exceptions import (
|
|
6
|
+
BoundaryMismatchError,
|
|
7
|
+
ConfigurationError,
|
|
8
|
+
DataValidationError,
|
|
9
|
+
Fin3Error,
|
|
10
|
+
ProviderError,
|
|
11
|
+
ProviderRateLimitError,
|
|
12
|
+
ProviderTimeoutError,
|
|
13
|
+
RequestLimitExceededError,
|
|
14
|
+
SchemaValidationError,
|
|
15
|
+
StorageError,
|
|
16
|
+
)
|
|
17
|
+
from fin3.inspect import LibraryOverview, SymbolProfile, inspect_library
|
|
18
|
+
from fin3.monitoring import ResourceReport, ResourceTracker
|
|
19
|
+
from fin3.options import ChainResult, OptionsDataFetcher
|
|
20
|
+
from fin3.options_schemas import ChainCoverageManifest
|
|
21
|
+
from fin3.schemas import AssetType, Resolution
|
|
22
|
+
from fin3.storage.defrag import DefragReport, SymbolDefragResult, defragment_library, get_fragmentation_info
|
|
23
|
+
from fin3.utils.integrity import IntegrityIssue, IntegrityReport, check_integrity
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"AssetType",
|
|
27
|
+
"BoundaryMismatchError",
|
|
28
|
+
"ChainCoverageManifest",
|
|
29
|
+
"ChainResult",
|
|
30
|
+
"ClientConfig",
|
|
31
|
+
"ConfigurationError",
|
|
32
|
+
"DataValidationError",
|
|
33
|
+
"DefragReport",
|
|
34
|
+
"Fin3Error",
|
|
35
|
+
"IntegrityIssue",
|
|
36
|
+
"IntegrityReport",
|
|
37
|
+
"LibraryOverview",
|
|
38
|
+
"MarketDataFetcher",
|
|
39
|
+
"OptionsDataFetcher",
|
|
40
|
+
"ProviderError",
|
|
41
|
+
"RequestLimitExceededError",
|
|
42
|
+
"ResourceReport",
|
|
43
|
+
"ResourceTracker",
|
|
44
|
+
"ProviderRateLimitError",
|
|
45
|
+
"ProviderTimeoutError",
|
|
46
|
+
"Resolution",
|
|
47
|
+
"SchemaValidationError",
|
|
48
|
+
"StorageError",
|
|
49
|
+
"SymbolDefragResult",
|
|
50
|
+
"SymbolProfile",
|
|
51
|
+
"check_integrity",
|
|
52
|
+
"defragment_library",
|
|
53
|
+
"get_fragmentation_info",
|
|
54
|
+
"inspect_library",
|
|
55
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|