LoginSignup
1
2

More than 5 years have passed since last update.

tulindでテクニカル分析

Last updated at Posted at 2018-09-05

概要

Sample axios,tulind

Bitmexから1分足を取得してSMAを得る
- BITMEX API doc
- https://www.bitmex.com/api/explorer/#!/Trade/Trade_getBucketed

const axios =require('axios')
var tulind = require('tulind')

const test = async ()=>{
  const res = await axios.get('https://testnet.bitmex.com/api/v1/trade/bucketed'
    +'?symbol=XBTUSD' + '&binSize=1m&partial=true&count=10&reverse=true')
  const close = res.data.map(v => v['close'])
  const sma = await tulind.indicators.sma.indicator([close], [3])
  console.log(close)
  console.log(sma)
}
test()

output

//close
[ 7338.5, 7338.5, 7338.5, 7338.5, 7339, 7339, 7338, 7341, 7341, 7345.5 ]
//sma
[ [ 7338.5,
    7338.5,
    7338.666666666666,
    7338.833333333333,
    7338.666666666666,
    7339.333333333333,
    7340,
    7342.5 ] ]

コンソール上にチャートを表示(asciichart)

const axios =require('axios')
var tulind = require('tulind')
var asciichart = require ('asciichart')

const test = async ()=>{
  const res = await axios.get('https://testnet.bitmex.com/api/v1/trade/bucketed'
    +'?symbol=XBTUSD' + '&binSize=1m&partial=true&count=50&reverse=true')
  const close = res.data.map(v => v['close'])
  const sma = await tulind.indicators.sma.indicator([close], [10])
  console.log(asciichart.plot(sma[0],{ height: 10 }))
}
test()

output

    7343.65 ┤                               ╭─╮       
    7342.00 ┤                            ╭──╯ ╰╮      
    7340.35 ┤                         ╭──╯     ╰───╮  
    7338.70 ┤                    ╭────╯            ╰╮ 
    7337.05 ┤           ╭────────╯                  ╰ 
    7335.40 ┤        ╭──╯                             
    7333.75 ┤       ╭╯                                
    7332.10 ┤     ╭─╯                                 
    7330.45 ┤   ╭─╯                                   
    7328.80 ┤ ╭─╯                                     
    7327.15 ┼─╯    
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2