You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0e78652
Browse filesBrowse the repository at this point in the historyBrowse files
fix(api)!: validate declared bar grids before feature computation (#90)
* test(api): reproduce missing-bar feature failures for issue 76
* feat(core): validate declared bar grids against real schedules for issue 76
* feat(api): validate shared v2 bar grids before feature computation
* fix(api): reject lazy null groups and document the grid migration
* docs(api): make row-mode examples explicit and cover schema rejection
* build(deps): pin merged Specs time contract for reproducible qualification
* fix(core): reject sparse fine grids without allocating every expected bar
* fix(build): qualify immutable dependencies but reject them for publication
* fix(core): reject off-grid nanoseconds before datetime conversion
Features are computed in dependency order (topological sort). Circular dependencies raise `ValueError`. The return type matches the input: `DataFrame` in, `DataFrame` out; `LazyFrame` in, `LazyFrame` out.
67
67
68
-
Input is sorted by asset and timestamp before computation. Common asset columns such as
69
-
`asset_id`, `symbol`, and `ticker` are detected automatically, and every rolling or
70
-
lagged feature is evaluated independently for each asset. If no timestamp column
71
-
exists, pass `assume_sorted=True` to make the row-order assumption explicit.
68
+
Common asset columns such as `asset_id`, `symbol`, and `ticker` are detected automatically,
69
+
and every rolling or lagged feature is evaluated independently for each asset.
70
+
The examples explicitly select `calendar=None`: their periods count observations and
71
+
input order is preserved, even when timestamps are irregular. Sort prices yourself before
72
+
deriving returns if chronological order is intended. Without timestamps, also pass
73
+
`assume_sorted=True` to assert that the supplied row order is correct.
72
74
73
75
Use `output` when requesting more than one configuration of the same feature:
Missing, duplicate or off-grid bars fail before any feature executes. The validator neither
151
+
fills prices nor changes row counts. If normalization is needed, explicitly construct the
152
+
intended schedule grid with null prices first, then derive returns. Reindexing an already-derived
153
+
return series leaves a cross-gap return intact; finite returns adjacent to missing prices are
154
+
rejected. Completeness is checked between each asset's observed endpoints, not outside unknown
155
+
dataset coverage.
156
+
157
+
Use the canonical shared `to_dict()` methods for JSON/YAML handoffs. Omitted selectors and
158
+
explicit null remain different in version 2. Legacy version-1 null metadata is unspecified,
159
+
not an intentional opt-out; migrate it explicitly or pass `calendar=None` for row mode.
160
+
This does not change legacy Specs bridges or the numerical feature kernels.
161
+
162
+
`window_unit="observation"` belongs to row mode; `"expected_bar"` belongs to a validated grid.
163
+
Neither means sessions or elapsed hours. A shortened final bar still counts as one expected
164
+
bar when `partial_bar_policy="include"`. Annualization remains a separate convention: for
165
+
example, `realized_volatility(trading_periods=252)` retains its documented numerical default.
166
+
No calendar-derived annualization factor is silently substituted.
167
+
85
168
> **Book**: [The ml4t Library Ecosystem](https://github.com/stefan-jansen/machine-learning-for-trading/blob/d2edec54b1c7a6a9d7a97d8129eb05db4491e1eb/07_defining_the_learning_task/10_ml4t_library_ecosystem.ipynb) calls `compute_features()` with names and parameter dictionaries, and compares the library RSI with a manual implementation.
86
169
87
170
## Category Reference
@@ -375,7 +458,8 @@ features:
375
458
- name: yang_zhang_volatility
376
459
```
377
460
378
-
Load with `compute_features(df, "features.yaml")`. The YAML format supports version comments and parameter documentation inline.
461
+
Load row-based features with `compute_features(df, "features.yaml", calendar=None)`.
462
+
The YAML format supports version comments and parameter documentation inline.
379
463
380
464
## Input Requirements
381
465
@@ -415,7 +499,7 @@ meta = get_registry().get("rsi")
415
499
print(meta.parameters) # {'period': 14}
416
500
417
501
# Override
418
-
result = compute_features(df, [{"name": "rsi", "params": {"period": 20}}])
502
+
result = compute_features(df, [{"name": "rsi", "params": {"period": 20}}], calendar=None)
419
503
```
420
504
421
505
Invalid parameters raise `ValueError` with the valid parameter names.
0 commit comments