lavolp3 / MMM-AVStock

MagicMirror module for displaying stock price with yfinance API
MIT License
39 stars 18 forks source link

"Last quote" shows current, but values are not updating. #43

Closed shevett closed 6 months ago

shevett commented 4 years ago

Good morning. I've been runing AVstock on my displayboard for several months. Right now I'm noticing that when I come in in the morning, the value is accurate for market opening, but will not update for the rest of the day, even thoush 'last quote' is showing the current value. Screenshot (via phone, sorry) image

Note the update date is current, but the values are hours old.

Here's my config:

                {
                        //disabled:true,
                        module: "MMM-AVStock",
                        position: "bottom_right",
                        config: {
                                apiKey : "REDACTED",
                                symbols : ["ADBE","AAPL","TSLA","^DJI"],
                                alias: ["ADOBE","APPLE","TESLA","DOW"],
                                tickerDuration: 20,
                                chartDays: 30,
                                mode: "table",
                                showChart: false,
                                chartWidth: null,
                                showVolume: false,
                                chartInterval: "Daily",
                                movingAverage: {
                                    type: 'SMA',
                                    periods: [200]
                                },
                                decimals : 2,
                                chartType: 'line',                // 'line', 'candlestick', or 'ohlc'
                                chartLineColor: '#eee',
                                chartLabelColor: '#eee',
                                coloredCandles: true,
                                debug: false
                                }
                },

Most recent pull was the last time i tried to fix this, a few weeks ago:


