1.1.0 • Published 1 year ago

@bytewaveco/signal v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

CodeQL CI Packages Released

Signal

Signal is a combination of MACD, EMA, and Williams %R. Signal offers a configurable set of financial indicators that can be used to determine whether a stock is overbought or oversold.

Generating signals provides actual determined output of the indicators, which can be used to visualize the performance of the parameters.

Installation

npm install @bytwaveco/signal

Usage

import { signal } from "@bytwave/signal";

// Compatible with any financial source that provides candles
const myFinData = [
  {
    open: 100,
    close: 105,
    low: 95,
    high: 110,
    timestamp: "2022-01-01T12:00:00.000Z",
  },

  // ...

  {
    open: 113,
    close: 115,
    low: 101,
    high: 115,
    timestamp: "2022-01-01T12:30:00.000Z",
  },
];

const signals = signal(myFinData);

// Use calculated signals in your application

Configuration

Signal is configurable using the options argument as shown below:

// ...

const signals = signal(myFinData, {
  emaPeriod: 10,
});

// ...

Available options are:

ParameterDescription
openKeyThe object key to treat as a candle open. Default open.
closeKeyThe object key to treat as a candle close. Default close.
lowKeyThe object key to treat as a candle low. Default low.
highKeyThe object key to treat as a candle high. Default high.
timestampISO8601KeyThe object key to treat as a candle ISO8601 timestamp. Default timestamp.
emaPeriodNumber of samples to take when generating EMA. Default 30.
emaBuyRatioThe EMA buy filter relative ratio. Default 0.005.
emaSellRatioThe EMA sell filter relative ratio. Default 0.005.
macdFastPeriodNumber of samples to take for the fast parameter in MACD. Default 5.
macdSlowPeriodNumber of samples to take for the slow parameter in MACD. Default 10.
macdSignalPeriodNumber of samples to take for the signal parameter in MACD. Default 7.
williamsRPeriodNumber of samples to take when generating Williams %R. Default 20.

Output

Signal's output is an array of objects with the following common properties:

PropertyDescription
openThe open price of the candle.
closeThe close price of the candle.
highThe high price of the candle.
lowThe low price of the candle.
timestampThe ISO8601 timestamp of the candle.
emaThe EMA value of the candle.
emaBuyThe EMA buy threshold of the candle.
emaSellThe EMA sell threshold of the candle.
macdThe MACD value of the candle.
macdSignalThe MACD signal value of the candle.
macdHistogramThe MACD histogram value of the candle.
isIntersectingFlag if the MACD line crosses the Signal line.
williamsRThe Williams %R value of the candle.
signalbuy, sell, or hold