项目作者: thanhnguyennguyen

项目描述 :
provide trading technical indicator values based on data of almost crypto currency exchanges
高级语言: JavaScript
项目地址: git://github.com/thanhnguyennguyen/trading-indicator.git
创建时间: 2020-01-30T01:04:36Z
项目社区:https://github.com/thanhnguyennguyen/trading-indicator

开源协议:

下载


trading-indicator

npm version

provide trading technical indicator values based on market data of almost crypto currency exchanges
https://www.npmjs.com/package/trading-indicator

☕ Give me a coffee :heart:

Installation

Node.js version 10 or later is required

  1. npm install --save trading-indicator

Fetch ticker information

  • Parameter:
    • Exchange name
    • Symbol
    • IsFuture exchange
      1. let ticker = await indicators.ticker("binance", symbol, true)
      The structure of a ticker is as follows:
      1. {
      2. 'symbol': string symbol of the market ('BTC/USD', 'ETH/BTC', ...)
      3. 'info': { the original non-modified unparsed reply from exchange API },
      4. 'timestamp': int (64-bit Unix Timestamp in milliseconds since Epoch 1 Jan 1970)
      5. 'datetime': ISO8601 datetime string with milliseconds
      6. 'high': float, // highest price
      7. 'low': float, // lowest price
      8. 'bid': float, // current best bid (buy) price
      9. 'bidVolume': float, // current best bid (buy) amount (may be missing or undefined)
      10. 'ask': float, // current best ask (sell) price
      11. 'askVolume': float, // current best ask (sell) amount (may be missing or undefined)
      12. 'vwap': float, // volume weighed average price
      13. 'open': float, // opening price
      14. 'close': float, // price of last trade (closing price for current period)
      15. 'last': float, // same as `close`, duplicated for convenience
      16. 'previousClose': float, // closing price for the previous period
      17. 'change': float, // absolute change, `last - open`
      18. 'percentage': float, // relative change, `(change/open) * 100`
      19. 'average': float, // average price, `(last + open) / 2`
      20. 'baseVolume': float, // volume of base currency traded for last 24 hours
      21. 'quoteVolume': float, // volume of quote currency traded for last 24 hours
      22. }

Available Indicators

Available Alerts

Supported exchanges

Supported interval

  • 1m : 1 minute
  • 5m: 5 minutes
  • 15m: 15 minutes
  • 30m: 30 minutes
  • 45m: 45 minutes
  • 1h : 1 hour
  • 2h : 2 hours
  • 4h : 4 hours
  • 1d : 1 day
  • 1w : 1 week
  • 1M : 1 month

Sample code

