npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stock-indicator

v1.0.8

Published

Stock Indicator Library

Readme

简单易用的股票指标计算库

安装

npm install stock-indicator

导入

const { MACD, RSI, BOLL, KDJ, ... } = require('stock-indicator');
// 或者
import { MACD, RSI, BOLL, KDJ, ... } from 'stock-indicator';
// 直接使用指标函数

// 也可以通过如下方式导入:
import stockIndicator from 'stock-indicator'; 
// 然后通过stockIndicator.MACD, stockIndicator.RSI, stockIndicator.BOLL, stockIndicator.KDJ调用指标函数

使用

  • MACD
const macd = MACD(CLOSE,SHORT, LONG, MID); // CLOSE为收盘价序列数组,默认参数SHORT=12,LONG=26,MID=9
  • RSI
const rsi = RSI(CLOSE,N1,N2,N3); // CLOSE为收盘价序列数组,默认参数N1=6,N2=12,N3=24
  • BOLL
const boll = BOLL(CLOSE,M); // CLOSE为收盘价序列,默认参数M=20
  • KDJ
const kdj = KDJ(HIGH, LOW, CLOSE, N, M1, M2); // HIGH为最高价序列数组, LOW为最低价数组, CLOSE为收盘价序列数组, 默认参数N=9,M1=3,M2=3
  • CCI
const cci = CCI(HIGH, LOW, CLOSE, N); // HIGH为最高价序列数组, LOW为最低价数组, CLOSE为收盘价序列数组, 默认参数N=14
  • DMI
const dmi = DMI(HIGH, LOW, CLOSE, N, M); // HIGH为最高价序列数组, LOW为最低价数组, CLOSE为收盘价序列数组, 默认参数N=14,M=6
  • DMA
const dma = DMA(CLOSE,N1,N2,M); // CLOSE为收盘价序列数组, 默认参数N1=10,N2=50,M=10
  • EXPMA
const expma = EXPMA(CLOSE,M1,M2); // CLOSE为收盘价序列数组, 默认参数M1=12,M2=50
  • MA
const ma = MA(CLOSE,...N ); // CLOSE为收盘价序列数组, 默认参数:5, 10, 20, 60,可添加多个参数,最少一个参数
v1.0.6版本新增指标:
  • TRIX
const trix = TRIX(CLOSE,N,M); // CLOSE为收盘价序列数组, 默认参数N=12,M=9
  • BRAR
const brar = BRAR(CLOSE, HIGH, LOW, OPEN, N); // CLOSE为收盘价序列数组,HIGH为最高价序列数组, LOW为最低价数组, CLOSE为收盘价序列数组,默认参数N=26
  • CR
const cr = CR(HIGH, LOW, N, M1, M2, M3, M4); // HIGH为最高价序列数组, LOW为最低价数组, 默认参数N=26,M1=10,M2=20,M3=40,M4=62
v1.0.8版本新增指标:
  • VR
const vr = VR( CLOSE, VOL, N, M); // CLOSE为收盘价序列数组, VOL为成交量序列数组, 默认参数N=26,M=6
  • OBV (此指标和某些软件的计算有微小误差,原因为计算精度影响,请注意)
const obv = OBV( CLOSE, VOL, M); // CLOSE为收盘价序列数组, VOL为成交量序列数组, 默认参数N=30
  • EMV
const emv = EMV( HIGH, LOW, VOL, N, M); // HIGH为最高价序列数组, LOW为最低价数组, VOL为成交量序列数组, 默认参数N=14,M=9

股票指标后续会逐步增加,欢迎大家提出宝贵意见。

注意

  • 所有指标函数都要求传入数组,数组中包含股票的收盘价序列、最高价序列、最低价序列、开盘价序列、成交量序列、成交额序列等数据。
  • 所有指标函数都返回一个对象,对象中包含指标名称和值的序列(数组),对应关系与输入的数组相同。
  • 所有指标函数都有默认参数,可以通过修改参数来调整计算结果。
  • 对于开发人员,请参考源代码,我们力求所有指标函数都有注释,可以查看每个指标的计算公式和和用法,但限于能力,还有很多不足,希望留言指出。
  • 对于使用者,请注意输入数据的正确性,指标函数的输出结果仅供参考,请根据自己的实际情况进行分析和决策。
  • waning: 本库还在开发中,欢迎大家提出宝贵意见。