Comments (7)
Could you run your code using DEBUG=cewsc:Client
. There mighty be a pb in your kline handler. Data passed to the handler is already an object and will fail on JSON.parse
from crypto-exchanges-gateway.
Sorry, I don't understand how to use that property or flag. As a parameter starting the crytpo-exchange-gateway? Or in my code? I'm running it in debug with Visual Studio Code, it is an additional parameter?
from crypto-exchanges-gateway.
When running the code which is connectant to the gateway DEBUG=cewsc:Client node bot.js
. This will enable debug of the ws client
from crypto-exchanges-gateway.
You can wrap your event handler with a try...catch
to see the problem
this.client.on('kline', (data) => {
log.debug('WS CEG MSG:' + data);
try {
const datajson = JSON.parse(data)
if (datajson && datajson.d) {
if (datajson.d.data.closed === false) {
log.debug('WS CEG data but NOT closed Candle')
}
if (datajson.d.data.closed === true) {
log.info('WS CEG of CLOSED Candle:' + datajson)
//const pairReversed = stringUtils.getSymbolForExchange(symbol, 'ceg')
const evt_name = 'candle_' + _this.symbols + '-' + datajson.d.interval
// adding data interval/timeframe to data candle
datajson.d.data['timeframe'] = datajson.d.interval
log.info(_this.symbols + ' - CANDLE close:' + JSON.stringify(datajson.d.data + ' emitting event candle:' + evt_name));
vorpal.log(_this.symbols + ' - CANDLE close:' + JSON.stringify(datajson.d.data + ' emitting event candle:' + evt_name));
_this.emit(evt_name, datajson.d.data);
}
}
}
catch (e) {
console.log(e);
}
});
You should have an error similar to SyntaxError: Unexpected token o in JSON at position 1
since you're trying to call JSON.parqe
on an object instead of a string
from crypto-exchanges-gateway.
Ok. I tried but I couldn't see any differences.
Anyway it seems I found the solution. I don't know exactly why now works, before the client was initialized on the constructor of the class and then calling a method of the class I used "this.client...". Anyway connection worked ..but I had that problem. Removing this from constructor and initializing it directly on the method ..works. Ok :)
from crypto-exchanges-gateway.
The data
object emitted by the library is similar to
{ pair: 'USDT-ETH',
interval: '4h',
data:
{ timestamp: 1568001600,
open: 178.25,
close: 177.47,
high: 179.01,
low: 177,
volume: 33932.89887,
remainingTime: 2347,
closed: false },
exchange: 'binance' }
from crypto-exchanges-gateway.
P.s: before trying moving the initializing I tried the snippet you gave me on the other issue and ..it worked perfectly. So, I checked deeply the differences on my code ..so I tried in that way.
Thank you for the kindly support!
from crypto-exchanges-gateway.
Related Issues (20)
- npm install ERROR HOT 3
- Add cfg.exchanges.kucoin.password into environment variables HOT 3
- Tiny issue of the doc HOT 1
- Okex doesn't work HOT 13
- DeFi exchanges (PancakeSwap) and BSC donation address HOT 1
- Completed orders incorrectly sorted in UI when some orders are cancelled (Binance) HOT 2
- Updating pair in url (myOrders view) does not refresh pair chooser HOT 1
- Looking to autosell BTC/ETH HOT 6
- Bug in your websocket connection file + a few fixes HOT 4
- In Localhost installation, can only view "prices", & Order Books HOT 5
- Implement Kucoin V2 API HOT 2
- Crypto-exchange : dummy ethers HOT 1
- Klines for exchanges that only have a trades websocket? HOT 6
- MaxListenersExceededWarning HOT 8
- Question: WS kline or polling history candles? HOT 2
- Setting ports on docker command does not work HOT 1
- Install issue HOT 10
- Filter trade notifications to only emit my exchange's account trades HOT 5
- Could not query exchange for pair HOT 46
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crypto-exchanges-gateway.