Skip to content

feat(fees): add computeMovingAverage for fee trend smoothing (#781) - #818

Closed
ZacLou wants to merge 1 commit into
Stellar-split:mainfrom
ZacLou:feat/moving-average-fee-trend-781
Closed

ZacLou wants to merge 1 commit into
Stellar-split:mainfrom
ZacLou:feat/moving-average-fee-trend-781

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 5, 2026

Copy link
Copy Markdown

Adds a pure, stateless computeMovingAverage helper to fees/trend.ts so callers can smooth raw fee samples before percentile-based recommendation.

Changes

  • New export: computeMovingAverage(samples: number[], windowSize: number): number[]
    • Returns a Simple Moving Average series of the same length.
    • First windowSize - 1 entries are NaN (insufficient data).
    • Throws RangeError when windowSize < 1.
    • Zero side effects: input array is never mutated.
  • Tests: test/feeTrend.test.ts covers padding, hand-calculated averages, windowSize = 1, oversize window, empty input, negative window, and immutability.

Closes #781

…-split#781)

- Export pure computeMovingAverage(samples, windowSize) in fees/trend.ts
- Returns SMA series with first windowSize-1 entries padded as NaN
- Throws RangeError for windowSize < 1
- Leaves input array untouched
- Add unit tests for padding, exact averages, edge cases, and immutability

Closes Stellar-split#781
@Kingsman-99

Copy link
Copy Markdown
Contributor

Closing this PR — it was opened against an issue that wasn't assigned to you. To avoid duplicate work, please wait for an issue to be assigned before submitting a PR for it. Feel free to comment on the issue to request assignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add moving average calculation for fee trend analysis in fees/trend.ts

2 participants