@equitysim/trkd-client
Advanced tools
Comparing version 0.2.9 to 0.2.10
{ | ||
"name": "@equitysim/trkd-client", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "REST Client for TRKD API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,4 +5,6 @@ import timeseriesFields from './field-maps/timeseries-fields' | ||
const result = [] | ||
let previousClose = 0; | ||
for (const values of trkdResponse['R'] || []) { | ||
let previousClose = 0 | ||
const length = trkdResponse['R'] && trkdResponse['R'].length || 0 | ||
for (let i = 0; i < length; i++) { | ||
const values = trkdResponse['R'][i] | ||
const fields = {} | ||
@@ -19,4 +21,4 @@ for (const [key, value] of Object.entries(values)) { | ||
} | ||
fields.netChange = fields.close - previousClose | ||
fields.percentChange = fields.close / previousClose - 1 | ||
fields.netChange = i == 0 ? 0 : fields.close - previousClose | ||
fields.percentChange = i == 0 ? 0 : fields.close / previousClose - 1 | ||
previousClose = fields.close | ||
@@ -33,3 +35,3 @@ result.push(fields) | ||
timezone: data['Timezone'], | ||
tradingDays: data['TradingWeek']['TradingDay'].map(day => { | ||
tradingDays: data['TradingWeek']['TradingDay'].map((day) => { | ||
const values = day['Session'][0] | ||
@@ -40,5 +42,5 @@ return { | ||
endDay: values['EndDay'], | ||
endTime: values['EndTime'] | ||
endTime: values['EndTime'], | ||
} | ||
}) | ||
}), | ||
} | ||
@@ -51,3 +53,3 @@ return result | ||
const today = new Date(); | ||
const today = new Date() | ||
function formatOffset(offset) { | ||
@@ -72,3 +74,3 @@ const hours = Math.floor(offset / 60) | ||
return data.map(zone => { | ||
return data.map((zone) => { | ||
const isSummer = zone['HasSummerTime'] && new Date(zone['SummerStart']) < today && new Date(zone['SummerEnd']) > today | ||
@@ -79,5 +81,5 @@ const offset = formatOffset(isSummer ? zone['SummerOffset'] : zone['GMTOffset']) | ||
name: zone['LongName'], | ||
offset: offset | ||
offset: offset, | ||
} | ||
}) | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43318
1333