indicatorts

repository·main·Indexed 19 days ago

https://github.com/cinar/indicatorts

A TypeScript module providing stock technical analysis indicators, strategies, and a backtesting framework for browser and server programs. It includes trend, momentum, volatility, and volume indicators, as well as a charting module for visualizing outcomes on HTML canvas.

Tokens
23.6K
Snippets
122
Records
143
Agent score
66%

What's inside indicatorts

  1. Overview of available indicators

    main

    The indicatorts package provides a wide range of technical analysis indicators categorized into four main types:

    Trend Indicators

    Includes: APO, Aroon, BOP, CFO, CCI, DEMA, EMA, MI, MACD, MMAX, MMIN, MSUM, PSAR, Qstick, KDJ, RMA, SMA, Since Change, TEMA, TRIMA, TRIX, Typical Price, VWMA, and Vortex Indicator.

    Momentum Indicators

    Includes: AO, CMO, Ichimoku Cloud, PPO, PVO, ROC, RSI, STOCH, and WILLR.

    Volatility Indicators

    Includes: AB, ATR, BB, BBW, CE, DC, KC, MSTD, PO, TR, and UI.

    Volume Indicators

    Includes: AD, CMF, EMV, FI, MFI, NVI, OBV, VPT, and VWAP.

  2. Overview of available strategies and backtesting

    main

    Beyond individual indicators, the library provides built-in trading strategies and a backtesting framework.

    Strategies

    Strategies are categorized by their underlying logic:

    • Trend Strategies: e.g., MACD Strategy, Parabolic SAR Strategy, Vortex Strategy.
    • Momentum Strategies: e.g., RSI 2 Strategy, Stochastic Oscillator Strategy.
    • Volatility Strategies: e.g., Bollinger Bands Strategy, Projection Oscillator Strategy.
    • Volume Strategies: e.g., Chaikin Money Flow Strategy, VWAP Strategy.

    Backtesting and Charting

    • Backtest: Evaluate how a strategy would have performed using functions like backtest, strategyStats, and strategyResult.
    • Chart: Visualize indicator and strategy outcomes using the chart module (supports initialization, adding data, and drawing).
  3. Use Volume Strategies in indicatorts

    main

    Volume strategies generate trading signals (BUY, SELL, or HOLD) based on volume-related indicators.

    Configuration Note: All strategy configuration objects are optional. If no object is passed, the default configuration is used. You can also partially pass a configuration object, and missing properties will be filled with their default values.

  4. Use Momentum Strategies in indicatorts

    main

    Momentum strategies generate trading signals (BUY, SELL, or HOLD) based on momentum indicators.

    Configuration Note: All configuration objects for all strategies are optional. If no configuration object is passed, the default configuration will be used. You can also partially pass a configuration object to override specific properties while keeping default values for the rest.

  5. General usage pattern for Momentum Indicators

    main
    All momentum indicators in indicatorts follow a consistent configuration pattern. Configuration objects are optional. If no configuration is provided, the indicator uses its default values. You can also provide a partial configuration object, and missing properties will be filled with their respective defaults.
  6. Understand StrategyResult

    main

    A StrategyResult represents the outcome of a single strategy after a backtest has been executed. It contains:

    • info: The original StrategyInfo used.
    • gain: The numerical result (profit/loss) of the strategy at the end of the period.
    • lastAction: The final Action performed by the strategy.
  7. Understand CompanyResult

    main

    A CompanyResult aggregates the performance of multiple strategies for a specific company. It contains:

    • companyInfo: The CompanyInfo (symbol, name, sector, etc.) for the company.
    • strategyResults: An array of StrategyResult objects, one for each strategy tested.
  8. How trend strategies work in indicatorts

    main

    Trend strategies generate trading signals (BUY, SELL, or HOLD) based on the output of specific trend indicators.

    Configuration Pattern: All strategy configuration objects are optional. If you do not provide a configuration object, the strategy uses its default settings. You can also provide a partial configuration object; any missing properties will be filled with their respective default values.

  9. Understand StrategyStats

    main

    The StrategyStats object provides aggregated performance metrics for a strategy across all companies in a dataset:

    • strategyInfo: The StrategyInfo of the strategy.
    • score: The total count of times this strategy generated the highest gain among all tested strategies.
    • minGain: The minimum gain recorded.
    • maxGain: The maximum gain recorded.
    • averageGain: The average gain recorded.
  10. Understand the Asset data structure

    main

    Strategies in indicatorts operate on an Asset object. An Asset represents time-series financial data containing dates, price points (open, close, high, low), and volume.

    interface Asset {
      dates: Date[];
      openings: number[];
      closings: number[];
      highs: number[];
      lows: number[];
      volumes: number[];
    }