Custom Component Avanza Stock

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:


I’ve been working on a custom card that can show my portfolio in a table with summary if anyone is interested. It can be used standalone or together with the filter functionality of auto-entities.


Sweet! Link to get the code? :smiley:

Give me a day, I’ll clean up the readme and stuff.

Here’s the code

1 Like

Looks very nice :slight_smile: Time to fix that wallmounted screen… :smirk:

1 Like

Nice work on this guys! Really great idea, and a end of day notification is awesome!
Here is what I thought I would contribute…entering the data is very tedious…here is how to make it easy (ier):

  • Create an excel spreadsheet. Columns:
    A: Ticker
    B: #OfShares
    C: Purchased Price
    D: StockID (as per instructions)
    E: Sensor: Formula starting E2 is =" - id: " &D2 & CHAR(10) &" name: " & A2 & CHAR(10) & " shares: " & B2 & CHAR(10) & " purchase_price: " & C2
    F: StockGainToday: Formula is =“states.sensor.”& LOWER(A2)& ".attributes.totalChange +"
    G: StockGainTotal: Formula is =“states.sensor.”& LOWER(A2)& ".attributes.totalProfitLoss +"
    H: Lovelace Card: Formula is =" - entity: sensor." & LOWER(A2)

Once you have all you stock entered (columns A B C D):

Column E can be selected whole, copied, pasted in notepad++, all double quotes replaced by nothing, and it’s ready to be pasted in sensors.yaml.

I created template sensors to add up the “totalChange” (StockGainToday), and “totalProfitLoss” (StockGainTotal), which is what columns F and G are about. Whole columns can be copied straight from Excel to yaml. This is what I use for daily notifications.

Finally, the last column H is for the table custom card. The whole columns can be copied and pasted to the card config.

It also make it easier to maintain once more stocks are bought (or sold!).

Hi guys,

I would love to use this card, however im still a Home Assistant beginner so I dont understand how to install this? Usually there is a HACS link or a file download but in I cant find it.

Please instruct a noob :slight_smile:

Tja! Great work on the component. I just started messing around with it.

Do you have any ideas on how to smooth out the graphs and only show data when the market is open?

Not 100% sure but I think that I did this.
HACS -> Frontend -> ••• (vertical) -> Custom repositories and then add the link.

Hope it helps :slight_smile:

Thank you Claes, had no idea about the custom repositories option. Worked perfectly