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

mytt-ts

v1.0.1

Published

通达信、同花顺、文华麦语言等指标公式的 TypeScript 实现

Readme

MyTT-ts

npm npm bundle size npm downloads NPM License

MyTT 的 TypeScript 实现版本,将通达信、同花顺、文华麦语言等指标公式移植到 TypeScript 中。这是一个轻量级的技术分析指标库,提供了常用的股票、期货技术分析指标。

本项目是 MyTT 的 TypeScript 实现版本。

特点

  • 🎯 完全使用 TypeScript 编写,提供完整的类型定义
  • 📦 支持 ESM 和 CommonJS 两种模块规范
  • 🚀 基于数组运算,性能优异
  • 💡 API 设计与通达信、同花顺等软件保持一致
  • 🔧 不依赖其他第三方库,体积小巧
  • ✨ 支持所有主流技术指标:MACD、KDJ、RSI、BOLL等

安装

# npm
npm install mytt-ts

# yarn
yarn add mytt-ts

# pnpm
pnpm add mytt-ts

类型定义

该库提供完整的 TypeScript 类型定义:

import { Series, MACD, KDJ } from 'mytt-ts';

// 基础类型
type Series = number[];           // 数值序列
type BoolSeries = boolean[];      // 布尔序列

// 指标函数类型示例
function MACD(
  close: Series,
  short?: number,   // 默认值 12
  long?: number,    // 默认值 26
  m?: number        // 默认值 9
): [Series, Series, Series];  // 返回 [DIF, DEA, MACD]

function KDJ(
  close: Series,
  high: Series,
  low: Series,
  n?: number,       // 默认值 9
  m1?: number,      // 默认值 3
  m2?: number       // 默认值 3
): [Series, Series, Series];  // 返回 [K, D, J]

使用示例

import { MA, MACD, KDJ, Series } from 'mytt-ts';

// 定义数据
const closePrice: Series = [10, 11, 12, 11, 10];
const highPrice: Series = [12, 13, 14, 12, 11];
const lowPrice: Series = [9, 10, 11, 10, 9];

// 计算指标
const ma5 = MA(closePrice, 5);
const [dif, dea, macd] = MACD(closePrice);
const [k, d, j] = KDJ(closePrice, highPrice, lowPrice);

// 类型安全
const wrongInput: Series = ['10', 11, 12]; // TS 会报错
MA(wrongInput, 5); // TS 会报错

错误处理

所有指标函数都会对输入进行基本验证:

  • 输入序列必须是数字数组
  • 参数必须是有效的数字
  • 序列长度必须足够计算指标
import { MA, Series } from 'mytt-ts';

// 序列太短
const shortSeries: Series = [1, 2];
const ma5 = MA(shortSeries, 5); // 前面的值会是 NaN

// 处理 NaN
const result = ma5.map(v => isNaN(v) ? null : v);