Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stockshark-channels

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stockshark-channels - npm Package Compare versions

Comparing version 1.0.254 to 1.0.255

2

package.json
{
"name": "stockshark-channels",
"version": "1.0.254",
"version": "1.0.255",
"description": "provide channels",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -13,3 +13,3 @@ const SourceProvider = require('./sourceProvider')

async createChannel(channelTask, indicatorDescriptors) {
const source = await this.sourceProvider.getSource(channelTask.source, channelTask.cache, channelTask.period.onlyTradingDays)
const source = await this.sourceProvider.getSource(channelTask.source, channelTask.cache)
// const indicatorDescriptor = indicatorDescriptors[channelTask.indicator]

@@ -16,0 +16,0 @@ // const channel = indicators[indicatorDescriptor.function](source, indicatorDescriptor.params)

@@ -18,6 +18,6 @@ const { util, moment, market, marketCalculator } = require('stockshark-util')

async getSource(source, fromCache, onlyTradingDays) {
async getSource(source, fromCache) {
const toDateStr = fromCache ? config.CACHE_TO_DATE : util.nowETDateString()
const fromDateStr = marketCalculator.calcFromDate(toDateStr, config.SOURCE_DATA_LENGTH, onlyTradingDays)
const fromDateStr = marketCalculator.calcFromDate(toDateStr, config.SOURCE_DATA_LENGTH)

@@ -56,3 +56,3 @@ //no cache in prediction mode and toDateStr is null

const preferredSource = fromCache ? config.ALPHAVANTAGE : config.FINANCIALMODELINGPREP
sourceData = await this.getSourceData(source, fromDateStr, toDateStr, preferredSource, onlyTradingDays)
sourceData = await this.getSourceData(source, fromDateStr, toDateStr, preferredSource)
}

@@ -142,3 +142,3 @@

async getSourceData(source, fromDateStr, toDateStr, preferredSource, onlyTradingDays) {
async getSourceData(source, fromDateStr, toDateStr, preferredSource) {
let provider1 = preferredSource == config.ALPHAVANTAGE ? this.alphavantage : this.financialmodelingprep

@@ -149,5 +149,5 @@ let provider2 = preferredSource == config.ALPHAVANTAGE ? this.financialmodelingprep : this.alphavantage

case "currency":
result = await this._getCurrency(provider1, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getCurrency(provider1, source.name, fromDateStr, toDateStr);
if (result == null) {
result = await this._getCurrency(provider2, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getCurrency(provider2, source.name, fromDateStr, toDateStr);
}

@@ -157,5 +157,5 @@ break;

case "index":
result = await this._getStock(provider1, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getStock(provider1, source.name, fromDateStr, toDateStr);
if (result == null) {
result = await this._getStock(provider2, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getStock(provider2, source.name, fromDateStr, toDateStr);
}

@@ -165,5 +165,5 @@ break;

case "stock":
result = await this._getStock(provider1, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getStock(provider1, source.name, fromDateStr, toDateStr);
if (result == null) {
result = await this._getStock(provider2, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getStock(provider2, source.name, fromDateStr, toDateStr);
}

@@ -173,5 +173,5 @@ break;

case "etf":
result = await this._getStock(provider1, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getStock(provider1, source.name, fromDateStr, toDateStr);
if (result == null) {
result = await this._getStock(provider2, source.name, fromDateStr, toDateStr, onlyTradingDays);
result = await this._getStock(provider2, source.name, fromDateStr, toDateStr);
}

@@ -181,3 +181,3 @@ break;

case "effect":
result = effects[source.name](fromDateStr, toDateStr, onlyTradingDays);
result = effects[source.name](fromDateStr, toDateStr);
break;

@@ -197,3 +197,3 @@ }

async _getStock(provider, name, fromDateStr, toDateStr, onlyTradingDays) {
async _getStock(provider, name, fromDateStr, toDateStr) {
const log = `getStock (${provider.name}): ${name}, ${fromDateStr} - ${toDateStr}`

@@ -231,3 +231,3 @@ console.log(`${log}...`)

const result = this._extractSourceData(downloadResult, fromDateStr, toDateStr, onlyTradingDays)
const result = this._extractSourceData(downloadResult, fromDateStr, toDateStr)
console.log(`${log}... SUCCESS`)

@@ -237,3 +237,3 @@ return result

async _getCurrency(provider, name, fromDateStr, toDateStr, onlyTradingDays) {
async _getCurrency(provider, name, fromDateStr, toDateStr) {
const log = `getCurrency (${provider.name}): ${name}, ${fromDateStr} - ${toDateStr}`

@@ -259,3 +259,3 @@ console.log(`${log}...`)

const result = this._extractSourceData(downloadResult, fromDateStr, toDateStr, onlyTradingDays)
const result = this._extractSourceData(downloadResult, fromDateStr, toDateStr)
console.log(`${log}... SUCCESS`)

@@ -265,3 +265,3 @@ return result

_extractSourceData(downloadResult, fromDateStr, toDateStr, onlyTradingDays) {
_extractSourceData(downloadResult, fromDateStr, toDateStr) {
let channel = {

@@ -280,3 +280,2 @@ data: {

channel.meta.toDateTime = moment.tz(toDateStr, downloadResult.timeZone).hour(16).valueOf()
channel.meta.onlyTradingDays = onlyTradingDays

@@ -305,3 +304,3 @@ let currDateStr = downloadResult.downloadFromDateStr

const saveRecord = startReached && (onlyTradingDays && market.isTradingDay(currDateStr))
const saveRecord = startReached && market.isTradingDay(currDateStr)

@@ -308,0 +307,0 @@ if (saveRecord) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc