cinar/indicatorts
소개
TypeScript로 만든 고성능 기술적 분석 지표 및 백테스팅 프레임워크입니다. 의존성은 없습니다. ✨ 살펴보세요! 👀
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalIndicator TS
Indicator TS is a TypeScript module providing pure technical analysis mathematics, statistical calculations, and generic backtesting utilities for browser and server environments.
This is a TypeScript implementation of the Indicator Go Golang module.
Maintenance status: This project is no longer actively developed, and new features are not planned. I will do my best to review issues and pull requests. It is provided as is under the MIT License.
⚠️ Legal Disclaimers & Risk Disclosures
1. Educational and Research Purpose Only
The software, algorithms, technical indicators, mathematical formulas, demonstrative strategy examples, and backtesting utilities provided in this project are strictly for educational, research, and informational purposes. Nothing contained in this codebase, documentation, or associated examples constitutes financial, investment, legal, tax, or trading advice, nor a solicitation, recommendation, endorsement, or offer to buy or sell any security, commodity, futures contract, option, cryptocurrency, or other financial instrument.
2. Non-Advisory and Non-Fiduciary Status
The authors, maintainers, and contributors of this library are NOT registered investment advisors (RIAs), commodity trading advisors (CTAs), broker-dealers, or certified financial analysts under the jurisdiction of the U.S. Securities and Exchange Commission (SEC), Commodity Futures Trading Commission (CFTC), Financial Industry Regulatory Authority (FINRA), or any other regulatory authority worldwide. No fiduciary, advisory, or professional relationship is created through your access, use, or implementation of this software.
3. Risk of Substantial Financial Loss and Leverage
Trading in financial markets—including stocks, options, futures, foreign exchange (Forex), and cryptocurrencies—involves substantial risk of loss and is not suitable for every investor. Market values fluctuate rapidly, and the use of leverage, margin, or derivative instruments can multiply losses, potentially resulting in the total loss of capital or liabilities exceeding the initial investment. You should independently assess your risk tolerance and financial situation before engaging in any trading activity.
4. CFTC Rule 4.41: Hypothetical Performance Disclosure
HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN INHERENT LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT ACTUALLY BEEN EXECUTED, THE RESULTS MAY HAVE UNDER- OR OVER-COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY, SPREADS, COMMISSIONS, OR MARKET SLIPPAGE. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN. PAST PERFORMANCE IS NO GUARANTEE OF FUTURE RESULTS.
5. "AS IS" Warranty & Limitation of Liability
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, ACCURACY, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS, OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, FINANCIAL LOSSES, TRADING LOSSES, LOSS OF PROFITS, DATA LOSS OR CORRUPTION, SYSTEM DOWNTIME, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Indicators Provided
The following technical analysis indicators are supported by this package:
Trend Indicators
- Absolute Price Oscillator (APO)
- Aroon Indicator
- Average Directional Index (ADX)
- Balance of Power (BOP)
- Chande Forecast Oscillator (CFO)
- Commodity Channel Index (CCI)
- Detrended Price Oscillator (DPO)
- Double Exponential Moving Average (DEMA)
- Exponential Moving Average (EMA)
- Hull Moving Average (HMA)
- Kaufman's Adaptive Moving Average (KAMA)
- Know Sure Thing (KST)
- Mass Index (MI)
- McGinley Dynamic (MD)
- Moving Average Convergence Divergence (MACD)
- Moving Average Envelope
- Moving Max (MMAX)
- Moving Min (MMIN)
- Moving Sum (MSUM)
- Parabolic SAR (PSAR)
- Pivot Point
- Qstick
- Random Index (KDJ)
- Rolling Moving Average (RMA)
- Schaff Trend Cycle (STC)
- Simple Moving Average (SMA)
- Since Change
- Slope
- Slow Stochastic
- Smoothed Moving Average (SMMA)
- Stochastic
- Tillson T3 Moving Average (T3)
- Triple Exponential Moving Average (TEMA)
- Triangular Moving Average (TRIMA)
- Triple Exponential Average (TRIX)
- True Strength Index (TSI)
- Typical Price
- Volume Weighted Moving Average (VWMA)
- Vortex Indicator
- Weighted Close
- Weighted Moving Average (WMA)
Momentum Indicators
- Awesome Oscillator (AO)
- Chaikin Oscillator (CO)
- Connors RSI (CRSI)
- Coppock Curve
- Ehlers Fisher Transform
- Elder-Ray Index
- Fisher Transform
- Ichimoku Cloud
- Internal Bar Strength (IBS)
- Percentage Price Oscillator (PPO)
- Percentage Volume Oscillator (PVO)
- Price Rate of Change (ROC)
- Pring's Special K
- Relative Strength Index (RSI)
- Relative Vigor Index (RVI)
- Stochastic Oscillator (STOCH)
- Stochastic RSI (StochRSI)
- TD Sequential
- Ultimate Oscillator (UO)
- Williams R (WILLR)
Volatility Indicators
- Acceleration Bands (AB)
- Annualized Historical Volatility (AHV)
- Average True Range (ATR)
- Bollinger Bands (BB)
- Bollinger Band Width (BBW)
- Chandelier Exit (CE)
- Choppiness Index (CHOP)
- Donchian Channel (DC)
- Historical Volatility (HV)
- Keltner Channel (KC)
- Moving Standard Deviation (MSTD)
- Percent B (%B)
- Projection Oscillator (PO)
- Super Trend
- True Range (TR)
- Ulcer Index (UI)
- Z-Score
Volume Indicators
- Accumulation/Distribution (AD)
- Chaikin Money Flow (CMF)
- Ease of Movement (EMV)
- Force Index (FI)
- Klinger Volume Oscillator (KVO)
- Money Flow Index (MFI)
- Money Flow Multiplier (MFM)
- Money Flow Volume (MFV)
- Negative Volume Index (NVI)
- On-Balance Volume (OBV)
- Volume Price Trend (VPT)
- Volume Weighted Average Price (VWAP)
Valuation Functions
Strategy Primitives & Execution Abstractions
The core engine provides lightweight, generic abstractions for price bar series and trading signals:
Educational Strategy Examples
Pre-baked illustrative strategies are organized in the examples/ directory as pedagogical demonstrations showing how developers can consume indicator mathematics:
Note: The example strategies are not part of the
indicatortsnpm package, soimport { macdStrategy } from 'indicatorts'does not work. Copy the example you need into your own project, and import the indicators it uses fromindicatorts. For example:import { Action, Asset, macd } from 'indicatorts'; export function macdStrategy(asset: Asset): Action[] { const { macdLine, signalLine } = macd(asset.closings); // ... see examples/trend/macdStrategy.ts }
- Baseline Strategy: Buy and Hold Strategy
- Momentum Strategy Examples: Awesome Oscillator, Ichimoku Cloud, RSI 2, Stochastic Oscillator, Williams R
- Trend Strategy Examples: APO, Aroon, BOP, CFO, KDJ, MACD, Parabolic SAR, Typical Price, VWMA, Vortex
- Volatility Strategy Examples: Acceleration Bands, Bollinger Bands, Projection Oscillator
- Volume Strategy Examples: Chaikin Money Flow, Ease of Movement, Force Index, Money Flow Index, Negative Volume Index, VWAP
Backtest Framework
A lightweight, generic backtest utility is provided for evaluating custom strategy functions against historical data:
Chart
Chart provides utilities to plot indicator values and simulated strategies:
Build
The project can be built from source:
npm run build
Contributing
Bug reports and pull requests are welcome. Please see CONTRIBUTING.md for the development setup, coding standards and the reference data testing approach.
Usage
Install the package:
npm install indicatorts
Import and calculate technical indicators:
import { ao } from 'indicatorts';
const highs = [10, 20, 30, 40];
const lows = [1, 2, 3, 4];
// Calculate Awesome Oscillator (AO)
const result = ao(highs, lows);
Warm-up and seeding
Indicators that smooth values recursively need a starting value. This library returns an output for every input index, so it starts at the first bar, while TA-Lib and several other libraries start from a simple average of the first period values and leave the earlier outputs empty. The formulas are otherwise the same, so the outputs converge, but the first values differ.
| Building block | This library | TA-Lib |
|---|---|---|
| EMA | Starts from the first value: ema[0] = values[0] |
Starts from the SMA of the first period values, at index period - 1 |
| RMA (Wilder) | Average of the values so far until period values are available |
Same |
| RSI | Counts the first bar as a gain and loss of 0 | Starts from the second bar (the first price change) |
| ATR | Includes the first bar's true range (high minus low) | Starts from the second bar |
The difference fades over time. For a 12-period EMA on the test data, it is 0.21 at the 12th bar, 0.03 at the 24th, and below 0.004 after the 36th. Indicators built on these blocks inherit the difference: DEMA, TEMA, TRIX, MACD, APO, PPO, PVO, Chaikin Oscillator, Mass Index, Bollinger Bands Width, Keltner Channel, Chandelier Exit, Projection Oscillator and Force Index. Both conventions are supported. The building blocks and the indicators that TA-Lib also provides take a seed option: 'first' (the default) is the behavior described above, and 'sma' starts from a simple moving average and leaves the warm-up results NaN, as TA-Lib does. With seed: 'sma', these match TA-Lib's output, which the tests check against reference data generated with TA-Lib:
| Indicator | TA-Lib function |
|---|---|
ema, dema, tema |
EMA, DEMA, TEMA |
trix |
TRIX (TA-Lib returns a percentage, this library a ratio) |
macd, apo, ppo, pvo |
MACD, APO, PPO (with an EMA) |
rsi, atr |
RSI, ATR |
rma |
Wilder smoothing, as used by RSI and ATR |
import { macd, rsi } from 'indicatorts';
const { macdLine, signalLine } = macd(closings, { seed: 'sma' });
const result = rsi(closings, { period: 14, seed: 'sma' });
The other indicators built on these blocks use the default. To compare them with other libraries, skip the first few multiples of period values.
Indicators without recursive smoothing, such as SMA, Bollinger Bands, Stochastic Oscillator, Williams %R, CCI and MFI, match TA-Lib from the first full window.
The indicators ported from the Go version of this library, such as WMA, HMA, T3 and KST, follow its conventions instead: their exponential and Wilder averages start from a simple moving average, and the results that are not available yet are NaN. Each one documents its warm-up period, and the tests check them against reference data generated with the Go library.
License
The source code is provided under the MIT License.
Copyright © 2022-2026 The Indicator Authors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Trademarks
- Bollinger Bands® is a registered trademark of John Bollinger.
- All other product names, logos, and brands mentioned herein are trademarks or registered trademarks of their respective owners. Mention of third-party products, services, or trademarks is for nominative identification and educational purposes only and does not imply affiliation or endorsement.
관련 프로젝트 살펴보기
불러오는 중…