Skip to content

Commit 8f17ca3

Browse files
committed
Fix two typos causing reference errors.
1 parent f30ddc3 commit 8f17ca3

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

findOuterPivotsOnLowerVolume.js

+35-24
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030

3131
const tickers = require('./stockList.js');
32-
const state = require('./src/stockstate.js');
32+
const state = require('./src/stockData.js');
3333

3434
const createThrottle = require('./src/createThrottle.js');
3535
const throttle = createThrottle(1, 1900);
@@ -61,33 +61,39 @@ const filter = process.argv[2] ? [
6161
'signal.date === process.argv[2]'
6262
].join(' && ') : undefined;
6363

64-
(function() {
6564

66-
// Create an array containing a promise for each ticker request.
67-
// Requests get individual catch blocks, so if one fails the rest can continue.
68-
const tickerRequests = tickers.map(async (ticker) => {
69-
try {
70-
await throttle();
71-
72-
// Check for local data for this ticker first before retrieval.
73-
const localFile = disk.readStockDataFromDisk(ticker);
74-
let parsedData = await fetchStock(ticker, needsFullRetrieval(localFile));
75-
// If local data exists, merge with fetched data.
76-
if (localFile.lastDateRetrieved && localFile.data) {
77-
parsedData = disk.mergeNewAndExistingData(ticker, parsedData, localFile.data);
78-
}
79-
disk.writeStockDataToDisk(ticker, parsedData);
80-
81-
// Initialize ticker in state, and add parsed data for processing.
82-
initDataForStock(ticker, parsedData);
83-
processDataForStock(ticker, parsedData);
84-
}
85-
catch (e) {
86-
log('warn', e, e.stack);
65+
// Create an array containing a promise for each ticker request.
66+
// Requests get individual catch blocks, so if one fails the rest can continue.
67+
const tickerRequests = tickers.map(async (ticker) => {
68+
try {
69+
await throttle();
70+
71+
// Check for local data for this ticker first before retrieval.
72+
const localFile = disk.readStockDataFromDisk(ticker);
73+
let parsedData = await fetchStock(ticker, needsFullRetrieval(localFile));
74+
75+
// If local data exists, merge with fetched data.
76+
if (localFile.lastDateRetrieved && localFile.data) {
77+
parsedData = disk.mergeNewAndExistingData(ticker, parsedData, localFile.data);
8778
}
88-
});
79+
80+
// Write to disk.
81+
disk.writeStockDataToDisk(ticker, parsedData);
82+
83+
// Initialize ticker in state, and add parsed data for processing.
84+
initDataForStock(ticker, parsedData);
85+
86+
// Process data.
87+
processDataForStock(ticker, parsedData);
88+
}
89+
catch (e) {
90+
log('warn', e, e.stack);
91+
}
92+
});
8993

9094

95+
// Main
96+
(function() {
9197
// Execute all ticker requests, perform any needed retries, and apply search filter to signals.
9298
Promise.all(tickerRequests)
9399
.then(() => {
@@ -140,14 +146,17 @@ function every(arr, filter) {
140146
return result;
141147
}
142148

149+
143150
function allResultsShort(result) {
144151
return result.trade === 'short';
145152
}
146153

154+
147155
function allResultsLong(result) {
148156
return result.trade === 'long';
149157
}
150158

159+
151160
// Returns true if localFile.data doesn't exist (data not fetched before), or if date ('2019-01-02') was more than 100 days ago, otherwise false.
152161
function needsFullRetrieval(localFile) {
153162
if (!localFile.data) {
@@ -158,11 +167,13 @@ function needsFullRetrieval(localFile) {
158167
return daysBetween(mostRecentDate, currentDate) > 100 ? true : false;
159168
}
160169

170+
161171
function initDataForStock(ticker, parsedData) {
162172
state.quotes[ticker] = {};
163173
state.quotes[ticker]['data'] = parsedData;
164174
}
165175

176+
166177
function processDataForStock(ticker, parsedData) {
167178
try {
168179
// Mark pivot highs and lows.

src/buildHeatMap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require("fs");
2-
const state = require("./stockstate.js");
2+
const state = require("./stockData.js");
33

44

55
// state.quotes[ticker]

0 commit comments

Comments
 (0)