New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No longer overwrite manually adjusted security prices with historical #1492
Conversation
Manually adjusted prices are flagged and not overwritten when fetching historical prices from remote servers
I sometimes add a fund price by hand that I happen to know before Ariva knows it. I would prefer not to have that marked as sacred and unchangeable in case I made a typo. Under what circumstances will |
Another question … I don’t know yet how serialization into the XML file and back works in PP. Will the “manual” flag automatically be included? |
Could you kindle revise the XML revision, please? Regarding the use case the meaning of "manually adjusted" and "not automatically updated" is different upon users expectations. By the way, is there any reasons to use plain text for this hint rather than using a checkbox? |
Thank you for your feedback. I will try to find a more coherent approach and bring it up here. |
Manually adjusted prices are flagged and not overwritten when fetching historical prices from remote servers
Now a checkbox is used and can be toggled. Identical prices from automatic sources don't remove the lock anymore. Manual adjustment of a price still leads to the price being locked and the checkbox selected. Not sure, if this automatic is good. Feedback on this is welcome. Put Current_version to 46 in Client, but what needs to be done in ClientFactory? |
One more thing. Writing to the xml and reading it, seems to work. |
PP is using XStream to serialize objects to and from XML. If you add a new property, it will automatically be persisted. The changes to My thinking is: I try to limit the XML serialization to classes in the "model" package. Any change to those classes means a change to the XML. And any change is forever. PP can still read (and upgrade) the very first version of the XML from 2012. Therefore I am always super careful with any change to the model classes. Now to the pull request:
Let's quickly recap how the quote provider behave:
Of course, we can introduce the "lock" property and have the user maintain that property. I see the following disadvantages:
Just a thought: That would mean
I see one argument against this implementation: If the quote provider corrects a price, then this correction would not make it into the list of historical prices. But how often does that happen? Does anybody have an idea? From the code perspective, @inv-trad, it looks good. The only thing I would add (if we need this feature and the proposal above does not work) is to have custom XML converter that is not writing the boolean flag always, but only if it is set to "true"). |
Thank you for your thoughts, Andreas. I agree with you. I too, saw, that the xml structure is growing dramatically and had the same thoughts.
Not updating existing quotes would be rather easy to implement. And as you have written, that behavior is implicitly implemented in case Portfolio Report, Quandl, Finnhub, etc are used to retrieve historic quotes. If you agree, I will adjust the coding accordingly, remove the checkbox and the locked flag. |
One issue that I see with the no-update strategy: During a trading day, Ariva shows the most recent quote in its “close” column instead of the (not-yet-known) closing price, with a footnote saying so. Therefore, PP will store the then-current price from some random point in time and no longer update it after the trading day is over. Example page; note the asterisk with the footnote saying “most recent price today”. |
Fair point. We could also introduce a property on the Security that determines the behavior:
The default would be "do not overwrite" but for some HTML pages like your example, the user could say "do overwrite prices all the time". Personally, I would prefer one property on the Security over a configuration on each and every price.
Yes. I think the Security#addAllPrices is a good starting point. And then add a boolean property to Security which has to be reflected in the EditSecurityModel. And this value you can "bind" in the HistoricalQuoteProviderPage. If the GUI part is too much (I know Eclipse SWT/JFace is overly complex...) then doing the "model" changes would already help. |
Well, with that approach the issue, we want to solve isn't really fixed. For example, if Ariva delivers a wrong price for one day and the behavior is set to overwrite prices, because it shows the most recent quote in its “close” column, not the final one, one needs to wait for 30 days to have the corrected price not overwritten. Yesterday, I was following a litte different approach, overloading Security#addPrice with an overwriteExisting flag and checking, what source the price comes from. With that logic it would be possible to distinguish between imports and automatic updates. Imports (manual, csv, html) overwrite existing prices with changed ones, while automatic updates don't and have exceptions like overwriting 0.0 prices (can happen during imports) or the last existing entry.
I think, that could be a feasible approach and will update that you can see, what I have done. |
Manual update, csv, html, etc overwrite, but automatic updates, only in special cases
It would work like this:
But, ah, now I get your PR. Der Groschen ist gefallen.
you basically handle the Ariva specific case of the last historical quote always to be updated. But depending on the jobs, the "latest" quote might already be up-to-date. Say the user opens PP every noon. If the user opens it today, then the "latest price" is first updated to today, but yesterdays historical price must be updated because it was just the value from noon. I think we cannot use the comparison to the latest day here (and "latest" can be null if no latest quote feed provider is configured). Checking for Maybe the rule is: if it is the most recent historical price, then it is updated. What do you think? But then it does not allow you to "fix" a historical price if it is the last one. Do we have more options? About your PR: Because |
Removing unnecessary changes
Yes, comparing with the latest was meant to fix the Ariva specific behaviour. Not sure, if that applies for other quote sources as well. During testing, I never deleted last Friday's price (latest), only changed it and everything worked fine, but it looks like the jobs provide the new latest before the historic prices. That means the old latest e.g. from Thursday noon (not Thursdays close price) is not updated, because it is no longer the latest. If the job for the historical quotes would run first, everything should be fine, but obviously it doesn't. I will investigate further to see, if there are more options. About the PR: I removed the unnecessary changes and left the CheckBoxEditingSupport class, in case someone else might need it later?! |
I changed the sequence the jobs are initiated and it works the way it should do. The historic quotes are updated first and the latest existing is replaced, in case it is different. After that the latest is updated. When one now adjusts the last historical prices, it will not be touched again, because the new latest exists and the date is different. Could there be side effects from changing the job sequence? So far I didn't realize any. Can someone tell me, why the check fails giving an error in a class I didn't touch? What do I need to do to get it fixed? |
Because I committed code that did not build and I did not notice it... 😒 Nothing to do with your change. |
My thinking for loading the "latest" quotes first was because one wants to see the current valuation first. It is hard to say if that makes a difference. In my (bigger) file, I need ca. 5 seconds to update all quotes. That is not a big difference. But what if the "latest" job ran, but the "historic" not. And the next day the data is not updated as expected. And why if Yahoo is wrong data for the last day? You can still not fix it if the "latest" quote happens to be for the same date. On the other hand, what can go wrong? If this does not work, we can easily improve it with the next version of PP. But if we add a new property, we can never remove it again. Let me rebase and merge and we will see. |
Issue: #1492 Signed-off-by: inv-trad <59824809+inv-trad@users.noreply.github.com> [squashed commits; rebased to master] Signed-off-by: Andreas Buchen <andreas.buchen@gmail.com>
Squashed, rebased, merged. |
Issue: portfolio-performance#1492 Signed-off-by: inv-trad <59824809+inv-trad@users.noreply.github.com> [squashed commits; rebased to master] Signed-off-by: Andreas Buchen <andreas.buchen@gmail.com>
Issue: portfolio-performance#1492 Signed-off-by: inv-trad <59824809+inv-trad@users.noreply.github.com> [squashed commits; rebased to master] Signed-off-by: Andreas Buchen <andreas.buchen@gmail.com>
Manually adjusted prices are flagged and not overwritten when fetching
historical prices from remote servers