custom-components / sensor.avanza_stock

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

id missing in attributes #160

Closed fatuuse closed 10 months ago

fatuuse commented 11 months ago

The attribute id in monitored sensor is missing and result in null

name: Avanza Zero
id: null
change: -1.41

config:

monitored_conditions:
  - name
  - id
  - change
  - changePercent
  - morningStarFactSheetUrl
  - priceAtStartOfYear
  - totalVolumeTraded
  - totalValueTraded
  - priceOneWeekAgo
  - priceThreeMonthsAgo
  - tickerSymbol
  - marketPlace
  - tradable
  - hasInvestmentFees
  - flagCode

Same for:

hasInvestmentFees: null
priceAtStartOfYear: null
totalVolumeTraded: null
totalValueTraded: null
priceOneWeekAgo: null
priceThreeMonthsAgo: null
tickerSymbol: null
marketPlace: null
flagCode: null
claha commented 11 months ago

Thanks for letting me know that these does 't work. The api changed sometime last year and I haven't prioritized to go through all the attributes, the "most important" ones are fixed.

Here is the response from the new api.

{"orderbookId":"41567","name":"Avanza Zero","isin":"SE0001718388","instrumentId":"41467","sectors":[],"tradable":"BUYABLE_AND_SELLABLE","listing":{"shortName":"Avanza Zero","tickerSymbol":"Avanza Zero","countryCode":"SE","currency":"SEK","marketPlaceCode":"FUND","marketPlaceName":"Fondmarknaden","tickSizeListId":"7700001","marketTradesAvailable":true},"historicalClosingPrices":{"oneDay":343.04,"oneWeek":350.810000,"oneMonth":353.930000,"threeMonths":364.040000,"startOfYear":316.980000,"oneYear":315.240000,"threeYears":255.890000,"fiveYears":226.340000,"tenYears":143.890000,"start":81.053630,"startDate":"2006-05-22"},"keyIndicators":{"numberOfOwners":603146,"dividendsPerYear":0},"quote":{"last":341.63,"highest":341.63,"lowest":341.63,"change":-1.41,"changePercent":-0.41,"timeOfLast":1692309600000,"totalValueTraded":0.00,"totalVolumeTraded":0,"updated":1692309600000},"type":"FUND"}

So I/someone needs to create a mapping from the old attributes to the new ones. And also since this is a fund (not a stock) we should instead call som other endpoint, like it is done for etfs.

Truepix commented 10 months ago

do we have any developments regarding a fix?

claha commented 10 months ago

Not really, I might have some time tomorrow or start of next week. I will start with the attributes listed above, please let me know of others of importance 🙂

claha commented 10 months ago

Fixed all but hasInvestmentFees which I could not find any equivalent to

Truepix commented 10 months ago

Wonderful, thank you so much for your help and dedication. I am aware that this is not your main job and that you do this voluntarily. But know that your work is greatly appreciated Thank you very much for your help.