Skip to content

Implement Spencer's 15-Point Moving Average #808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 19, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 26, 2025

This PR adds Spencer's 15-Point Moving Average (SMA15), a specialized weighted moving average designed for optimal data smoothing while preserving trend characteristics.

Implementation Details

Spencer's 15-Point Moving Average uses a fixed 15-point window with specific weights:

[-3, -6, -5, 3, 21, 46, 67, 74, 67, 46, 21, 3, -5, -6, -3]

These weights sum to 320, which is used as the denominator for the weighted average calculation.

Changes

  • Added src/SMA15/SMA15.ts with both standard and faster implementations
  • Added comprehensive tests in src/SMA15/SMA15.test.ts
  • Updated exports in index.ts
  • Added entry in README.md

Usage

import {SMA15} from 'trading-signals';

const sma15 = new SMA15();

// Add values to fill the 15-point window
for (let i = 0; i < 15; i++) {
  sma15.add(i);
}

// Get the Spencer's 15-point weighted average
const result = sma15.getResult();

Unlike other moving averages in the library that take a customizable interval parameter, Spencer's 15-Point Moving Average always uses 15 points with the predefined weights.

Fixes #807.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Feature request: Spencer's 15-Point Moving Average Implement Spencer's 15-Point Moving Average May 26, 2025
@Copilot Copilot AI requested a review from bennycode May 26, 2025 10:34
Copilot finished work on behalf of bennycode May 26, 2025 10:34
@bennycode bennycode marked this pull request as ready for review June 18, 2025 14:37
@bennycode bennycode merged commit 1b81d80 into main Jun 19, 2025
3 checks passed
@bennycode bennycode deleted the copilot/fix-807 branch June 19, 2025 09:59
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.

Feature request: Spencer's 15-Point Moving Average
2 participants