Author: Dirk <dirk.kovert@gmail.com>
Date:   Tue Sep 8 12:34:15 2020 +0000

    optimized purchasePrice option```

Any ideas?
lavolp3 commented 4 years ago

Unfortunately AlphaVantage only provides the last days closing price in their API for a few weeks/months now. So what you see is yesterdays closing price. It will not change until todays close.

THere's nothing wrong with the module.

Note the update date is current, but the values are hours old.

The "update time" value is not very useful currently. It shows the last time the API has been successfully tapped.

shevett commented 4 years ago

Well that will explain it :). Is there another source I can use to get relatively current values?

lavolp3 commented 4 years ago

I'm working on using the IEX Cloud API. I need to change the base code. You can't do much yet apart from completely rewriting node_helper.js.

lavolp3 commented 4 years ago

@shevett would you like to do some beta testing for me? I have pushed a new branch new_api including the IEX API. You would need an IEX API key (as described in the README) in ADDITION to the alphavantage key. Then you will have up-to-date quotes in table, ticker, and grid. Unfortunately I cannot switch completely to IEX, since fetching historical data is too expensive and would blow the free quota limit.

git fetch
git checkout new_api
git pull

Let me know if you can and want to test it.

lavolp3 commented 4 years ago

Or hold a moment. I think I have found a more appropriate API. Twelve Data looks good. Just give me a few more days. You can still try to use this. But I may not use IEX in the end

shevett commented 4 years ago

I"ll wait til you give me the high sign and i'll try it out.

spitzlbergerj commented 4 years ago

Hi Dirk @lavolp3,

I like to test with you, if you have implemented the new API.

one more hint: I mean onvista.com also has an API and as far as I remember it was completely free. However, I can't find anything about it right now. Maybe this will help you.

lavolp3 commented 4 years ago

As far as I can see, onvista provides the API to get access to your own account (balance, transactions), not to stock data. comdirect does the same.

lavolp3 commented 1 year ago

@spitzlbergerj it has taken some time :-D but I have now included the yahoo finance API. If you're still interest I am happy if you can update and check. There's no api key needed.

spitzlbergerj commented 1 year ago

Hi @lavolp3, Thank you for taking care of the matter. I have used another ticker in the meantime, but will gladly return to your ticker. Please give me some time to test it, I have too many "projects" running in parallel. Thanks again!

spitzlbergerj commented 1 year ago

Hi @lavolp3, sorry that it took a while, but yesterday I was able to update and try. Unfortunately, the display does not work for me yet. I didn't have much time unfortunately. I have only seen two error messages that I could not follow up yet:

MMM-AVStock.js:387 Uncaught (in promise) TypeError: Cannot set properties of null (setting 'innerHTML') at Class.updateData (MMM-AVStock.js:387:34) at Class.socketNotificationReceived (MMM-AVStock.js:408:18) at module.js:234:9 at Socket. (socketclient.js:38:4) at Emitter.emit (index.mjs:136:20) at Socket.emitEvent (socket.js:498:20) at Socket.onevent (socket.js:485:18) at MMSocket.socket.onevent (socketclient.js:32:11) at Socket.onpacket (socket.js:455:22) at Emitter.emit (index.mjs:136:20)

[06.10.2023 09:01.30.586] [ERROR] (node:2641) UnhandledPromiseRejectionWarning: FetchError: request to https://query2.finance.yahoo.com/v10/finance/quoteSummary/TL0.F?formatted=false&modules=price&crumb=warpfd.R.6X failed, reason: getaddrinfo EAI_AGAIN query2.finance.yahoo.com at ClientRequest. (/home/pi/MagicMirror/modules/MMM-AVStock/node_modules/node-fetch/lib/index.js:1501:11) at ClientRequest.emit (node:events:513:28) at TLSSocket.socketErrorListener (node:_http_client:502:9) at TLSSocket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) [06.10.2023 09:01.30.589] [ERROR] (node:2641) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2111)

lavolp3 commented 1 year ago

Thanks @spitzlbergerj Looks like an error thrown by the API because it couldn't find the ticker. These should be catched so the module doesn't break. I will follow this up.

lavolp3 commented 1 year ago

Have pushed an update. Now a ticker that could not be found throws an error in the console (provided by node-helper), but does not crash the module anymore. The entry in the table is then empty.

spitzlbergerj commented 1 year ago

Good morning @lavolp3 , Unfortunately it still does not work after the update. This is my config

    {
        module: "MMM-AVStock",
        position: "bottom_bar",
        config: {
        /* apiKey : "0TS4Z1L0W4YC3H84", /* josef@spitzlberger.de */
        /* apiKey : "KB3ODR6LWJ5QX71D", /* paula@kleeberger.de */
        mode : "ticker",
        symbols : [       "TL0.F", "RIVN", "MSF.DE",   "PRG.DE",   "EUNL.F", "AMEW.DE"],
        alias: [          "Tesla", "Rivian",   "Microsoft", "Proc&Gam", "MSCI i",   "MSCI a"],
        purchasePrice: [  76.77,  23.20,   131.05,   96.15,      70.30,   262.75],
        purchaseQuantity: [217,     260,      10,    20,         471,          46],
        decimals: 0,
        tickerDuration: 20,
        showChart: false,
        showVolume: false,
        showPurchasePrices: true,
        showPerformance2Purchase: true,
        showStockValueTotal: true,
        debug: false,
        }
    },

and these are the errors that appear now

Uncaught (in promise) TypeError: Cannot set properties of null (setting 'innerHTML')
    at Class.updateData (MMM-AVStock.js:387:34)
    at Class.socketNotificationReceived (MMM-AVStock.js:408:18)
    at module.js:234:9
    at Socket.<anonymous> (socketclient.js:38:4)
    at Emitter.emit (index.mjs:136:20)
    at Socket.emitEvent (socket.js:498:20)
    at Socket.onevent (socket.js:485:18)
    at MMSocket.socket.onevent (socketclient.js:32:11)
    at Socket.onpacket (socket.js:455:22)
    at Emitter.emit (index.mjs:136:20)

Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'quotes')
    at Class.socketNotificationReceived (MMM-AVStock.js:406:43)
    at module.js:234:9
    at Socket.<anonymous> (socketclient.js:38:4)
    at Emitter.emit (index.mjs:136:20)
    at Socket.emitEvent (socket.js:498:20)
    at Socket.onevent (socket.js:485:18)
    at MMSocket.socket.onevent (socketclient.js:32:11)
    at Socket.onpacket (socket.js:455:22)
    at Emitter.emit (index.mjs:136:20)
    at manager.js:204:18

Thanks for your time

lavolp3 commented 1 year ago

Ok that seems to be related to the ticker, I haven't looked at that during the recent update. Will check over the coming days

lavolp3 commented 6 months ago

to update here, the ticker currently works for me. So I'll close this one. @spitzlbergerj maybe you find he time to try again.