Custom Component Avanza Stock

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 https://github.com/gwendo/entities-table-card 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

I’ve created an own thread for the Entities table card, notifications about updates will be posted here: Entities table card

Hi, I just installed this, and it looks very good.
But I have some questions. My sensor config looks like this:

  shares: 222
  purchase_date: "2021-10-21T-00:00+00"
  purchase_price: 2991.32

the price is in euro (the stock is also in euro)
In the sensor’s attributes, I get this:

shares: 222
totalValue: 5066.04
purchaseDate:  2021-10-21T-00:00+00
purchasePrice: 2991.32
profitLoss: -2968.5
totalChange: -39.96
profitLossPercentage: -99.24
totalProfitLoss: -659007

Could someone explain the meaning of the last 4 values to me please?
If I calculate 2991.32-5066.04 I get -2074.72 not -2968.5 for profitLoss.

Also, I couldn’t find any information about the date format. Is the above the correct one?

Thanks

Hi!

profitLoss is the current price minus purchasePrice.
totalChange is todays change mulitplied with shares.
profitLossPercentage is how much the price has changed compared to purchasePrice
totalProfitLoss is profitLoss multiplied by shares.

In your example totalValue is the current price multiplied by shares

Ah, thank you.
What irritated me was the purchase_price in the sensor config is per share and profitLoss is profit or loss not the loss of profit.

Do I even need the prurchaseDate if I provide the purchasePrice already?

Sorry I missed your question about the date. It is just a string, not used for anything so you can remove it. It was requested by someone to have, not sure what they use it for.

I can’t find the ID corresponding to MSOS symbol on Avanza. It’s an ETF trading on the NYSE it should be easy to find but it’s not on Avanza website :frowning:

Unfourtnately (I think it is beacuse of EU-law) not all US based ETF are possible to invest in through Avanza :frowning:

Just wondering, is this an issue specific to MSOS ETF, or other ETFs are also blocked in Europe? Is this due to the legal status of cannabis in EU?

There are a lot of ETFs that are blocked/not available, dont think has anything to do with cannabis.

I installed the entities-table-card via hacs but whatever i do: no result:

type: custom:entities-table-card
name: Portfolio
showSummary: true
entities:
  - entity: sensor.btc_eur
dataColumns:
  - header: Name
    attr: name
  - header: Daily
    attr: changePercent
    format: percentage
  - header: State
    source: state
    format: number
  - header: '%'
    attr: profitLossPercentage
    format: percentage
  - header: Profit/Loss
    attr: totalProfitLoss
    format: currency
  - header: Value
    attr: totalValue
    format: currency

tried various versions of the card but none of them are working , anybody a hint?

found the issue.

in configuration.yaml I needed to add

    monitored_conditions:
      - totalVolumeTraded
      - totalValueTraded
      - change
      - changePercent

Hello!

I find this HACS very interesting but while setting my configuration.yaml, I cannot pass the verification. It keeps running and I can’t get the Configuration Valid! confirmation.

sensor:

  - platform: avanza_stock
    stock:
      - id: 789695
        name: Nouveau Monde Graphite
        shares: XXX
        purchase_price: 19.17
      - id: 691678
        name: Euro Sun Mining
        share: XXX
        purchase_price: 2.12
    monitored_conditions:
      - totalVolumeTraded
      - totalValueTraded
      - change
      - changePercent
      - lastPrice

Is there something I am missing here?

Your second entry has share, should be shares. Maybe that’s it?

Even correcting that mistake, I cannot pass the verification for my YAML file.

And if I remove the code for avanza_stock, it’s fine

Could you please post your logs, found under Settings->System->Logs.