jamsix / ib-edavki

Skripta, ki prevede XML poročilo trgovalnih poslov v platformi InteractiveBrokers v XML format primeren za uvoz v obrazce Doh-KDVP, D-IFI, Doh-Div in Doh-Obr v eDavkih Finančne uprave.
MIT License
195 stars 60 forks source link

Got an error There is no exchange rate for 20220128 #58

Closed ifrond closed 1 year ago

ifrond commented 2 years ago

Error: There is no exchange rate for 20220128 (this is the first trade date) Maybe dateformat problem because in xml export file all dates have format 20220128 but in bsrate-20221130.xml all dates have format 2022-01-28

ifrond commented 2 years ago

I am not a python developer but I suppose the problem is here https://github.com/jamsix/ib-edavki/blob/d2cf732728dbb65b3b7e4f010b80bbd380dacd64/ib_edavki.py#L74 lastWorkingDateStr = lastWorkingDate.strftime("%Y%m%d") maybe change to lastWorkingDateStr = lastWorkingDate.strftime("%Y-%m-%d")

jamsix commented 1 year ago

Živjo,

ta del kode ne bi smel bit problem, ker so ključi v rates v obliki brez pomišljajev: https://github.com/jamsix/ib-edavki/blob/d2cf732728dbb65b3b7e4f010b80bbd380dacd64/ib_edavki.py#L215

Poskusi izbrisat bsrate-*.xml in ponovno pognat.

ifrond commented 1 year ago

you are right, the problem was in currency that wasn't at bsrate-*.xml in my case that currency was CNH i think you need to check exchange twice - for date and then for the currence and correct the error message to fit the actual problem

jamsix commented 1 year ago

Thanks for coming back witht this explanation. Solution to the problem is a bit trickier that it seems.

  1. FURS demands currency rates as published by Bank of Slovenia. BS does not publish CNH rates.
  2. We can probably take ECB rates (if we find a reliable free API), but ECB only provides CNY rates.
  3. CNY and CNH rates can in theory diverge, should we just ignore that?

For now I recommend you simply remove that entry or change CNH to some other value in your IB XML files and recalculate that entry manually. We will look into this, but no promises that it will be done before the end of this year's tax season.

ifrond commented 1 year ago

I would just silently replace CNH to CNY. Exchage rate is about 0.999. Thank you for your help.

jamsix commented 1 year ago

@ifrond this should be fixed now with https://github.com/jamsix/ib-edavki/commit/2a23c4da509412d7a4bf73d292541c14ead9b775 It's not an ideal fix as it assumes CNH/CNY = 1, but lacking a better guidance, it should be close enough.

ifrond commented 1 year ago

Thank you