Custom Component Avanza Stock

Aha, shouldn’t be that hard then!
I am already using HACS and quick look at the links you shared it seems like it should not be that hard to get what I want actually :slight_smile:
Ill give it a try tonight

Thanks for the help!
And again, great job on the component :slight_smile:

Works great! Thanks, I also saw you put the " % gain/loss calculation " on your todo list! Bravo. Great work on this, seems to be more robust and works better then the alpha vantage integration. I’d love to have this integrated directly into hass for easier updates / watching the repo, but you can’t win them all I suppose. I’m going to open up a short ticket for something that may interest you as an enhancement. Fractional shares! I’m one of many people now who partake in fractional share buying/selling. I know this integration doesn’t do a whole lot of that, but for people (and when you have gain loss calc working) who use fractional shares, this would mean more accurate reporting in hass. Just a thought, cheers!

Tjena @claha!
Thanks for this component - love it! have you considered to specify the opening hours for each market in order to not update the stocks when the markets aren’t open?

Has anyone come up with a beautiful way of presenting this? I’m quite new to Home Assistant and haven’t found the best way for that yet?

1 Like

I created mini-graph-cards and a price alerts for my sensors with this integration. You can find my config here
I also have two blog posts on this:


Wow, that’s really helpful! Very nice! Perfect for a rookie like me to piggyback :slight_smile:

Can I just ask, in order to display any of the monitored_conditions/attributes, do I use a template sensor or what is the easiest way to get the changePercent dispayed?

How do you @eifinger get a history graph of the stock, mine is flat and the dates are todays dates only:

Template sensor is one alternative, there exist some custom lovelace cards, there are probably more

Or you could try to create a custom card yourself aimed at this sensor :wink:

1 Like

I’ll look into that once I start understanding how HA in general works :wink:

Maybe not even possible but has anyone managed to get a refresh button to get an instant refresh of the stock prices?

Go to Developer Tools -> Services and use homeassistant.update_entity :blush: You might need to enable Developer Tools… You can write a script that updates all your stocks using that service, I use it update all my stocks after stock market closes and then send a daily summary

1 Like

You need to have the hours of data in the database. If you just added the sensors it will take some days until the graphs show something else than a flat line

1 Like

Thanks, makes sense :slight_smile:

Can I ask if you have solved it so that the graph show this year in a graph, meaning how a stock/market has developed since January 1st or since the first of the current month (April 1st)?

I don’t store that much data in my home-assistant database. I purge everything older than 30 days.
To get a view of all data I use the influxdb integration and grafana.

Alright, I think I remember reading something that there is a standard function to remove data so that most likely applies to mine too. Thanks for your help!

1 Like

Because of the recent increased activity in this thread I decided to take some time a do some updates. Version 1.0.1 supports fractional shares and also adds a totalValue and totalChange attribute which will be set if shares is defined. If the change or changePercent attribute is monitored you will now also get changeOneWeek/Percent, changeOneMonth/Percent,…, changeFiveYears/Percent, changeCurrentYear/Percent attributes.

If you have any more suggestions on imporovements or features please post here or write and issue at

1 Like

You are a fucking boss! I literally just asked about fractional shares…That’s a github star from me chief!


Version 1.0.3 released. You can now define multiple stock id, no need to copy paste the same monitored conditions everywhere. Check REDAME/HACS for example.

My plans for the future is to create an offical integration that can track not just stocks, but fonds/bonds/certificates etc. If you have feature requests for that please create an issue in the avanza stocl custom component repo and I will take a not of it.

1 Like

Hi, is it possible to define the target-currancy (e.g. Euro), in which the stock is shown? Most stocks are shown in Dollars, but for Germany Euro would be nice.

No it is not possible. What I have done is that i also track currencies (ex and then in my notification scripts I check unit_of_measurement and convert to the currency I want.

I will see if it is possible to integrate this into the component, it will probably require that you define for each stock where it should get its factor from.

I actually really liked this idea of automatic conversion to the preferred currency, so I created an issue for it. expect to see this in the next release, hopfully within a week :blush:

1 Like

Is it possible to see if it’s a fund?

I sorted it out by my self.
If hasInvestmentFees is true then it is.

No there is not. I’m planning to get an official avanza component into HA and there it will be a distinction between stock, fund, … since there are different available apis for each. It is just pure luck that funds can be tracked using the stock api :blush: