invest-momo
v1.0.0
Published
NPM module to calculate RSI (22, 44, 66 days) based momentum for stocks using Yahoo Finance
Maintainers
Readme
invest-momo
A modular Node.js library for calculating momentum investing metrics based on specific RSI periods (22, 44, and 66 days).
Features
- Modular architecture with separated data fetching and calculation logic.
- Interface-based data provider system allowing for custom implementations.
- Default integration with Yahoo Finance.
- Fully written in modern JavaScript (ES Modules).
Installation
npm install invest-momoUsage
Basic Usage
The library uses a class-based architecture. Instantiate the MomentumAnalysis class to start fetching data.
import { MomentumAnalysis } from 'invest-momo';
// Create an instance (uses YahooStockData by default)
const analyzer = new MomentumAnalysis();
// Fetch and calculate momentum
const result = await analyzer.getMomentumMetrics('AAPL');
console.log(result);Output Format
{
"symbol": "AAPL",
"rsi22": 45.32,
"rsi44": 52.10,
"rsi66": 48.90,
"avgRsi": 48.77
}Custom Data Providers
You can inject your own data provider by extending the StockData interface.
import { MomentumAnalysis } from 'invest-momo';
import { YahooStockData } from 'invest-momo/lib/implementations/YahooStockData.js';
// Explicitly using the specific implementation
const yahooProvider = new YahooStockData();
const analyzer = new MomentumAnalysis(yahooProvider);Methodology
This module calculates the Relative Strength Index (RSI) over three custom lookback periods:
- 22 days (approx. 1 month)
- 44 days (approx. 2 months)
- 66 days (approx. 3 months)
These values are averaged to produce a composite momentum score (avgRsi).
Requirements
- Node.js >= 18.0.0
- NPM >= 9.0.0
License
MIT
