Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
let rateBTCUSD;
let advisorInfo = {};
let clientMessage = {};
let liveData = {
activeLoans: [],
openOffers: [],
};
let config = {};
self.config = config;
let apiCallTimes = [];
let waitOneMinute = null;
let callsLast100 = [];
let bfxPublic = new Bitfinex(null, null, { version: 1, autoOpen: false }).rest;
let poloPublic = new Poloniex();
let _debugApiCallDuration = _.bind(debugApiCallDuration, this);
let _debugCycleDuration = _.bind(debugCycleDuration, this);
const isWriteAllowed = function isWriteAllowed(cliendId) {
let authClient = _.find(authClients, { id: cliendId });
return authClient && authClient.isReadWriteAllowed;
};
const isReadAllowed = function isReadAllowed(cliendId) {
let authClient = _.find(authClients, { id: cliendId });
return authClient && authClient.isReadAllowed;
};
const authClientsEmit = function authClientsEmit() {
function wsClient() {
if (!ws_client) {
if (!conf.bitfinex || !conf.bitfinex.key || conf.bitfinex.key === 'YOUR-API-KEY') {
throw new Error('please configure your Bitfinex credentials in ' + path.resolve(__dirname, 'conf.js'))
}
ws_connecting = true
ws_connected = false
ws_client = new BFX(conf.bitfinex.key, conf.bitfinex.secret, { version: 2, transform: true }).ws
ws_client
.on('open', wsOpen)
.on('close', wsClose)
.on('error', wsError)
.on('subscribed', wsSubscribed)
.on('message', wsMessage)
.on('trade', wsUpdateTrades)
.on('ticker', wsUpdateTicker)
.on('ws', updateWallet)
.on('wu', updateWallet)
.on('on', wsUpdateOrder)
.on('on-req', wsUpdateReqOrder)
.on('ou', wsUpdateOrder)
.on('oc', wsUpdateOrderCancel)
.on('miu', marginSymbolWebsocket)
function publicClient() {
if (!public_client) public_client = new BFX(null, null, { version: 2, transform: true }).rest
return public_client
}
var Trader = function(config) {
_.bindAll(this);
if(_.isObject(config)) {
this.key = config.key;
this.secret = config.secret;
}
this.name = 'Bitfinex';
this.balance;
this.price;
this.asset = config.asset;
this.currency = config.currency;
this.pair = this.asset + this.currency;
this.bitfinex = new Bitfinex.RESTv1({apiKey: this.key, apiSecret: this.secret, transform: true});
this.interval = 4000;
}