Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let coms = [] as Redis.Coms
let dids = {} as Dict
let scoms = new redis.SetsComs(rkeys.RH.SYMBOLS)
results.forEach(function(v) {
dids[v.id] = v.symbol
scoms.sadd(v.symbol)
v.mic = _.compact(v.market.split('/')).pop()
v.acronym = robinhood.MICS[v.mic]
v.alive = v.state == 'active' && v.tradability == 'tradable' && v.tradeable == true
coms.push(['hmset', `${rkeys.RH.INSTRUMENTS}:${v.symbol}`, v as any])
})
coms.push(['hmset', rkeys.RH.IDS, dids as any])
scoms.merge(coms)
await redis.main.coms(coms)
return next || pForever.end
}, 'https://api.robinhood.com/instruments/')
console.info('syncInstruments -> done')
pForever(async () => {
try {
if (this._destroyed) return pForever.end
this._delayedPromise = delay(ms)
await this._delayedPromise
if (this._destroyed) return pForever.end
const newMS = await this._job(this)
if (Number.isInteger(newMS)) {
ms = newMS
} else {
ms = this._ms
}
} catch (err) {
console.warn(`Error in Task ${this._id}`, err.message)
}
}).finally(() => {
this.emit('destroy')
if (process.env.DEVELOPMENT) {
console.log('syncInstruments ->', response.results.length, response.next)
}
let coms = [] as Redis.Coms
let symbols = new redis.SetsComs(rkeys.RH.SYMBOLS)
response.results.forEach(function(v) {
symbols.sadd(v.symbol)
v.mic = _.compact(v.market.split('/')).pop()
v.acronym = robinhood.MICS[v.mic]
v.alive = v.state == 'active' && v.tradability == 'tradable' && v.tradeable == true
coms.push(['hmset', `${rkeys.RH.INSTRUMENTS}:${v.symbol}`, v as any])
})
symbols.merge(coms)
await redis.main.coms(coms)
return response.next || pForever.end
}, 'https://api.robinhood.com/instruments/')
return pForever(previousVal => {
handleLambdaCallback(kwargs, previousVal);
readerIndex++;
return readerIndex < kwargs.NumberOfRuns
? receiveMessages(kwargs)
: pForever.end;
}, []);
}
await pforever(function(url) {
if (url) return onUrl(url);
return pforever.end
}, 'https://api.robinhood.com/instruments/')
}
await pForever(async url => {
config.url = url
let { results, next } = await http.request(config) as Robinhood.Api.Paginated
results.forEach(v => {
core.fix(v, true)
items.push(v)
})
return next || pForever.end
}, config.url)
return items