custom-components / sensor.avanza_stock

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

Add purchase date as instrument attribute #108

Closed ronnydahl closed 3 years ago

ronnydahl commented 3 years ago

Tjena!

It would be really neat to have an optional attribute for purchase date that is persisted. It would be useful for e.g. reports that lets you see how the instrument has performed since start. It would also be cool to have investment horizon (e.g. five years). This can be especially useful in reports.

claha commented 3 years ago

I could easily add the purchase_date attribute, will probably just be a string. Hopefully I can find the time this week.

Could you please further explain the investment horizon, is that also an attribute and how would it be used?

ronnydahl commented 3 years ago

Great! Maybe add it in a format so that it can be parsed as datetime? Maybe ISO 8601? The investment horizon could be stored in the same way.

With investment horizon, I refer to the field on the right hand size on instrument details on Avanza (below Risknivå, Rekommenderad sparhorisont: Minst 5 år). This field is of course just a recommended period before one consider realizing the stocks, but it could be helpful in reports. Also another field I think could be interesting is a instrument classification. If the instrument is bound to a period of time (e.g. pension) or similar. I can create a separate "issue" for that if you want :)

claha commented 3 years ago

Seems investment horizon is not available in the api that is currently used by this component. But apparently there is a new api at avanza (which seems to be used in the updated fund pages) https://www.avanza.se/_api/fund-guide/guide/2253 which returns the attribute recommendedHoldingPeriod. Unfourtenatley not that easy to just change to the new api, currently the same endpoint is used for wathever instrument is fetched (stock, fund, index, certificate, ...) but with the new api these seem to have different endpoints.

I have been thinking of redoing this component and have it integrated into homeassitant/core, then I should probably use this new api which seems to provide more information.

Yes, please create an other issue for that :)

ronnydahl commented 3 years ago

Great work! Thanks 😊