Combine Avanza and yahoo stock information

Some stocks are not available from avanza and therefor could not be used in the avanza integration with the entities-table-card.

How would I simulate a new sensor with states/attributes feeded from a yahoofinance sensor and combined with additional static or calculated information to display them in an entities table?

Below my entities table definition.
I assume a sensor with state fro yahoofinanze as state and additional attributes name (constant string), purchaseDate (constant string), profitLossPercentage (Needs to be calculate using state and two constant values), totalProfitLoss (Needs to be calculate using state and two constant values) and totalValue (Needs to be calculate using state and one constant value) would work, but I have no idea how the template(?) has to look like.

  - header: Name
    attr: name
  - header: Kurs
    source: state
    format: number
  - header: Kaufdatum
    attr: purchaseDate
    format: number
  - header: '%'
    attr: profitLossPercentage
    format: percentage
  - header: Gewinn/Verlust
    attr: totalProfitLoss
    format: currency
    showSummary: true
  - header: Aktueller Wert
    attr: totalValue
    format: currency
    showSummary: true

I would look at the Add Custom Attributes example here

1 Like

Thanks for that hint!

Is there a way to use variables or constants instead of entering the same value several times? As you can see in my example below, I have define the number of share and have entered the same value in purchasePrice. Same with value 5000 used in purchasePrice, totalProfitLoss and profitLossPercentage.

        value_template: >-
          {{ states('yahoofinance.x2hf_de') }}
          name: >-
            Deka MDax
          purchaseDate: >-
          shares:  >-
            {{ float(15) }}
          purchasePrice: >-
            {{ float(5000/15) }}
          totalValue: >-
            {{         15 * (states('yahoofinance.x2hf_de') | float) }}
          totalProfitLoss: >-
            {{         15 * (states('yahoofinance.x2hf_de') | float) - 5000 }}
          profitLossPercentage: >-
            {{ (100 * (15 * (states('yahoofinance.x2hf_de') | float) - 5000) / 5000) | round(2) }}