yura505 / robinbot

Robinhood API based swing trading bot
132 stars 34 forks source link

ypeError: Cannot read property 'forEach' of undefined; lst.forEach(function(earning) #14

Closed justanotherkevin closed 5 years ago

justanotherkevin commented 5 years ago

after npm i then ./backtest.js i am running into this error. seem like lst can be undefined leading to this error.

change if (global.backtest) { ...} => if (global.backtest && !lst=== undefined) {...} for the fix

whoizerwin commented 5 years ago

Thanks for figuring this out! Now I'm getting the following error though, would you know how to fix this?

/Users/wind/robinbot/rsa.js:21
        let diff = (quotes.get(symbol)[0].close / quotes.get(symbol)[length].close);
                                         ^

TypeError: Cannot read property 'close' of undefined
    at Object.rsa (/Users/wind/robinbot/rsa.js:21:42)
    at Object.m3 (/Users/wind/robinbot/rsa.js:12:21)
    at Object.calculate (/Users/wind/robinbot/rsa.js:29:52)
    at /Users/wind/robinbot/backtest.js:61:13
    at end (/Users/wind/robinbot/node_modules/run-series/index.js:8:15)
    at done (/Users/wind/robinbot/node_modules/run-series/index.js:11:10)
    at each (/Users/wind/robinbot/node_modules/run-series/index.js:16:43)
    at /Users/wind/robinbot/earnings.js:17:13
    at end (/Users/wind/robinbot/node_modules/run-series/index.js:8:15)
    at done (/Users/wind/robinbot/node_modules/run-series/index.js:11:10)
yura505 commented 5 years ago

I think that you added some new symbol that has no enough information for relative strength analysis. You can try switch off RSA in configuration conf.js, it can help.

On Thu, Aug 9, 2018 at 5:58 PM whoizerwin notifications@github.com wrote:

Thanks for figuring this out! Now I'm getting the following error though, would you know how to fix this?

`/Users/wind/robinbot/rsa.js:21 let diff = (quotes.get(symbol)[0].close / quotes.get(symbol)[length].close); ^

TypeError: Cannot read property 'close' of undefined at Object.rsa (/Users/wind/robinbot/rsa.js:21:42) at Object.m3 (/Users/wind/robinbot/rsa.js:12:21) at Object.calculate (/Users/wind/robinbot/rsa.js:29:52) at /Users/wind/robinbot/backtest.js:61:13 at end (/Users/wind/robinbot/node_modules/run-series/index.js:8:15) at done (/Users/wind/robinbot/node_modules/run-series/index.js:11:10) at each (/Users/wind/robinbot/node_modules/run-series/index.js:16:43) at /Users/wind/robinbot/earnings.js:17:13 at end (/Users/wind/robinbot/node_modules/run-series/index.js:8:15) at done (/Users/wind/robinbot/node_modules/run-series/index.js:11:10)`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yura505/robinbot/issues/14#issuecomment-411924155, or mute the thread https://github.com/notifications/unsubscribe-auth/AF3kc20dSYpwcwDNVge-ZR_LHy4GyMInks5uPL6DgaJpZM4VvHn0 .

whoizerwin commented 5 years ago

Interesting! Thank you Yury, it definitely went further by turning off RSA. But still giving me the error code while running. Much appreciated!

*** BACKTEST today: 2018-08-09 4:20:02 PM
Downloading historical quotes...
Downloading historical quotes...
Downloading delayed today quotes...
Downloading delayed today quotes...
Downloading NASDAQ Composite index...
Downloading recent earnings...
Downloading recent earnings...
**Day:252 2017-08-08
SYMBOL  RANK   CLOSE  SMA50  SMA200  SS.K  ADX  MACD0   MACD     SAR      ATR   OBV/MA  RSI    EARNINGS   RESULT
------ ------ ------- ------ ------ ------ --- ------- ------ --------- ------- ------ ----- ------------ ------
V        1.00  100.60   96.0   87.4   92.6  50    0.11   0.07   98.23^     1.13  1.000 66.00              BUY
AMZN     1.00  989.84  998.0  878.3    8.0  17   -5.84  -5.58 1055.14v    18.00  0.996 45.00              SELL
HP       1.00   44.23   50.7   61.1    4.2  20   -0.68  -0.73   51.71v     1.71  1.070 29.00              SELL
MU       1.00   28.84   30.7   25.4   23.8  19   -0.30  -0.21   30.03v     1.01  1.065 42.00              
ADBE     1.00  147.81  144.0  124.3   60.6  16   -0.24  -0.26  149.67v     2.38  0.991 55.00              
/Users/wind/robinbot/strategy.js:28
                close: q[0].close,
                            ^

TypeError: Cannot read property 'close' of undefined
    at /Users/wind/robinbot/strategy.js:28:29
    at Array.forEach (<anonymous>)
    at Object.run (/Users/wind/robinbot/strategy.js:24:14)
    at /Users/wind/robinbot/backtest.js:62:18
    at end (/Users/wind/robinbot/node_modules/run-series/index.js:10:15)
    at done (/Users/wind/robinbot/node_modules/run-series/index.js:13:10)
    at each (/Users/wind/robinbot/node_modules/run-series/index.js:18:43)
    at /Users/wind/robinbot/earnings.js:17:13
    at end (/Users/wind/robinbot/node_modules/run-series/index.js:10:15)
    at done (/Users/wind/robinbot/node_modules/run-series/index.js:13:10)
justanotherkevin commented 5 years ago

q[0] is undefine, likely that stock didnt have any data. the unfortunate thing is I don't know what other formulas are using the closing value. Fixing this might lead to a bunch of other errors. ill take a look over the weekend