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 588 forks source link

Extend JSON quote update to also update dynamic security-attributes #4193

Open dietmarb01 opened 4 weeks ago

dietmarb01 commented 4 weeks ago

Is your feature request related to a problem? Please describe. Through XML I can programmatically inject values for custom attributes for securities, e.g. "sector", "industry". For fairly static ones injection is fine. To ease review of holdings, I would also want to use e.g. "fundamentals-summary" (including P/E, P/B, etc.) that change daily. I would like to make them updateable online through the existing quote update mechanism by importing and setting such values if they are a) defined as Security Attribute with Source "JSON" and b) present in the JSON data for a security.

Describe the solution you'd like If a security attribute that is defined with Source "JSON" is present in the JSON data with a matching Name, this attribute shall be set for the security from the value in the JSON data. This mechanism should be fully backwards compatible and non-intrusive. Excess fields in JSON are currently ignored, and data is only pulled if there is a matching name (preferably case-insensitive). No new UI is required. I noticed that the UI currently mixes the use of Name (in the menu) and Column Label. I would prefer to consistently use Column Label as a "display name" and restrict Name to internal use. Provision of appropriate JSON data is entirely up the the user of PP who wants to use this feature.

Describe alternatives you've considered Injection into XML is possible, but only "offline".

Additional context None.

pfalcon commented 4 weeks ago

through the existing quote update mechanism

But that's the issue - existing JSON quote update mechanism is quote update mechanism. It's intended to interface with existing 3rd-party datasource, that's why it allows user to configure mapping from 3rd-party JSON attribute names to something importable into PP. Your usecase is different - you want to import the data you prepare yourself. And it's tempting to find an existing orifice in PP and stuff more stuff into it, but there're at least 2 immediately obvious problems:

  1. It will be another obscure PP feature, known only to someone who implemented it and perhaps the maintainer. Because nobody will look for ways to import attributes somewhere documented as quote imports.
  2. If someone uses other quote feed, e.g. Yahoo, they won't be able to use this JSON attribute update mechanism.

So yes, as long as you prepare you data to import, you can prepare it in different ways, and the most obvious is by modifying XML. Yes, it's a bit inconvenient, as you need to close XML in PP, run your script, then open XML in PP again. But that only means that there should be further push to make it convenient to interface PP with external application. And the ultimate solution is known: using database: https://github.com/portfolio-performance/portfolio/issues/2216 .

(Non-ultimate solution is also known: https://github.com/portfolio-performance/portfolio/issues/2085 . It's not ultimate because it requires solving essentially the same problem twice: first how to store data, then how to expose that data to external clients. Solve and then maintain over time. And the project clearly doesn't have enough resources for such unscalable duplication of effort, the best proof is that the maintainer didn't get back to it past the initial prototype for over 3 years. So again, the simple solution is to store data in such a way that this storage was public external interface.)