tickerforge-spec-data 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.
- tickerforge_spec_data-0.1.0/.gitignore +27 -0
- tickerforge_spec_data-0.1.0/LICENSE +21 -0
- tickerforge_spec_data-0.1.0/PKG-INFO +286 -0
- tickerforge_spec_data-0.1.0/README.md +274 -0
- tickerforge_spec_data-0.1.0/VERSION +1 -0
- tickerforge_spec_data-0.1.0/pyproject.toml +32 -0
- tickerforge_spec_data-0.1.0/spec/contracts/b3/futures.yaml +101 -0
- tickerforge_spec_data-0.1.0/spec/contracts/b3/options.yaml +107 -0
- tickerforge_spec_data-0.1.0/spec/contracts/cme/futures.yaml +113 -0
- tickerforge_spec_data-0.1.0/spec/exchanges/b3.yaml +110 -0
- tickerforge_spec_data-0.1.0/spec/exchanges/cme.yaml +82 -0
- tickerforge_spec_data-0.1.0/spec/schedules/b3.yaml +25 -0
- tickerforge_spec_data-0.1.0/spec/schedules/cme.yaml +16 -0
- tickerforge_spec_data-0.1.0/spec/schemas/contract_cycles.yaml +84 -0
- tickerforge_spec_data-0.1.0/spec/schemas/contracts_schema.yaml +76 -0
- tickerforge_spec_data-0.1.0/spec/schemas/exchange_schema.yaml +77 -0
- tickerforge_spec_data-0.1.0/spec/schemas/options_schema.yaml +115 -0
- tickerforge_spec_data-0.1.0/spec/schemas/schedule_schema.yaml +182 -0
- tickerforge_spec_data-0.1.0/spec/tests/b3/B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz +0 -0
- tickerforge_spec_data-0.1.0/spec/tests/b3/futures_resolve.csv +31 -0
- tickerforge_spec_data-0.1.0/spec/tests/b3/options_resolve.csv +17 -0
- tickerforge_spec_data-0.1.0/spec/tests/cme/futures_resolve.csv +13 -0
- tickerforge_spec_data-0.1.0/tickerforge_spec_data/__init__.py +21 -0
- tickerforge_spec_data-0.1.0/tickerforge_spec_data/py.typed +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
Thumbs.db
|
|
4
|
+
|
|
5
|
+
# Editors
|
|
6
|
+
.vscode/
|
|
7
|
+
.idea/
|
|
8
|
+
*.swp
|
|
9
|
+
*.swo
|
|
10
|
+
*~
|
|
11
|
+
|
|
12
|
+
# Cursor
|
|
13
|
+
.cursorignore
|
|
14
|
+
.cursorindexingignore
|
|
15
|
+
|
|
16
|
+
# Python packaging artifacts
|
|
17
|
+
**/__pycache__/
|
|
18
|
+
*.pyc
|
|
19
|
+
.venv/
|
|
20
|
+
dist/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
|
|
23
|
+
# Rust (crate at repo root; also legacy rust/ subfolder if used)
|
|
24
|
+
/target/
|
|
25
|
+
Cargo.lock
|
|
26
|
+
rust/target/
|
|
27
|
+
rust/Cargo.lock
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alejandro Mesias
|
|
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,286 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tickerforge-spec-data
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Canonical tickerforge specification (YAML/CSV) for tickerforge-py and other consumers.
|
|
5
|
+
Project-URL: Homepage, https://github.com/mesias/tickerforge-spec
|
|
6
|
+
Project-URL: Repository, https://github.com/mesias/tickerforge-spec
|
|
7
|
+
Author: TickerForge
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# TickerForge Spec
|
|
14
|
+
|
|
15
|
+
[](https://github.com/mesias/tickerforge-spec/actions/workflows/ci.yml)
|
|
16
|
+
|
|
17
|
+
**TickerForge Spec** is the canonical specification and shared dataset used by TickerForge implementations across different programming languages.
|
|
18
|
+
|
|
19
|
+
The repository defines exchange metadata, contract rules, and test cases used to resolve financial asset tickers and derivatives contracts (futures and options).
|
|
20
|
+
|
|
21
|
+
It serves as the **source of truth** for all implementations of the TickerForge ecosystem.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# Purpose
|
|
26
|
+
|
|
27
|
+
Different languages may implement their own versions of TickerForge (Python, Rust, Go, etc.).
|
|
28
|
+
|
|
29
|
+
This repository ensures that all implementations share:
|
|
30
|
+
|
|
31
|
+
* The same exchange metadata
|
|
32
|
+
* The same contract rules (futures and options)
|
|
33
|
+
* The same symbol resolution logic
|
|
34
|
+
* The same validation test cases
|
|
35
|
+
|
|
36
|
+
This guarantees **consistent behavior across languages**.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# Repository Structure
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
tickerforge-spec/
|
|
44
|
+
|
|
45
|
+
VERSION
|
|
46
|
+
|
|
47
|
+
spec/
|
|
48
|
+
exchanges/
|
|
49
|
+
b3.yaml
|
|
50
|
+
cme.yaml
|
|
51
|
+
contracts/
|
|
52
|
+
b3/
|
|
53
|
+
futures.yaml
|
|
54
|
+
options.yaml
|
|
55
|
+
cme/
|
|
56
|
+
futures.yaml
|
|
57
|
+
tests/
|
|
58
|
+
b3/
|
|
59
|
+
futures_resolve.csv
|
|
60
|
+
options_resolve.csv
|
|
61
|
+
B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz
|
|
62
|
+
cme/
|
|
63
|
+
futures_resolve.csv
|
|
64
|
+
schemas/
|
|
65
|
+
contract_cycles.yaml
|
|
66
|
+
exchange_schema.yaml
|
|
67
|
+
contracts_schema.yaml
|
|
68
|
+
options_schema.yaml
|
|
69
|
+
|
|
70
|
+
pyproject.toml
|
|
71
|
+
tickerforge_spec_data/
|
|
72
|
+
__init__.py
|
|
73
|
+
|
|
74
|
+
rust/
|
|
75
|
+
Cargo.toml
|
|
76
|
+
src/lib.rs
|
|
77
|
+
|
|
78
|
+
scripts/
|
|
79
|
+
check_versions.py
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The B3 multi-year calendar golden file is kept only as **`B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz`** (semicolon-separated CSV, lzma-compressed)—no uncompressed twin is required in the repo.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
# Exchanges Metadata
|
|
87
|
+
|
|
88
|
+
Exchange files define static information such as:
|
|
89
|
+
|
|
90
|
+
* timezone
|
|
91
|
+
* trading hours
|
|
92
|
+
* supported assets and product categories
|
|
93
|
+
* exchange identifiers
|
|
94
|
+
|
|
95
|
+
Example:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
exchange: B3
|
|
99
|
+
timezone: America/Sao_Paulo
|
|
100
|
+
|
|
101
|
+
assets:
|
|
102
|
+
WIN:
|
|
103
|
+
type: future
|
|
104
|
+
category: index
|
|
105
|
+
description: Mini Ibovespa Futures
|
|
106
|
+
trading_hours:
|
|
107
|
+
start: "09:00"
|
|
108
|
+
end: "18:25"
|
|
109
|
+
|
|
110
|
+
EQUITY_OPTIONS:
|
|
111
|
+
type: option
|
|
112
|
+
category: equity_option
|
|
113
|
+
description: Options on listed equities (PETR4, VALE3, ...)
|
|
114
|
+
trading_hours:
|
|
115
|
+
start: "10:00"
|
|
116
|
+
end: "18:25"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
# Contract Rules — Futures
|
|
122
|
+
|
|
123
|
+
Futures contract rules describe how derivatives contracts are generated and resolved.
|
|
124
|
+
|
|
125
|
+
Each contract defines its cycle (which months it trades in) and an expiration rule.
|
|
126
|
+
|
|
127
|
+
Supported expiration rule types:
|
|
128
|
+
|
|
129
|
+
* `nearest_weekday_to_day` — closest weekday to a calendar day (e.g. WIN/IND: nearest Wednesday to the 15th)
|
|
130
|
+
* `first_business_day` — first business day of the contract month (e.g. DOL, WDO, DI1)
|
|
131
|
+
* `last_business_day` — last business day of the contract month (e.g. BGI)
|
|
132
|
+
* `fixed_day` — specific calendar day, next business day if holiday (e.g. CCM: 15th)
|
|
133
|
+
* `schedule` — dates vary per contract; consult exchange maturity calendar (e.g. ICF, CL, GC)
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
contracts:
|
|
139
|
+
- symbol: DOL
|
|
140
|
+
exchange: B3
|
|
141
|
+
ticker_format: "{symbol}{month_code}{yy}"
|
|
142
|
+
contract_cycle:
|
|
143
|
+
- F # January
|
|
144
|
+
- G # February
|
|
145
|
+
# ... all 12 months
|
|
146
|
+
expiration_rule:
|
|
147
|
+
type: first_business_day
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
These rules allow implementations to determine:
|
|
151
|
+
|
|
152
|
+
* front-month contracts
|
|
153
|
+
* expiration dates
|
|
154
|
+
* contract offsets
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
# Contract Rules — Options
|
|
159
|
+
|
|
160
|
+
Options contract rules describe how option tickers are resolved.
|
|
161
|
+
|
|
162
|
+
B3 has four categories of options, each with distinct ticker formats:
|
|
163
|
+
|
|
164
|
+
**Equity options** use a compact format where one letter encodes both the option type (call/put) and the expiration month:
|
|
165
|
+
|
|
166
|
+
* Calls: A (Jan) through L (Dec)
|
|
167
|
+
* Puts: M (Jan) through X (Dec)
|
|
168
|
+
* Ticker format: `{root}{month_code}{strike}` — e.g. `PETRA35` = Petrobras call, January, strike 35
|
|
169
|
+
|
|
170
|
+
**Index, dollar, and rate options** use futures-style month codes with an explicit call/put indicator:
|
|
171
|
+
|
|
172
|
+
* Ticker format: `{symbol}{month_code}{yy}{C|P}{strike}` — e.g. `DOLF26C005200`
|
|
173
|
+
|
|
174
|
+
Example:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
options:
|
|
178
|
+
- type: equity
|
|
179
|
+
exchange: B3
|
|
180
|
+
option_style: american
|
|
181
|
+
ticker_format: "{root}{month_code}{strike}"
|
|
182
|
+
call_month_codes: [A, B, C, D, E, F, G, H, I, J, K, L]
|
|
183
|
+
put_month_codes: [M, N, O, P, Q, R, S, T, U, V, W, X]
|
|
184
|
+
expiration_rule:
|
|
185
|
+
type: nth_weekday
|
|
186
|
+
weekday: friday
|
|
187
|
+
nth: 3
|
|
188
|
+
underlyings:
|
|
189
|
+
- PETR4
|
|
190
|
+
- VALE3
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
# Shared Test Cases
|
|
196
|
+
|
|
197
|
+
Test cases ensure that all implementations produce identical results.
|
|
198
|
+
|
|
199
|
+
Test files use CSV format for easy maintenance and universal parsing.
|
|
200
|
+
|
|
201
|
+
**Futures** (`spec/tests/<exchange>/futures_resolve.csv`):
|
|
202
|
+
|
|
203
|
+
Columns: `symbol,date,offset,expected,comment`
|
|
204
|
+
|
|
205
|
+
```csv
|
|
206
|
+
symbol,date,offset,expected,comment
|
|
207
|
+
WIN,2026-06-01,0,WINM26,before June expiry (Jun 17) front month is June
|
|
208
|
+
DOL,2026-04-02,0,DOLK26,after Apr 1 expiry rolls to May
|
|
209
|
+
BGI,2026-06-01,0,BGIM26,after May expiry (May 29) front month is June
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Options** (`spec/tests/<exchange>/options_resolve.csv`):
|
|
213
|
+
|
|
214
|
+
Columns: `type,underlying,date,option_type,strike,offset,expected,comment`
|
|
215
|
+
|
|
216
|
+
```csv
|
|
217
|
+
type,underlying,date,option_type,strike,offset,expected,comment
|
|
218
|
+
equity,PETR4,2026-01-16,call,35,0,PETRA35,January call strike 35
|
|
219
|
+
equity,PETR4,2026-01-16,put,35,0,PETRM35,January put strike 35
|
|
220
|
+
dollar,DOL,2026-03-15,call,5200,0,DOLH26C005200,March call strike 5200
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Implementations must load these tests and verify their resolver against them.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
# Implementations
|
|
228
|
+
|
|
229
|
+
TickerForge implementations may exist in multiple languages.
|
|
230
|
+
|
|
231
|
+
Examples:
|
|
232
|
+
|
|
233
|
+
* tickerforge (Python)
|
|
234
|
+
* tickerforge-rs (Rust)
|
|
235
|
+
* tickerforge-go (Go)
|
|
236
|
+
|
|
237
|
+
All implementations should rely on this specification.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
# Versioning and Releases
|
|
242
|
+
|
|
243
|
+
This repository uses a shared root `VERSION` file as release authority.
|
|
244
|
+
|
|
245
|
+
- Tag format: `vX.Y.Z`
|
|
246
|
+
- Python package (`tickerforge-spec-data` in root `pyproject.toml`) version must match `VERSION`
|
|
247
|
+
- Rust crate under `rust/` uses the same version for local checks; it is marked `publish = false` (crates.io needs a different layout than `../spec`)
|
|
248
|
+
|
|
249
|
+
Release sequence:
|
|
250
|
+
|
|
251
|
+
1. Update `VERSION` and the `version` field in `pyproject.toml` and `rust/Cargo.toml`
|
|
252
|
+
2. Run `python scripts/check_versions.py`
|
|
253
|
+
3. Commit and tag `vX.Y.Z`
|
|
254
|
+
4. GitHub Actions `release.yml` publishes the Python wheel/sdist to PyPI (spec files are bundled at build time; there is no duplicate `spec/` copy in git)
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
# Design Principles
|
|
259
|
+
|
|
260
|
+
TickerForge Spec follows several principles:
|
|
261
|
+
|
|
262
|
+
* **Deterministic** — no dependency on external APIs
|
|
263
|
+
* **Exchange-aware** — rules are defined per exchange
|
|
264
|
+
* **Language-neutral** — YAML and CSV datasets usable by any language
|
|
265
|
+
* **Test-driven** — shared test cases ensure consistent behavior
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
# Contributing
|
|
270
|
+
|
|
271
|
+
Contributions are welcome.
|
|
272
|
+
|
|
273
|
+
Typical contributions include:
|
|
274
|
+
|
|
275
|
+
* new exchanges
|
|
276
|
+
* updated contract rules
|
|
277
|
+
* additional test cases
|
|
278
|
+
* corrections to metadata
|
|
279
|
+
|
|
280
|
+
Please ensure any change includes appropriate test cases.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
# License
|
|
285
|
+
|
|
286
|
+
MIT License
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# TickerForge Spec
|
|
2
|
+
|
|
3
|
+
[](https://github.com/mesias/tickerforge-spec/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
**TickerForge Spec** is the canonical specification and shared dataset used by TickerForge implementations across different programming languages.
|
|
6
|
+
|
|
7
|
+
The repository defines exchange metadata, contract rules, and test cases used to resolve financial asset tickers and derivatives contracts (futures and options).
|
|
8
|
+
|
|
9
|
+
It serves as the **source of truth** for all implementations of the TickerForge ecosystem.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Purpose
|
|
14
|
+
|
|
15
|
+
Different languages may implement their own versions of TickerForge (Python, Rust, Go, etc.).
|
|
16
|
+
|
|
17
|
+
This repository ensures that all implementations share:
|
|
18
|
+
|
|
19
|
+
* The same exchange metadata
|
|
20
|
+
* The same contract rules (futures and options)
|
|
21
|
+
* The same symbol resolution logic
|
|
22
|
+
* The same validation test cases
|
|
23
|
+
|
|
24
|
+
This guarantees **consistent behavior across languages**.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Repository Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
tickerforge-spec/
|
|
32
|
+
|
|
33
|
+
VERSION
|
|
34
|
+
|
|
35
|
+
spec/
|
|
36
|
+
exchanges/
|
|
37
|
+
b3.yaml
|
|
38
|
+
cme.yaml
|
|
39
|
+
contracts/
|
|
40
|
+
b3/
|
|
41
|
+
futures.yaml
|
|
42
|
+
options.yaml
|
|
43
|
+
cme/
|
|
44
|
+
futures.yaml
|
|
45
|
+
tests/
|
|
46
|
+
b3/
|
|
47
|
+
futures_resolve.csv
|
|
48
|
+
options_resolve.csv
|
|
49
|
+
B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz
|
|
50
|
+
cme/
|
|
51
|
+
futures_resolve.csv
|
|
52
|
+
schemas/
|
|
53
|
+
contract_cycles.yaml
|
|
54
|
+
exchange_schema.yaml
|
|
55
|
+
contracts_schema.yaml
|
|
56
|
+
options_schema.yaml
|
|
57
|
+
|
|
58
|
+
pyproject.toml
|
|
59
|
+
tickerforge_spec_data/
|
|
60
|
+
__init__.py
|
|
61
|
+
|
|
62
|
+
rust/
|
|
63
|
+
Cargo.toml
|
|
64
|
+
src/lib.rs
|
|
65
|
+
|
|
66
|
+
scripts/
|
|
67
|
+
check_versions.py
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The B3 multi-year calendar golden file is kept only as **`B3_2023_2028_WIN_IND_DOL_calendar_FIXED.csv.xz`** (semicolon-separated CSV, lzma-compressed)—no uncompressed twin is required in the repo.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
# Exchanges Metadata
|
|
75
|
+
|
|
76
|
+
Exchange files define static information such as:
|
|
77
|
+
|
|
78
|
+
* timezone
|
|
79
|
+
* trading hours
|
|
80
|
+
* supported assets and product categories
|
|
81
|
+
* exchange identifiers
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
exchange: B3
|
|
87
|
+
timezone: America/Sao_Paulo
|
|
88
|
+
|
|
89
|
+
assets:
|
|
90
|
+
WIN:
|
|
91
|
+
type: future
|
|
92
|
+
category: index
|
|
93
|
+
description: Mini Ibovespa Futures
|
|
94
|
+
trading_hours:
|
|
95
|
+
start: "09:00"
|
|
96
|
+
end: "18:25"
|
|
97
|
+
|
|
98
|
+
EQUITY_OPTIONS:
|
|
99
|
+
type: option
|
|
100
|
+
category: equity_option
|
|
101
|
+
description: Options on listed equities (PETR4, VALE3, ...)
|
|
102
|
+
trading_hours:
|
|
103
|
+
start: "10:00"
|
|
104
|
+
end: "18:25"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
# Contract Rules — Futures
|
|
110
|
+
|
|
111
|
+
Futures contract rules describe how derivatives contracts are generated and resolved.
|
|
112
|
+
|
|
113
|
+
Each contract defines its cycle (which months it trades in) and an expiration rule.
|
|
114
|
+
|
|
115
|
+
Supported expiration rule types:
|
|
116
|
+
|
|
117
|
+
* `nearest_weekday_to_day` — closest weekday to a calendar day (e.g. WIN/IND: nearest Wednesday to the 15th)
|
|
118
|
+
* `first_business_day` — first business day of the contract month (e.g. DOL, WDO, DI1)
|
|
119
|
+
* `last_business_day` — last business day of the contract month (e.g. BGI)
|
|
120
|
+
* `fixed_day` — specific calendar day, next business day if holiday (e.g. CCM: 15th)
|
|
121
|
+
* `schedule` — dates vary per contract; consult exchange maturity calendar (e.g. ICF, CL, GC)
|
|
122
|
+
|
|
123
|
+
Example:
|
|
124
|
+
|
|
125
|
+
```yaml
|
|
126
|
+
contracts:
|
|
127
|
+
- symbol: DOL
|
|
128
|
+
exchange: B3
|
|
129
|
+
ticker_format: "{symbol}{month_code}{yy}"
|
|
130
|
+
contract_cycle:
|
|
131
|
+
- F # January
|
|
132
|
+
- G # February
|
|
133
|
+
# ... all 12 months
|
|
134
|
+
expiration_rule:
|
|
135
|
+
type: first_business_day
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
These rules allow implementations to determine:
|
|
139
|
+
|
|
140
|
+
* front-month contracts
|
|
141
|
+
* expiration dates
|
|
142
|
+
* contract offsets
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
# Contract Rules — Options
|
|
147
|
+
|
|
148
|
+
Options contract rules describe how option tickers are resolved.
|
|
149
|
+
|
|
150
|
+
B3 has four categories of options, each with distinct ticker formats:
|
|
151
|
+
|
|
152
|
+
**Equity options** use a compact format where one letter encodes both the option type (call/put) and the expiration month:
|
|
153
|
+
|
|
154
|
+
* Calls: A (Jan) through L (Dec)
|
|
155
|
+
* Puts: M (Jan) through X (Dec)
|
|
156
|
+
* Ticker format: `{root}{month_code}{strike}` — e.g. `PETRA35` = Petrobras call, January, strike 35
|
|
157
|
+
|
|
158
|
+
**Index, dollar, and rate options** use futures-style month codes with an explicit call/put indicator:
|
|
159
|
+
|
|
160
|
+
* Ticker format: `{symbol}{month_code}{yy}{C|P}{strike}` — e.g. `DOLF26C005200`
|
|
161
|
+
|
|
162
|
+
Example:
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
options:
|
|
166
|
+
- type: equity
|
|
167
|
+
exchange: B3
|
|
168
|
+
option_style: american
|
|
169
|
+
ticker_format: "{root}{month_code}{strike}"
|
|
170
|
+
call_month_codes: [A, B, C, D, E, F, G, H, I, J, K, L]
|
|
171
|
+
put_month_codes: [M, N, O, P, Q, R, S, T, U, V, W, X]
|
|
172
|
+
expiration_rule:
|
|
173
|
+
type: nth_weekday
|
|
174
|
+
weekday: friday
|
|
175
|
+
nth: 3
|
|
176
|
+
underlyings:
|
|
177
|
+
- PETR4
|
|
178
|
+
- VALE3
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
# Shared Test Cases
|
|
184
|
+
|
|
185
|
+
Test cases ensure that all implementations produce identical results.
|
|
186
|
+
|
|
187
|
+
Test files use CSV format for easy maintenance and universal parsing.
|
|
188
|
+
|
|
189
|
+
**Futures** (`spec/tests/<exchange>/futures_resolve.csv`):
|
|
190
|
+
|
|
191
|
+
Columns: `symbol,date,offset,expected,comment`
|
|
192
|
+
|
|
193
|
+
```csv
|
|
194
|
+
symbol,date,offset,expected,comment
|
|
195
|
+
WIN,2026-06-01,0,WINM26,before June expiry (Jun 17) front month is June
|
|
196
|
+
DOL,2026-04-02,0,DOLK26,after Apr 1 expiry rolls to May
|
|
197
|
+
BGI,2026-06-01,0,BGIM26,after May expiry (May 29) front month is June
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Options** (`spec/tests/<exchange>/options_resolve.csv`):
|
|
201
|
+
|
|
202
|
+
Columns: `type,underlying,date,option_type,strike,offset,expected,comment`
|
|
203
|
+
|
|
204
|
+
```csv
|
|
205
|
+
type,underlying,date,option_type,strike,offset,expected,comment
|
|
206
|
+
equity,PETR4,2026-01-16,call,35,0,PETRA35,January call strike 35
|
|
207
|
+
equity,PETR4,2026-01-16,put,35,0,PETRM35,January put strike 35
|
|
208
|
+
dollar,DOL,2026-03-15,call,5200,0,DOLH26C005200,March call strike 5200
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Implementations must load these tests and verify their resolver against them.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
# Implementations
|
|
216
|
+
|
|
217
|
+
TickerForge implementations may exist in multiple languages.
|
|
218
|
+
|
|
219
|
+
Examples:
|
|
220
|
+
|
|
221
|
+
* tickerforge (Python)
|
|
222
|
+
* tickerforge-rs (Rust)
|
|
223
|
+
* tickerforge-go (Go)
|
|
224
|
+
|
|
225
|
+
All implementations should rely on this specification.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
# Versioning and Releases
|
|
230
|
+
|
|
231
|
+
This repository uses a shared root `VERSION` file as release authority.
|
|
232
|
+
|
|
233
|
+
- Tag format: `vX.Y.Z`
|
|
234
|
+
- Python package (`tickerforge-spec-data` in root `pyproject.toml`) version must match `VERSION`
|
|
235
|
+
- Rust crate under `rust/` uses the same version for local checks; it is marked `publish = false` (crates.io needs a different layout than `../spec`)
|
|
236
|
+
|
|
237
|
+
Release sequence:
|
|
238
|
+
|
|
239
|
+
1. Update `VERSION` and the `version` field in `pyproject.toml` and `rust/Cargo.toml`
|
|
240
|
+
2. Run `python scripts/check_versions.py`
|
|
241
|
+
3. Commit and tag `vX.Y.Z`
|
|
242
|
+
4. GitHub Actions `release.yml` publishes the Python wheel/sdist to PyPI (spec files are bundled at build time; there is no duplicate `spec/` copy in git)
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
# Design Principles
|
|
247
|
+
|
|
248
|
+
TickerForge Spec follows several principles:
|
|
249
|
+
|
|
250
|
+
* **Deterministic** — no dependency on external APIs
|
|
251
|
+
* **Exchange-aware** — rules are defined per exchange
|
|
252
|
+
* **Language-neutral** — YAML and CSV datasets usable by any language
|
|
253
|
+
* **Test-driven** — shared test cases ensure consistent behavior
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
# Contributing
|
|
258
|
+
|
|
259
|
+
Contributions are welcome.
|
|
260
|
+
|
|
261
|
+
Typical contributions include:
|
|
262
|
+
|
|
263
|
+
* new exchanges
|
|
264
|
+
* updated contract rules
|
|
265
|
+
* additional test cases
|
|
266
|
+
* corrections to metadata
|
|
267
|
+
|
|
268
|
+
Please ensure any change includes appropriate test cases.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
# License
|
|
273
|
+
|
|
274
|
+
MIT License
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tickerforge-spec-data"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Canonical tickerforge specification (YAML/CSV) for tickerforge-py and other consumers."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "TickerForge" }]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Homepage = "https://github.com/mesias/tickerforge-spec"
|
|
16
|
+
Repository = "https://github.com/mesias/tickerforge-spec"
|
|
17
|
+
|
|
18
|
+
[tool.hatch.build.targets.sdist]
|
|
19
|
+
include = [
|
|
20
|
+
"/spec",
|
|
21
|
+
"/tickerforge_spec_data",
|
|
22
|
+
"/README.md",
|
|
23
|
+
"/LICENSE",
|
|
24
|
+
"/VERSION",
|
|
25
|
+
"/pyproject.toml",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[tool.hatch.build.targets.wheel]
|
|
29
|
+
packages = ["tickerforge_spec_data"]
|
|
30
|
+
|
|
31
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
32
|
+
"spec" = "tickerforge_spec_data/spec"
|