How to use tulind - 10 common examples

To help you get started, we’ve selected a few tulind examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github C451 / trading-vue-js / tools / og_data.js View on Github external
// OG data secured

const request = require('request')
const tulind = require('tulind')
const I = tulind.indicators
const fs = require('fs')

const write_to = './data/data.json'

const t1 = Math.floor(new Date().getTime() / 1000)
const t0 = t1 - 3600 * 4200

// Hey Coingy, we will borrow some data, ok?
const mrk = 'BITF/BTC/USD'
const url = `https://www.coinigy.com/getjson/chart_feed/${mrk}/60/${t0}/${t1}`

request
    .get(url, {}, function(err,res,body) {
        if (err) {
            console.log('Not this time, bro')
            process.exit()
github magic8bot / magic8bot / legacy / legacy_analysis / ti_macd.ts View on Github external
return new Promise((resolve, reject) => {
    if (s.lookback.length >= Math.max(shortPeriod, longPeriod)) {
      let tmpMarket = optMarket
      if (!tmpMarket) {
        tmpMarket = s.lookback.slice(0, 1000).map((x) => x.close)
        tmpMarket.reverse()
        // add current period
        tmpMarket.push(s.period.close)
      } else {
        tmpMarket = tmpMarket.map((x) => x.close)
      }
      tulind.indicators.macd.indicator([tmpMarket], [shortPeriod, longPeriod, signalPeriod], (err, result) => {
        if (err) {
          console.log(err)
          reject(err)
          return
        }

        resolve({
          macd: result[0],
          macd_histogram: result[2],
          macd_signal: result[1],
        })
      })
    } else {
      reject()
    }
  })
github magic8bot / magic8bot / legacy / legacy_analysis / ti_stoch.ts View on Github external
if (s.lookback.length >= Math.max(kPeriods, dPeriods, skPeriods)) {
      // dont calculate until we have enough data
      let tmpMarket = optMarket
      if (!tmpMarket) {
        tmpMarket = s.lookback.slice(0, 1000)
        tmpMarket.reverse()
        // add current period
        tmpMarket.push(s.period)
      }

      const tmpMarketHigh = tmpMarket.map((x) => x.high)
      const tmpMarketClose = tmpMarket.map((x) => x.close)
      const tmpMarketLow = tmpMarket.map((x) => x.low)
      // addCurrentPeriod

      tulind.indicators.stoch.indicator(
        [tmpMarketHigh, tmpMarketLow, tmpMarketClose],
        [kPeriods, skPeriods, dPeriods],
        (err, result) => {
          if (err) {
            console.log(err)
            reject(err)
            return
          }

          resolve({
            d: result[1],
            k: result[0],
          })
        }
      )
    } else {
github magic8bot / magic8bot / legacy / legacy_analysis / ti_stochrsi.ts View on Github external
let tmpMarket = optMarket
    if (!tmpMarket) {
      tmpMarket = s.lookback.slice(0, 1000).map((x) => x.close)
      tmpMarket.reverse()
      // add current period
      tmpMarket.push(s.period.close)
    } else {
      tmpMarket = tmpMarket.map((x) => x.close)
    }

    if (tmpMarket.length >= rsiPeriod) {
      // doublecheck length.
      if (tmpMarket.length >= rsiPeriod) {
        // extract int from string input for ma_type

        tulind.indicators.rsi.indicator([tmpMarket], [rsiPeriod], (err, result) => {
          if (err) {
            console.log(err)
            reject(err)
            return
          }
          const trsi = result[0]
          // 0 oldest -- end newest
          trsi.reverse()
          const stochRSI = []

          for (let i = 0; i < kPeriods + dPeriods - 1; i++) {
            const rsiForPeriod = trsi.slice(i, rsiPeriod + i)
            const highestRSI = Math.max(...rsiForPeriod)
            const lowestRSI = Math.min(...rsiForPeriod)

            if (highestRSI === lowestRSI) {
github magic8bot / magic8bot / legacy / legacy_analysis / ti_rsi.ts View on Github external
let tmpMarket = optMarket
    if (!tmpMarket) {
      tmpMarket = s.lookback.slice(0, 1000).map((x) => x.close)
      tmpMarket.reverse()
      // add current period
      tmpMarket.push(s.period.close)
    } else {
      tmpMarket = tmpMarket.map((x) => x.close)
    }

    if (tmpMarket.length >= rsiPeriod) {
      // doublecheck length.
      if (tmpMarket.length >= rsiPeriod) {
        // extract int from string input for ma_type

        tulind.indicators.rsi.indicator([tmpMarket], [rsiPeriod], (err, result) => {
          if (err) {
            console.log(err)
            reject(err)
            return
          }
          resolve({
            rsi: result[0],
          })
        })
      } else {
        reject('MarketLenth not populated enough')
      }
    } else {
      reject('MarketLenth not populated enough')
    }
  })
github drewcummins / hodlol / app / model / signal / macd.js View on Github external
async evaluate(ticker) {
    let series = ticker.series;
    if (series && series.length() >= this.periods[2]) {
      let slice = series.transpose(this.props, this.periods[2] * 5); // this grabs the desired properties from the series
      let last = series.last();
      // [macd, macd signal, macd histogram]
      let [foo, bar, histo] = await tulind.indicators.macd.indicator(slice, this.periods);
      if (this.hasBuySignal(histo)) return sig.BUY;
      else if (this.hasSellSignal(histo)) return sig.SELL;
    }
    return sig.PASS;
  }
github magic8bot / magic8bot / legacy / legacy_analysis / ti_hma.ts View on Github external
if (s.lookback.length > s.marketData.close.length) {
      for (let i = s.lookback.length - s.marketData.close.length - 1; i >= 0; i--) {
        s.marketData.close.push(s.lookback[i].close)
      }
    }

    if (s.marketData.close.length < minPeriods) {
      resolve()
      return
    }

    const tmpClose = s.marketData.close.slice()
    tmpClose.push(s.period.close)

    ti.indicators.hma.indicator([tmpClose], [trendFull], (err, results) => {
      resolve(results[0][results[0].length - 1])
    })
  })
}
github drewcummins / hodlol / src / models / indicator / obv.ts View on Github external
public async evaluate(ticker:OHLCVTicker):Promise {
    let series = ticker.series;
    if (series && series.length() > 0) {
      let slice:Number[][] = series.transpose(this.props, 50);
      let last:Tick = series.last();
      let obv = await tulind.indicators.obv.indicator(slice, []);
      if (this.hasBuySignal(obv[0])) return Signal.BUY;
      else if (this.hasSellSignal(obv[0])) return Signal.SELL;
    }
    return Signal.PASS;
  }
github magic8bot / magic8bot / src / strategy / indicators / tulind.ts View on Github external
export const Tulind = (indicatorName: keyof Indicators) => {
  const indicator = tulind.indicators[indicatorName].indicator
  return (inputs: number[], options: number[] = null) =>
    new Promise((resolve, reject) => indicator(inputs, options, (err, result) => (err ? reject(err) : resolve(result))))
}
github askmike / gekko / core / tulind.js View on Github external
return (data, callback) => execute(callback, {
            indicator: tulind.indicators.mass,
            inputs: [data.high, data.low],
            options: [params.optInTimePeriod],
            results: ['result'],
        });
    }

tulind

Tulip Indicators Wrapper Providing Over 100 Technical Analysis Functions

LGPL-3.0
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular tulind functions