portfolio icon indicating copy to clipboard operation
portfolio copied to clipboard

VIAC PDF import for small fraction of expensive share breaks share price

Open mike-kfed opened this issue 2 years ago • 10 comments

this is clearly the fault of VIAC as they are rounding the fraction shares to 3 digits, but since that is what we get - what happens in PP is:

PDF info

0.015 Shares of CSIF SPI Extra at share-price CHF 2711.97 ends up being valuta price of CHF 41.53

outcome of import

  • Valuta price stays correctly CHF 41.53
  • 0.015 fraction share stays (importing the problem created by VIAC)
  • PP changes share-price to CHF 2768.66 which then results in a buy/sell marker on the plot that is not on the chart-line of the shares history. This looks like bought too expensive at first glance (or sold very intelligently, depending on action ;))

proposed fix

instead of calculating share-price (not necessary, it is found inside the PDF) calculate correct fraction, here 0.015315 instead of rounded 0.015

mike-kfed avatar Nov 22 '21 13:11 mike-kfed

Hello @mike-kfed Portfolio Performance is not responsible for the plausibility check of the available documents. Furthermore, the importer does not have the function to calculate rates. If VIAC creates the documents incorrectly, this must be reported to VIAC. Alternatively, you can correct the shares yourself.

This issue can be closed.

Regards Alex

Nirus2000 avatar Nov 22 '21 18:11 Nirus2000

Well the importer calculates the share-price, so from where I am sitting this means that the math is there, it just needs to solve for another variable.

Also I am not sure I understand your attitude towards developing financial software. Computing the correct fractional amount of stocks and storing 3 correct and consistent values into the database should be preferred over recomputing a wrong share-price and knowingly store that into the DB, all the while the correct share-price at time of buy/sale is available in the PDF.

mike-kfed avatar Nov 22 '21 23:11 mike-kfed

I looked more into this, PP stores only amount and valuta (total price) in its DB and computes the share-price. Makes sense, easier to keep the 3 values consistent. The importer therefore also only imports the amount of shares and the valuta, taking the values directly from PDF - making all imported transactions from VIAC imprecise, because VIAC publishes rounded values. It is just less obvious on the chart because the computed share-prices often aren't too far off and therefore the markers are close to the plot-line. However the share-prices are wrong once inside PP in almost every case.

Given this information I find it even more important for the viac importer to use the PDFs share-price to calculate the amount of shares bought with higher precision than is provided in the PDF (ignoring the amount presented in the PDF, or using it only as a sanity check).

mike-kfed avatar Nov 24 '21 11:11 mike-kfed

I can only mention it as I said at the beginning. "If VIAC would create correct documents, the problem would not exist."

The importer is also not specific for VIAC, but for WIR-Bank documents.

I also think it is the wrong way of development to fix "other" errors through work arounds.

Nirus2000 avatar Nov 24 '21 11:11 Nirus2000

I highly doubt VIAC will change their PDF documents precision, especially when they contain all data needed to achieve precision. Therefore we have to work with what we've got. So you are not willing to make a workaround, fine, but would you accept a PR to fix that problem?

mike-kfed avatar Nov 24 '21 11:11 mike-kfed

Feel free... :-)

Nirus2000 avatar Nov 24 '21 11:11 Nirus2000

@mike-kfed https://github.com/DomeAlonso/ViacCSVFileGenerator

Nirus2000 avatar Dec 06 '21 21:12 Nirus2000

@mike-kfed https://github.com/DomeAlonso/ViacCSVFileGenerator

thanks, doesn't work exactly how I need it though, e.g. import of transactions/dividends for shares with foreign currency doesn't work. I wrote my own importer already, once I have given it the finishing touches I'll release it.

mike-kfed avatar Dec 07 '21 15:12 mike-kfed

Hello Mike,

I have the same problem as you, so I'm very interested in your solution.

I wrote my own importer already, once I have given it the finishing touches I'll release it.

Any progress here?

sgelb avatar Jan 02 '22 11:01 sgelb

Here's my initial take on this, written in Rust (nice programming exercise ;)) https://github.com/mike-kfed/viac_pdf_import

works for german and french docs as of today, but far from polished, lots of useless stdout printing for example.

mike-kfed avatar Jan 04 '22 17:01 mike-kfed