Resampling, Aggregation, and Time Alignment
Install and import#
npm install fintech-algorithmsimport { resamplingAggregationAndTimeAlignment } from "fintech-algorithms/financial-mathematics-statistics-and-data-foundations/financial-time-series-foundations/resampling-aggregation-and-time-alignment";Signature#
resamplingAggregationAndTimeAlignment(input)Worked example#
verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.
Input#
{
"timestamps": [
"2025-01-01T00:00:00Z",
"2025-01-02T00:00:00Z",
"2025-01-03T00:00:00Z",
"2025-01-04T00:00:00Z",
"2025-01-05T00:00:00Z",
"2025-01-06T00:00:00Z"
],
"values": [100, 102, 101, 104, 106, 105],
"lag": 1,
"window": 3,
"resampleSize": 2,
"period": 3,
"stationarityTolerance": 3,
"alpha": 0.4,
"splitIndex": 4
}Call#
resamplingAggregationAndTimeAlignment(input)Returns#
object with 2 fields: aggregatedMeans, bucketSizes
{
"aggregatedMeans": [101, 102.5, 105.5],
"bucketSizes": [2, 2, 2]
}Diagrams#
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Time Series Plot — NIST/SEMATECH e-Handbook
- Common Pitfalls and Recommended Practices — scikit-learn
- Historical-example decision