portfolio-performance / portfolio

Track and evaluate the performance of your investment portfolio across stocks, cryptocurrencies, and other assets.
http://www.portfolio-performance.info
Eclipse Public License 1.0
2.86k stars 591 forks source link

YahooFinance latest quote endpoint is broken, leads to confusing stale price and mismatch in UI #3302

Open pfalcon opened 1 year ago

pfalcon commented 1 year ago

Calling YahooFinanceQuoteFeed.rpcLatestQuote() (e.g. https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US&region=US&corsDomain=finance.yahoo.com&symbols=AMZN ) leads to:

{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}

And the latest quote for security not updated. Historical quotes work of course. So, if the latest quote was set somehow (I'm not sure how, there's complex logic, but apparently that may happen from historic quote feed), then the value is stuck in the UI, but one can see that for example "Change on previous day" (btw, that's bug, should be "Change from previous day") update. Yes, like that: user selects a security, via menu does "Update quotes (selected security)", and the latest price stays the same, while delta to prev day is updated. Weird.

chirlu commented 1 year ago

apparently that may happen from historic quote feed

No, never. It’s just the value when it last worked (and you can delete it at any time from a security’s context menu).

"Change on previous day" (btw, that's bug, should be "Change from previous day")

Then go to POEditor and fix the translation. There are certainly lots of errors in them.

pfalcon commented 1 year ago

No, never.

But of course, this condition is simple and got 100% functional testing:

       // use latest quote only
        // * if one exists
        // * and if either no historic quotes exist
        // * or
        // ** if the requested time is after the latest quote
        // ** and the historic quotes are older than the latest quote

        if (latest != null //
                        && (lastHistoric == null //
                                        || (!requestedDate.isBefore(latest.getDate()) && //
                                                        !latest.getDate().isBefore(lastHistoric.getDate()) //
                                        )))

and the comment corresponds to the code, and other standard programming silver bullets.

It’s just the value when it last worked

The non-workability of that YF API endpoint is likely the most stable thing here.

(and you can delete it at any time from a security’s context menu).

Right, I just wonder how a mere user would figure that out and why they would need to do that again and again.

Then go to POEditor and fix the translation.

Let's start with just reporting bugs and see how it goes.

chirlu commented 1 year ago

But of course

Never is the latest quote set from any historical quote.

Let's start with just reporting bugs and see how it goes.

Currently, you get across as annoying, so it isn’t going well …

pfalcon commented 1 year ago

https://forum.portfolio-performance.info/t/price-incorrect-in-statement-of-assets/23806