-
Notifications
You must be signed in to change notification settings - Fork 3
/
basic-chart.js
26 lines (19 loc) · 944 Bytes
/
basic-chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"use strict";
const ccxt = require ('../../ccxt.js')
const asciichart = require ('asciichart')
const asTable = require ('as-table')
const log = require ('ololog').configure ({ locate: false })
require ('ansicolor').nice
//-----------------------------------------------------------------------------
;(async function main () {
// experimental, not yet implemented for all exchanges
// your contributions are welcome ;)
const index = 4 // [ timestamp, open, high, low, close, volume ]
const ohlcv = await new ccxt.okcoin ().fetchOHLCV ('BTC/USD', '15m')
const lastPrice = ohlcv[ohlcv.length - 1][index] // closing price
const series = ohlcv.map (x => x[index]) // closing price
const bitcoinRate = ('₿ = $' + lastPrice).green
const chart = asciichart.plot (series, { height: 15, padding: ' ' })
log.yellow ("\n" + chart, bitcoinRate, "\n")
process.exit ()
}) ()