custom-components / sensor.avanza_stock

Custom component to get stock data from Avanza for Home Assistant
MIT License
46 stars 10 forks source link

Currency Gain/Loss #91

Closed mbedk closed 3 years ago

mbedk commented 4 years ago

This add-on is currently able to calculate the gains and losses based on GA price and number of stocks purchased.

However this does not take into account the loss/gain in currency.

Example My local currency is DKK. If I purchase a stock in Norway, there is a currency exchange happening at the time of the purchase. While I hold this stock, the currency between NOK and DKK changes. If I were to sell this stock after 6 months, I would not only have gained/lost the increase/decrease value in the stock but also the currency.

claha commented 4 years ago

@mbedk Will this not be handled if you set the purchase_price in DKK?

Example: Buy 1 stock A for 2DKK (this is the purchase_price) the stock is actually bought in NOK and at that day the conversion rate is 1:1 (to make it simple). They next day the value of the stock does not change but the conversion rate changes so now you need 2DKK for 1NOK. Purchase price is till 2DKK but current value is 4DKK.

Please correct me if I'm wrong :)

claha commented 3 years ago

Hi,

A quick glance at the code and it does not seem to handle the conversion rate in the profit/loss calculation. I will have a look at it.

Thanks for finding the bug :)

Best regards, Claes

Den tors 7 jan. 2021 17:18fabir-git notifications@github.com skrev:

I think this does not work at the moment. The results are way off if I try this.

Example: stock in dollar, conversion to euro. Purchase price in euro -> Profit is way to high.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/custom-components/sensor.avanza_stock/issues/91#issuecomment-756217973, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHHPVCUIO4HTKAAHL4V47LSYXNGPANCNFSM4QLWKFIA .