ATR (Average True Range)

  • Parameters:

    • Period: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { atr, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. let atrData = await atr(14, "close", input)
      4. console.log(atrData[atrData.length - 1])

    ADX (Average Directional Index)

  • Parameters:
    • Period: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { adx, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. let adxData = await adx(14, "close", input)
      4. console.log(adxData[adxData.length - 1])

BB (Bollinger bands)

  • Parameters:

    • Bollinger bands period: integer
    • stdDev : integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { bb, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. let bbData = await bb(50, 2, "close", input)
      4. console.log(bbData[bbData.length - 2])

    EMA (Exponential Moving Average)

    • Parameters:
      • MA period: integer
      • Input source: “open” | “high” | “low” | “close”
      • Input : detach from OHLCV
        1. const { ema, getDetachSourceFromOHLCV } = require('trading-indicator')
        2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
        3. let emaData = await ema(8, "close", input)
        4. console.log(emaData[emaData.length - 1])

IchimokuCloud

  • Parameters:

    • conversionPeriod: integer
    • basePeriod: integer
    • spanPeriod: integer
    • displacement: integer
    • Input : detach from OHLCV
      1. const { ichimokuCloud, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await ichimokuCloud(9, 26, 52, 26, input))

    MACD (Moving Average Convergence Divergence)

  • Parameters:

    • Fast period: integer
    • Slow period: integer
    • Signal period: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { macd, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await macd(12, 26, 9, "close", input))

    MFI

  • Parameters:

    • MFI period: integer
    • Input : detach from OHLCV
      1. const { mfi, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await mfi(14, input))

    CCI

  • Parameters:

    • CCI period: integer
    • Input : detach from OHLCV
      1. const { cci, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await cci(14, input))

    VWAP

  • Parameters:
    • Input : detach from OHLCV
      1. const { vwap, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await vwap(input))

OBV

  • Parameters:
    • Input : detach from OHLCV
      1. const { obv, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await obv(input))

RSI

  • Parameters:

    • RSI period: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { rsi, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await rsi(14, "close", input))

    SMA (Simple Moving Average)

  • Parameters:

    • MA period: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { sma, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. let smaData = await sma(8, "close", input)
      4. console.log(smaData[smaData.length - 1])

    Stochastic RSI

  • Parameters:

    • kPeriod: integer
    • dPeriod: integer
    • rsiPeriod: integer
    • stochasticPeriod: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { stochasticRSI, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await stochasticRSI(3, 3, 14, 14, "close", input))

    WMA (Weighted Moving Average)

  • Parameters:
    • MA period: integer
    • Input source: “open” | “high” | “low” | “close”
    • Input : detach from OHLCV
      1. const { wma, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. let wmaData = await wma(8, "close", input)
      4. console.log(wmaData[wmaData.length - 1])

KST

  • Parameters:
    • Input : detach from OHLCV
    • ROC1
    • ROC2
    • ROC3
    • ROC4
    • SMA1
    • SMA2
    • SMA3
    • SMA4
    • SignalLength
      1. const { kst, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. console.log(await kst(input, 10, 15, 20, 30, 10, 10, 10, 15, 9))

Golden cross / Death cross

  • Parameter:

    • MA_FAST (should be 50)
    • MA_SLOW (should be 200)
    • Input : detach from OHLCV

      Sample code

      1. const { goldenCross, deathCross, maCross, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. await goldenCross(50, 200, input)
      4. await deathCross(50, 200, input)
      5. // check both golden/death cross
      6. await maCross(50, 200, input) // response { goldenCross: false, deathCross: false }

    RSI in overBought/overSold area

  • Parameter:

    • RSI Period
    • OverBoughtThreshold (75)
    • OverSoldThreshold (25)
    • Input : detach from OHLCV

      Sample code

      1. const { rsiCheck, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. await rsiCheck(14, 75, 25, input)
      4. // Test RSIcheck
      5. // { overBought: false, overSold: false, rsiVal: 27.81 }

    Price crosses SMA/EMA

  • Parameter:

    • MA Period
    • Input : detach from OHLCV

      Sample code
      ```javascript
      const { priceCrossSMA, priceCrossEMA, getDetachSourceFromOHLCV } = require(‘trading-indicator’)
      const { input } = await getDetachSourceFromOHLCV(‘binance’, ‘BTC/USDT’, ‘1h’, false) // true if you want to get future market
      await priceCrossSMA(14, input)
      //Test SMA cross
      // { cross: true, direction: ‘up’ }

  1. await priceCrossEMA(14, input)
  2. // Test EMA cross
  3. // { cross: true, direction: 'down' }
  4. ```

VWAP crosses SMA/EMA

  • Parameter:

    • MA Period
    • Input : detach from OHLCV

      Sample code
      ```javascript
      const { vwapCrossSMA, vwapCrossEMA, getDetachSourceFromOHLCV } = require(‘trading-indicator’)
      const { input } = await getDetachSourceFromOHLCV(‘binance’, ‘BTC/USDT’, ‘1h’, false) // true if you want to get future market
      await vwapCrossSMA(14, input)
      //Test SMA cross
      // { cross: true, direction: ‘up’ }

  1. await vwapCrossEMA(14, input)
  2. // Test EMA cross
  3. // { cross: true, direction: 'down' }
  4. ```

KST crossing

  • Parameter:

    • Input : detach from OHLCV
    • ROC1
    • ROC2
    • ROC3
    • ROC4
    • SMA1
    • SMA2
    • SMA3
    • SMA4
    • SignalLength

      Sample code

      1. const { kstCross, getDetachSourceFromOHLCV } = require('trading-indicator')
      2. const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false) // true if you want to get future market
      3. await kstCross(input, 10, 15, 20, 30, 10, 10, 10, 15, 9)
      4. //Test KST cross
      5. // { cross: true, direction: 'up' }

Dependencies