trading-indicator

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
npm install --save trading-indicator
- Parameter:
- Exchange name
- Symbol
- IsFuture exchange
let ticker = await indicators.ticker("binance", symbol, true)
The structure of a ticker is as follows:
{
'symbol': string symbol of the market ('BTC/USD', 'ETH/BTC', ...)
'info': { the original non-modified unparsed reply from exchange API },
'timestamp': int (64-bit Unix Timestamp in milliseconds since Epoch 1 Jan 1970)
'datetime': ISO8601 datetime string with milliseconds
'high': float,
'low': float,
'bid': float,
'bidVolume': float,
'ask': float,
'askVolume': float,
'vwap': float,
'open': float,
'close': float,
'last': float,
'previousClose': float,
'change': float,
'percentage': float,
'average': float,
'baseVolume': float,
'quoteVolume': float,
}
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
const { atr, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
let atrData = await atr(14, "close", input)
console.log(atrData[atrData.length - 1])
ADX (Average Directional Index)
- Parameters:
- Period: integer
- Input source: “open” | “high” | “low” | “close”
- Input : detach from OHLCV
const { adx, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
let adxData = await adx(14, "close", input)
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
const { bb, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
let bbData = await bb(50, 2, "close", input)
console.log(bbData[bbData.length - 2])
EMA (Exponential Moving Average)
- Parameters:
- MA period: integer
- Input source: “open” | “high” | “low” | “close”
- Input : detach from OHLCV
const { ema, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
let emaData = await ema(8, "close", input)
console.log(emaData[emaData.length - 1])
IchimokuCloud
- Parameters:
- conversionPeriod: integer
- basePeriod: integer
- spanPeriod: integer
- displacement: integer
- Input : detach from OHLCV
const { ichimokuCloud, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
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
const { macd, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
console.log(await macd(12, 26, 9, "close", input))
MFI
- Parameters:
- MFI period: integer
- Input : detach from OHLCV
const { mfi, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
console.log(await mfi(14, input))
CCI
- Parameters:
- CCI period: integer
- Input : detach from OHLCV
const { cci, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
console.log(await cci(14, input))
VWAP
- Parameters:
- Input : detach from OHLCV
const { vwap, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
console.log(await vwap(input))
OBV
- Parameters:
- Input : detach from OHLCV
const { obv, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
console.log(await obv(input))
RSI
- Parameters:
- RSI period: integer
- Input source: “open” | “high” | “low” | “close”
- Input : detach from OHLCV
const { rsi, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
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
const { sma, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
let smaData = await sma(8, "close", input)
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
const { stochasticRSI, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
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
const { wma, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
let wmaData = await wma(8, "close", input)
console.log(wmaData[wmaData.length - 1])
KST
- Parameters:
- Input : detach from OHLCV
- ROC1
- ROC2
- ROC3
- ROC4
- SMA1
- SMA2
- SMA3
- SMA4
- SignalLength
const { kst, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
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
const { goldenCross, deathCross, maCross, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
await goldenCross(50, 200, input)
await deathCross(50, 200, input)
await maCross(50, 200, input)
RSI in overBought/overSold area
-
Parameter:
- RSI Period
- OverBoughtThreshold (75)
- OverSoldThreshold (25)
- Input : detach from OHLCV
Sample code
const { rsiCheck, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
await rsiCheck(14, 75, 25, input)
Price crosses SMA/EMA
-
Parameter:
- MA Period
- Input : detach from OHLCV
Sample code
const { priceCrossSMA, priceCrossEMA, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
await priceCrossSMA(14, input)
await priceCrossEMA(14, input)
```
VWAP crosses SMA/EMA
-
Parameter:
- MA Period
- Input : detach from OHLCV
Sample code
const { vwapCrossSMA, vwapCrossEMA, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
await vwapCrossSMA(14, input)
await vwapCrossEMA(14, input)
KST crossing
-
Parameter:
- Input : detach from OHLCV
- ROC1
- ROC2
- ROC3
- ROC4
- SMA1
- SMA2
- SMA3
- SMA4
- SignalLength
Sample code
const { kstCross, getDetachSourceFromOHLCV } = require('trading-indicator')
const { input } = await getDetachSourceFromOHLCV('binance', 'BTC/USDT', '1h', false)
await kstCross(input, 10, 15, 20, 30, 10, 10, 10, 15, 9)
Dependencies
评论