Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// The connection was closed
stream.on('close', function() {
clients.splice(clients.indexOf(stream), 1);
console.log('Closed connection ');
});
});
});
// ===============================================================================
// Binance API / webSocket
const binance = require('node-binance-api');
binance.options({
APIKEY: '',
APISECRET: '',
useServerTime: true, // If you get timestamp errors, synchronize to server time at startup
test: false // If you want to use sandbox mode where orders are simulated
});
// --------- BTCUSDT ---------
var gameTimeCounter = 0;
var startBtcPrice = 0;
var endBtcPrice = 0;
// For a specific symbol:
binance.websockets.prevDay('BTCUSDT', (error, response) => {
// var t = new Date( response.eventTime );
// var formatted = t.format("dd.mm.yyyy hh:MM:ss");
module.exports = function(models,clients){
const binance = require('node-binance-api')().options({
APIKEY: '',
APISECRET: '',
useServerTime: true, // If you get timestamp errors, synchronize to server time at startup
test: false // If you want to use sandbox mode where orders are simulated
})
// --------- BTCUSDT ---------
const BTCUSDT_20 = 10;
var Btcusdt = models.btcusdt_table;
var initTimer = new Date().getTime() + BTCUSDT_20*1000;
var thisGameId = Math.round(initTimer/1000);
var nextGameId = thisGameId+BTCUSDT_20;
var gameStartBtcPrice = 0;
var gameEndBtcPrice = 0;
start: function(next) {
binance.options({
"APIKEY": vars.options.binance.key,
"APISECRET": vars.options.binance.secret,
useServerTime: true,
reconnect: false
})
var oldLog = console.log
console.log = function() {
if(vars.options.verbose) oldLog.apply(console, arguments)
}
exchUtils.initExchangeInfo(function(error) {
if(error) {
console.log("Error initializing exchange info.", error)
if(next) next("Error initializing exchange info.")
return
constructor(props) {
super(props);
this.state = {
currentPrice: 15290,
boughtPrice: 15290,
diffPercentage : 0.01,
messages: []
}
binance.options({
APIKEY: props.opts.binance.key,
APISECRET: props.opts.binance.secret,
recvWindow: 60000
})
}
componentDidMount = () => {
binance.options({
APIKEY: this.props.opts.binance.key,
APISECRET: this.props.opts.binance.secret,
reconnect: false,
test: true,
});
this.getCryptoList();
this.bindSocket(this.state.selectedCrypto.symbol);
};