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
173 stars 57 forks source link

Dividend crash #117

Closed Riba77 closed 1 month ago

Riba77 commented 5 months ago

Zdravo.

Ne uspe mi sparsati xmlja, kljub temu da kompanijo dodam na listo v companies.xml file. Kaksna ideja kaj je narobe?

Error: Doh-KDVP.xml created (includes no trades) D-IFI.xml created (includes no trades) Cannot find a matching dividend for LOGN(CH0025751329) CASH DIVIDEND CHF 1.06 PER SHARE - CH TAX (20230927;202000) of -20.78. Traceback (most recent call last): File "C:\Users\hri79002\AppData\Roaming\Python\Python311\Scripts\ib_edavki-script.py", line 33, in sys.exit(load_entry_point('ib-edavki==1.4.6', 'console_scripts', 'ib_edavki')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hri79002\AppData\Roaming\Python\Python311\site-packages\ib_edavki.py", line 1186, in main closestDividend["taxEUR"] += closestDividendTax / getCurrencyRate( ^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'closestDividend' where it is not associated with a value

LP Roman

jamsix commented 4 months ago

Iz izpisa izgleda kot da imaš v XMLju iz IBKRja zaveden davek od dividende, same dividende pa ne. Lahko preveriš?

Riba77 commented 4 months ago

CashTransaction accountId="" acctAlias="" model="" currency="CHF" fxRateToBase="1.0345" assetCategory="STK" subCategory="COMMON" symbol="LOGN" description="LOGN(CH0025751329) CASH DIVIDEND CHF 1.06 PER SHARE - CH TAX" conid="39999891" securityID="CH0025751329" securityIDType="ISIN" cusip="" isin="CH0025751329" figi="BBG000CYR5S0" listingExchange="EBS" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" issuerCountryCode="" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" dateTime="20230927;202000" settleDate="20230927" amount="-20.78" type="Withholding Tax" tradeID="" code="" transactionID="586285294" reportDate="20230928" clientReference="" actionID="122514923" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0"

Riba77 commented 4 months ago

Same dividende ne najdem v zgornjem CashTransactionu, je pa v "descriptnon" naveden amount.

jamsix commented 4 months ago

ib-edavki za izračun potrebuje tudi CashTransaction vnos od konkretne dividende. Drži sicer, da bi lahko sparsali tudi vrednost iz description parametra vnosa za davek, ampak za enkrat ni bilo potrebe po tem.

Vse skupaj je precej nenavadno. Ostale dividende pa vidiš pod CashTransactions?

Riba77 commented 4 months ago

Identicno pri ostalih dividendah. Lahko ti pošljem xml in pregledaš, ker tudi meni ni čisto jasno. Kje naj bi bile vrednosti dividend definirane, iz kje jo parsate, če ne iz "description".

jamsix commented 4 months ago

Si izvozil dividende v poročilu? Preveri 7. točko navodil za izvoz: https://github.com/jamsix/ib-edavki?tab=readme-ov-file#izvoz-poro%C4%8Dila-v-platformi-interactivebrokers

Riba77 commented 4 months ago

DividendsProblem

Riba77 commented 4 months ago

Lahko ti osebno pošljem še XML.

jamsix commented 4 months ago

Če si imel dividende, ampaj jih ni v IB XML exportu z nastavitvami, kot si jih prikazal zgoraj, se boš moral obrnit na IB support.

Takole nekako izgleda pravilen report, vsak type=Dividends ima matching type=Withholding Tax:

<CashTransaction acctAlias="" model="" currency="USD" fxRateToBase="0.90814" assetCategory="STK" symbol="URNM" description="URNM(US85208P3038) PAYMENT IN LIEU OF DIVIDEND - US TAX" conid="558207272" securityID="US85208P3038" securityIDType="ISIN" cusip="85208P303" isin="US85208P3038" listingExchange="ARCA" underlyingConid=""dateTime="20231221;202000" settleDate="20231221" amount="-27.84" type="Withholding Tax" tradeID="" code="" reportDate="20231221" clientReference="" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" subCategory="ETF" figi="BBG016ZGFKV6" issuerCountryCode="US" />
<CashTransaction acctAlias="" model="" currency="USD" fxRateToBase="0.90814" assetCategory="STK" symbol="URNM" description="URNM(US85208P3038) CASH DIVIDEND USD 1.75096 PER SHARE - US TAX" conid="558207272" securityID="US85208P3038" securityIDType="ISIN" cusip="85208P303" isin="US85208P3038" listingExchange="ARCA" underlyingConid=""dateTime="20231221;202000" settleDate="20231221" amount="-11.56" type="Withholding Tax" tradeID="" code="" reportDate="20231221" clientReference="" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" subCategory="ETF" figi="BBG016ZGFKV6" issuerCountryCode="US" />
<CashTransaction acctAlias="" model="" currency="USD" fxRateToBase="0.90814" assetCategory="STK" symbol="URNM" description="URNM(US85208P3038) CASH DIVIDEND USD 1.75096 PER SHARE (Ordinary Dividend)" conid="558207272" securityID="US85208P3038" securityIDType="ISIN" cusip="85208P303" isin="US85208P3038" listingExchange="ARCA" underlyingConid=""dateTime="20231221;202000" settleDate="20231221" amount="77.04" type="Dividends" tradeID="" code="" reportDate="20231221" clientReference="" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" subCategory="ETF" figi="BBG016ZGFKV6" issuerCountryCode="US" />
<CashTransaction acctAlias="" model="" currency="USD" fxRateToBase="0.90814" assetCategory="STK" symbol="URNM" description="URNM(US85208P3038) PAYMENT IN LIEU OF DIVIDEND (Ordinary Dividend)" conid="558207272" securityID="US85208P3038" securityIDType="ISIN" cusip="85208P303" isin="US85208P3038" listingExchange="ARCA" underlyingConid=""dateTime="20231221;202000" settleDate="20231221" amount="185.6" type="Payment In Lieu Of Dividends" tradeID="" code="" reportDate="20231221" clientReference="" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" subCategory="ETF" figi="BBG016ZGFKV6" issuerCountryCode="US" />
Riba77 commented 4 months ago

<CashTransaction accountId="" acctAlias="" model="" currency="EUR" fxRateToBase="1" assetCategory="STK" subCategory="COMMON" symbol="BAYNd" description="BAYN(DE000BAY0017) CASH DIVIDEND EUR 2.40 PER SHARE - DE TAX" conid="29612150" securityID="FR0000121014" securityIDType="ISIN" cusip="" isin="FR0000121014" figi="BBG000BC7Q05" listingExchange="SBF" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" issuerCountryCode="FR" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" dateTime="20231206;202000" settleDate="20231206" amount="-13.75" type="Withholding Tax" tradeID="" code="" transactionID="630683980" reportDate="20231207" clientReference="" actionID="122868011" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" />

Riba77 commented 4 months ago

Tako nekako zgleda dividenda, pri kateri dobim zgoraj omenjen error.

ddbk commented 4 months ago

<CashTransaction accountId="" acctAlias="" model="" currency="EUR" fxRateToBase="1" assetCategory="STK" subCategory="COMMON" symbol="BAYNd" description="BAYN(DE000BAY0017) CASH DIVIDEND EUR 2.40 PER SHARE - DE TAX" conid="29612150" securityID="FR0000121014" securityIDType="ISIN" cusip="" isin="FR0000121014" figi="BBG000BC7Q05" listingExchange="SBF" underlyingConid="" underlyingSymbol="" underlyingSecurityID="" underlyingListingExchange="" issuer="" issuerCountryCode="FR" multiplier="1" strike="" expiry="" putCall="" principalAdjustFactor="" dateTime="20231206;202000" settleDate="20231206" amount="-13.75" type="Withholding Tax" tradeID="" code="" transactionID="630683980" reportDate="20231207" clientReference="" actionID="122868011" levelOfDetail="DETAIL" serialNumber="" deliveryType="" commodityType="" fineness="0.0" weight="0.0" />

@Riba77 tole zgleda "narobe". Glede na symbol in isin, ki je v description polju bi to naj bila delnica Bayerja; glede na vrednost v isin polju in to, da je država izdajatelja Francija pa LVMH.

jjustin commented 4 months ago

Sem naletel na isti issue. Pri meni je bila napaka v queryju/exportu iz IBKR. "Dividends" option se je sam od sebe odkljukal v exportu.

Preveri, če "Cash Transactions" section tvojega flex query-ja (ko je ze enkrat kreiran in gres v edit mode) zgleda tako: image namesto image

Nevem zakaj pride do napake, sem pa opazil, da se mi pravili settingi shranijo, če:

  1. Grem v edit mode obstoječega query-ja
  2. V "Cash Transactions" sectionu označim optione, ki jih je treba
  3. Odnačim vse parametere (deselect "Select All")
  4. Nazaj označim vse (select "Select All")
  5. "Save"
  6. Spet odprem "Cash Transactions"
  7. "Save"
  8. "Continue"
  9. "Save Changes"
  10. "Ok"
ZigaSajovic commented 4 months ago

Crash se zgodi zaradi buga opisanega v komentarju tukaj.

V kolikor se zedinimo o željenem obnašanju obnašanju bom naredil pull request s fixom.

  1. Uporabniku javimo hard error in exit-amo
  2. Transakcijo preskočimo in userju javimo warning da ima čuden input in naj preveri dotično transakcijo.

V obeh primerih bo crash rešen. Drugega pa skripta ne more v tem primeru.