tensorchart-api
Advanced tools
Comparing version 1.0.3 to 1.0.4
const WebSocket = require('ws') | ||
const ws = new WebSocket('wss://ws-ny.tensorcharts.com/tensorWS'); | ||
const socket = (type, channel) => { | ||
const socket = (type, channel, callback) => { | ||
ws.on('open', function open() { | ||
console.log('aberto.') | ||
//console.log('aberto.') | ||
ws.send(JSON.stringify({ "type": type, "channel": channel }), (err) => { | ||
if (err) { | ||
console.log('um erro ocorreu') | ||
return err | ||
callback(err) | ||
} else { | ||
ws.on('message', async (data) => { | ||
//callback | ||
callback(data) | ||
}) | ||
@@ -15,0 +14,0 @@ } |
@@ -9,2 +9,3 @@ const { | ||
} = require("./controllers/requests"); | ||
const { socket } = require("./controllers/socket"); | ||
@@ -17,2 +18,8 @@ class tensorChart { | ||
liveChart(settings = {type: 'reg', exchangeAndPair: 'binanceBTCUSDT'}, callback){ | ||
socket(settings.type, settings.exchangeAndPair, call => { | ||
callback(JSON.parse(call)) | ||
}) | ||
} | ||
chart(candleTime) { | ||
@@ -19,0 +26,0 @@ return new Promise((resolve, reject) => { |
{ | ||
"name": "tensorchart-api", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "api for https://www.tensorcharts.com/", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -169,2 +169,14 @@ ![logo](https://github.com/victorratts13/tensorChart-api/blob/main/asset/logo.jpg?raw=true) | ||
## real time connection | ||
to realtime conncetion with websockets. use this: | ||
```js | ||
//type is reg for default | ||
//exchangeAndPair is binance-BTCUSDT default | ||
tensor.liveChart({type: 'reg', exchangeAndPair: 'binanceBTCUSDT'}, call => { | ||
console.log(call) | ||
}) | ||
``` | ||
## format tradingview export | ||
@@ -171,0 +183,0 @@ |
17
test.js
@@ -5,6 +5,6 @@ const { settings, trades, markets, orderBook, volumeCounters, heatmapCandles } = require("./controllers/requests"); | ||
const tensor = new tensorChart('binance', 'BNBBTC') | ||
//const {socket} = require("./controllers/socket"); | ||
//tensor.chart('5min').then(data => { | ||
const {socket} = require("./controllers/socket"); | ||
// tensor.chart('5min').then(data => { | ||
// console.log(data) | ||
//}) | ||
// }) | ||
@@ -15,6 +15,11 @@ //tensor.tradingViewChart('5min').then(data => { | ||
tensor.tradingViewSymbols(null).then(data => { | ||
console.log(data) | ||
// tensor.tradingViewSymbols(null).then(data => { | ||
// console.log(data) | ||
// }) | ||
tensor.liveChart({type: 'reg', exchangeAndPair: 'binanceBTCUSDT'}, call => { | ||
console.log(call) | ||
}) | ||
//socket('reg', 'binanceBTCUSDT') | ||
// socket('reg', 'binanceBTCUSDT', call => { | ||
// console.log(JSON.parse(call)) | ||
// }) | ||
@@ -21,0 +26,0 @@ //settings('binance', 'BNBBTC').then(data => { |
265582
293
260