GithubHelp home page GithubHelp logo

iprak / yahoofinance Goto Github PK

View Code? Open in Web Editor NEW
68.0 8.0 11.0 263 KB

Home Assistant component which allows you to get stock updates from Yahoo finance.

License: MIT License

Python 99.62% Dockerfile 0.38%
homeassistant-components homeassistant hacs home-assistant yahoo-finance stock-updates

yahoofinance's Introduction

Summary

A custom component to display stock information from Yahoo finance.

Currency details can be presented in an different currency than what is reported (target_currency). Data is downloaded at regular intervals (scan_interval) but a retry is attempted after 20 seconds in case of failure.

Installation

This can be installed through HACS or by copying all the files from custom_components/yahoofinance/ to <config directory>/custom_components/yahoofinance/.

Configuration

Define the symbols to be tracked and optional parameters in configuration.yaml.

# Example configuration.yaml entry
yahoofinance:
  symbols:
    - ISTNX

The above configuration will generate an entity with the id sensor.yahoofinance_istnx and current value as the state along with these attributes:

state_class: measurement
attribution: Data provided by Yahoo Finance
currencySymbol: $
symbol: ISTNX
quoteType: MUTUALFUND
quoteSourceName: Delayed Quote
marketState: PRE
averageDailyVolume10Day: 0
averageDailyVolume3Month: 0
regularMarketChange: 0.35
regularMarketChangePercent: 0.5
regularMarketDayHigh: 0
regularMarketDayLow: 0
regularMarketPreviousClose: 69.93
regularMarketPrice: 70.28
regularMarketVolume: 0
regularMarketTime: 2024-05-10T19:00:27-05:00
dividendDate: null
forwardPE: 0
trailingPE: 0
fiftyDayAverage: 69.79
fiftyDayAverageChange: 0.49
fiftyDayAverageChangePercent: 0.7
preMarketChange: 0
preMarketChangePercent: 0
preMarketTime: 0
preMarketPrice: 0
postMarketChange: 0
postMarketChangePercent: 0
postMarketPrice: 0
postMarketTime: 0
twoHundredDayAverage: 62.94
twoHundredDayAverageChange: 7.34
twoHundredDayAverageChangePercent: 11.67
fiftyTwoWeekLow: 53.81
fiftyTwoWeekLowChange: 16.47
fiftyTwoWeekLowChangePercent: 30.61
fiftyTwoWeekHigh: 72.44
fiftyTwoWeekHighChange: -2.16
fiftyTwoWeekHighChangePercent: -2.98
trending: up
unit_of_measurement: USD
icon: mdi:trending-up
friendly_name: Ivy Science & Technology Fund C

Attributes

  • The attributes can be null if there is no data present.
  • The dividendDate is in ISO format (YYYY-MM-DD).

Optional Configuration

Integration

  • Data fetch interval can be adjusted by specifying the scan_interval setting whose default value is 6 hours and the minimum value is 30 seconds.

    scan_interval:
      hours: 4

    You can disable automatic update by passing manual for scan_interval.

  • Trending icons (trending-up, trending-down or trending-neutral) can be displayed instead of currency based icon by specifying show_trending_icon.

    show_trending_icon: true
  • All numeric values are by default rounded to 2 places of decimal. This can be adjusted by the decimal_places setting. A value of 0 will return in integer values and -1 will suppress rounding.

    decimal_places: 3
  • The fifty_day, post, pre and two_hundred attributes can be suppressed as following. They are included by default.

    include_fifty_day_values: false
    include_fifty_two_week_values: false
    include_post_values: false
    include_pre_values: false
    include_two_hundred_day_values: false

Symbol

  • An alternate target currency can be specified for a symbol using the extended declaration format. Here, the symbol EMIM.L is reported in USD but will be presented in EUR. The conversion would be based on the value of the symbol USDEUR=X.

    symbols:
      - symbol: EMIM.L
        target_currency: EUR

    If data for the target currency is not found, then the display will remain in original currency. The conversion is only applied on the attributes representing prices.

  • The data fetch interval can be fine tuned at symbol level. By default, the scan_interval from the integration is used. The minimum value is still 30 seconds. Symbols with the same scan_interval are grouped together and loaded through one data coordinator.

    If conversion data needs to be loaded, then that too will get added to the same coordinator. However, if conversion symbol is found in another coordinator, then that will get used.

    scan_interval:
      hours: 4
    scan_interval:
      minutes: 5
    scan_interval: 300
  • The unit_of_measurement can be suppressed by setting no_unit: true. This could be used for index symbols if no currency unit is desired to be displayed.

    • Note: Using this setting will generate a warning like The unit of sensor.yahoofinance_gspc cannot be converted to the unit of previously compiled statistics (USD). Generation of long term statistics will be suppressed unless the unit changes back to USD or a compatible unit. You will have to manually resolve it as mentioned in the message otherwise new data might not show in cards.

Examples

  • The symbol can also represent a financial index such as this.

    symbols:
      - ^SSMI
  • Yahoo also provides currency conversion as a symbol.

    symbols:
      - GBPUSD=X
  • A complete sample

yahoofinance:
  include_post_values: false
  include_pre_values: false
  show_trending_icon: true
  decimal_places: 2
  scan_interval:
    hours: 4
  symbols:
    - USDINR=X
    - UNP
  • The trending icons themselves cannot be colored but colors can be added using lovelace-card-mod. Here auto-entities is being used to simplify the code.

    - type: custom:auto-entities
      card:
        type: entities
        title: Financial
      filter:
        include:
          - group: group.stocks
            options:
              entity: this.entity_id
              style: |
                :host {
                  --paper-item-icon-color: {% set value=state_attr(config.entity,"trending") %}
                                          {% if value=="up" -%} green
                                          {% elif value=="down" -%} red
                                          {% else %} var(--paper-item-icon-color))
                                          {% endif %};

Services

The component exposes the service yahoofinance.refresh_symbols which can be used to refresh all the data.

Breaking Changes

  • As of version 1.2.5, scan_interval can be manual to suppress automatic update.

  • As of version 1.1.0, the entity id has changed from yahoofinance.symbol to sensor.yahoofinance_symbol.

  • As of version 1.0.0, all the configuration is now under yahoofinance. If you are upgrading from an older version, then you would need to adjust the configuration.

  • As of version 1.0.1, the minimum scan_interval is 30 seconds.

yahoofinance's People

Contributors

cabberley avatar feikojoosten avatar grandadevans avatar iprak avatar ktibow avatar swiergot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yahoofinance's Issues

MINIMUM_SCAN_INTERVAL

I was setup scan_interval as 1sec, after update seems like minimum_scan_interval is change to 30sec. suggestion keep minimum scan interval as 1sec thanks

Dividend - ex date, payment day, amount per share

Is it possible to have data for dividends? payment day at least?

it would be nice to hear on my daily welcome routine information that some company is paying me today:) Avanza has those data, but there is only a limited stock market (the US and only some European countries ) - Yahoo has more stocks

HA 2021.12.1 "device_state_attributes" warning

At every restart, the following warning appears:

2021-12-13 10:41:26 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.yahoofinance_gc_f (<class 'custom_components.yahoofinance.sensor.YahooFinanceSensor'>) implements device_state_attributes. Please report it to the custom component author.

Not sure, if it wil be deprecated in near future or something else, just notyfing the author as instructed :).

Refactor integration to use 'sensor' domain instead of custom 'yahoofinance' domain

Love the integration, however it doesn't follow HA development guidelines.

The entities created should exist under the sensor domain (perfectly capable of handling everything present in this integration), rather than a new custom domain just for this integration.

Reasons for this:

  • Compliance with HA development guidelines
  • Consistency with all other integrations
  • UI/Frontend restrictions (most UI elements will restrict the domains usable as entities)

Unique Id for entity

Can you added unique ID for each entity?
Than can be modify by user - example: change name.

Thanks.

Bug: Data for the conversion symbol is loaded consistently in time

When there are a lot of entities and lots of symbols, then additional conversion symbol might not load. The call to async_request_refresh goes out but data is not loaded - this might be due to debouncing since the coordinator is still processing data from the last refresh. Delaying the additional refresh seems to work.

TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'

This used to be working until an update or two ago (it took me a couple weeks to find time to report it).

Using the following config:

- platform: yahoofinance
  symbols:
    - AMZN
    - TSLA
    - MSFT
    - AMD
    - GME

The integration will not start up due to this error:

Logger: homeassistant.setup
Source: custom_components/yahoofinance/__init__.py:72
First occurred: 3:04:11 PM (1 occurrences)
Last logged: 3:04:11 PM

Error during setup of component yahoofinance
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/config/custom_components/yahoofinance/__init__.py", line 88, in async_setup
    scan_interval = parse_scan_interval(domain_config.get(CONF_SCAN_INTERVAL))
  File "/config/custom_components/yahoofinance/__init__.py", line 72, in parse_scan_interval
    elif scan_interval < MINIMUM_SCAN_INTERVAL:
TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'

Error on startup and calling yahoofinance.refresh_symbols service (introduced in v1.0.5)

I am getting the following errors on startup and when calling the yahoofinance.refresh_symbols service, meaning that the prices are no longer updating. This problem appears to have been introducted in v1.0.5, as downgrading to v1.0.4 causes the errors to disappear and the prices to refresh again. I have highlighted the potential cause, which looks like it could be a typo / syntax error for the operator '+:'

2021-02-17 17:24:46 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform yahoofinance
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 315, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 506, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/yahoofinance/sensor.py", line 282, in async_added_to_hass
self._coordinator.async_add_listener(self.async_write_ha_state)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 83, in async_add_listener
self._schedule_refresh()
File "/config/custom_components/yahoofinance/init.py", line 228, in _schedule_refresh
utcnow().replace(microsecond=0) + self.get_next_update_interval(),
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

2021-02-17 17:24:46 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up yahoofinance platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 206, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 315, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 506, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 530, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/yahoofinance/sensor.py", line 282, in async_added_to_hass
self._coordinator.async_add_listener(self.async_write_ha_state)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 83, in async_add_listener
self._schedule_refresh()
File "/config/custom_components/yahoofinance/init.py", line 228, in _schedule_refresh
utcnow().replace(microsecond=0) + self.get_next_update_interval(),
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

2021-02-17 17:30:00 ERROR (MainThread) [homeassistant.components.automation.shares_update_prices] Shares: Update prices: Error executing script. Unexpected error for call_service at pos 1: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 254, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/yahoofinance/init.py", line 148, in handle_refresh_symbols
await coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 75, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in async_refresh
self._schedule_refresh()
File "/config/custom_components/yahoofinance/init.py", line 228, in _schedule_refresh
utcnow().replace(microsecond=0) + self.get_next_update_interval(),
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

2021-02-17 17:30:00 ERROR (MainThread) [homeassistant.components.automation.shares_update_prices] While executing automation automation.shares_update_prices
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/init.py", line 404, in async_trigger
await self.action_script.async_run(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1033, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 246, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 254, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/yahoofinance/init.py", line 148, in handle_refresh_symbols
await coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 75, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in async_refresh
self._schedule_refresh()
File "/config/custom_components/yahoofinance/init.py", line 228, in _schedule_refresh
utcnow().replace(microsecond=0) + self.get_next_update_interval(),
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

UK stocks

How do we do UK stocks? Trying to get BT.A for example and nothing is returned.

Errors and inaccurate data when changing or adding config symbols

When adding or replacing symbols to the original config, I end up getting errors in the Home Assistant log, like this:

2021-05-27 18:04:44 WARNING (MainThread) [custom_components.yahoofinance.coordinator] Requested data for SPDR and received MSFT

When this occurs, inaccurate data is represented in lovelace (SPDR populated with MSFT values, and MSFT values are null):

snip_1
SPDR_Entity
MSFT_Entity

Feature request - set a currency for currency conversion

Hello,

I would like to have the value delivered back in a different currency than yahoo. I also track prices of ETFs such as the following: https://finance.yahoo.com/quote/EMIM.L
This one is listed in GPB. Would it be possible to include an automatic conversion for this, so that the price is displayed in the specified currency.
The rates of GBP => USD => EUR are provided by Yahoo Finance(GBPUSD=X / EURUSD=X), but I don't want to miss out on all attributes and features with a custom template sensor.

Regards

The sensors became unavailable.

Hi,

First of all, Thanks for creating this project. I was able to get it up and running for a month (I think) but as of last week, all the sensor shows unavailable. Any advice is appreciated.

FEATURE REQUEST: IPOs Calendar

Could it be possible to have a notification for new IPOs calendar?
example:

sensor:
  - platform: yahoofinance
    calendar

and that could change to 1 for an update and after a few hrs change back to 0, that way we could create an alarm that could send a notification to the phone.

Home Assistant Long-term Statistics support

Thanks for making this component, it's been working great!

HASS 2021.8 introduced long-term statistics (see https://www.home-assistant.io/blog/2021/08/04/release-20218/) which would be nice to have support for with yahoofinance.

From what I can tell the only thing that should be needed is to set the "state_class" property to "measurement", see: https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

After this change the long term statistics can be seen in the developer tools (https://my.home-assistant.io/redirect/developer_statistics/) or by using the statistics graph card (https://www.home-assistant.io/dashboards/statistics-graph/)

As a secondary enhancement it might be good idea to set "device_class" property to "monetary"? See: https://www.home-assistant.io/integrations/sensor/#device-class

Feature request - Icon state related colors (Also doc addition suggestion for indexes)

First, thanks for this integration! Gave up on having stocks in HA a long time ago; integrations were unreliable, doing it via REST sensors involved a lot of work and hard to find APIs. Then I found this in HACS and was super happy someone was finally developing something that works!

Request: Would it be possible to include coloring for the icons based on the state of the entity? Either user input config or even simple Red/Yellow/Green for Trending Down/Neutral/Trending Up states. I'd just like that immediate visual recognition and I think it would add to the function/features.

Also: Discovered that I could add indexes by using the symbol and caret; e.g.

- platform: yahoofinance
  show_trending_icon: true
  scan_interval:
    minutes: 15
  symbols:
    - ^DJI
    - ^IXIC
    - ^VIX
    - AAPL
    - AMZN
    - GOOGL
    - UPS
    - UNM

Works great in case you want to add this to the docs; you can get the index abbreviation from the URL in the Yahoo Finance page. Thanks!

UI-integration an new attributes

Please consider the following functionality:

  1. Make an UI-integration so stocks can be added using the UI. – No restart off HA needed.

  2. Add two attributes, «buy price» and «number of stocks»
    Using the UI-integration the two attributes can be set by the user.

This way a portfolio can be created in HA for daily monitoring.

Cheers.

UPDATE:
I see the functionality #2 has been proposed before. I am a N00b, where and how, in your code do I write in some code to get two new attributes? This way I can populate them manually.

Error on startup of plugin: "'YahooSymbolUpdateCoordinator' object has no attribute '_job'"

I get the following error after updating the plugin to version 1.0.7. I came from 1.0.0 so had to reconfigure my configuration.yaml. After starting homeassistant the following error pops up.

 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up yahoofinance platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 481, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/yahoofinance/sensor.py", line 286, in async_added_to_hass
    self._coordinator.async_add_listener(self.async_write_ha_state)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 77, in async_add_listener
    self._schedule_refresh()
  File "/config/custom_components/yahoofinance/__init__.py", line 229, in _schedule_refresh
    self._job,
AttributeError: 'YahooSymbolUpdateCoordinator' object has no attribute '_job'

Configfile is as follows

show_trending_icon: true
scan_interval:
  minutes: 1
symbols:
  - USDEUR=X
  - symbol: TSLA
    target_currency: EUR
  - symbol: GOOGL
    target_currency: EUR
  - symbol: MSFT
    target_currency: EUR
  - BTC-EUR
  - ETH-EUR

FEATURE REQUEST: Change percent

Hi,

It would be great also to have the change percent ( seems to be the regularMarketChangePercent property in the api )
image

Thanks for this great integration

Gunth

The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2

Running the integration on the latest beta triggers the following error message:

Detected integration that called async_timeout.timeout with loop keyword argument. The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2. Please report issue to the custom component author for yahoofinance using this method at custom_components/yahoofinance/coordinator.py, line 163: async with async_timeout.timeout(WEBSESSION_TIMEOUT, loop=self.loop):

YahooFinance not working if YahooFinance server is down at HA boot

Hello!

YahooFinance seems to have issues this morning and so the servers seems to reply with error 500 when presented a request - wich I guess is something that can happen. Here is the log I see in my HA logs :
2021-02-11 13:57:20 ERROR (MainThread) [custom_components.yahoofinance] Error requesting YahooSymbolUpdateCoordinator data: 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url=URL('https://query1.finance.yahoo.com/v7/finance/quote?symbols=BOB,SPG,URW.AS,COV.PA,NQ=F,%5EGSPC,%5ENDX,HUF=X,EURUSD=X,QQQ,EEM,EURHUF=X,SPY,WIZ,DUDE,ES=F,SCZ,MAC,O,TMF')
2021-02-11 13:57:20 INFO (MainThread) [homeassistant.setup] Setup of domain yahoofinance took 2.9 seconds
Now the problem is that after that first try, the custom component seems to give up and never tries again... I guess this is an issue and should be corrected - the component should do several attempts?

Issue on restart

Hello, great work with this, however I'm noticing that on restarting HA, the integration is bringing through what I'm assuming is the default value of USD, and then updating to what I want it to be (GBP)

This unfortunately messes up my graph as it looks like there's been a spike when there hasn't - If you ignore the start of the chart as its where I was integrating and doing loads of changes, but today o've restarted twice and both times seen a spike
Screenshot 2021-10-12 at 10 18 41 am

Screenshot 2021-10-12 at 10 19 49 am

v1.1.10 stops retrieving data

Hi,
I am on version 1.1.9, integration is working correctly. I have netities defined as sensor.yahoofinance_symbol and they are correctly retrieveing values. After upgrade to v1.1.10 integration stops retrieving data anymore. Tried couple of times, the same result.
Kind regards,
PKort

TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'

I am getting an error w/ Hassos v2021.02

The errors has something to do w/ the scan interval change introduced here

2021-02-04 11:50:28 ERROR (MainThread) [homeassistant.setup] Error during setup of component yahoofinance
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/config/custom_components/yahoofinance/__init__.py", line 88, in async_setup
    scan_interval = parse_scan_interval(domain_config.get(CONF_SCAN_INTERVAL))
  File "/config/custom_components/yahoofinance/__init__.py", line 72, in parse_scan_interval
    elif scan_interval < MINIMUM_SCAN_INTERVAL:
TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'

my config is as follows:

sensor:
  - platform: yahoofinance
    show_trending_icon: true
    symbols:
      - CSCO
    scan_interval:
      hours: 1


I am running v1.01

Thanks

[Feature Request] Portfolio Holdings

Hi,

Thanks for creating this project.
Any chance it would be possible to add the portfolio holdings (total $$$) including total/day gains/losses?

Cheers

Entity sensor.yahoofinance_xyz (<class 'custom_components.yahoofinance.sensor.YahooFinanceSensor'>) is using state class 'measurement' which is impossible considering device class ('monetary') it is using

Since update to home assistant 2023.02 these warnings are emitted on startup:

WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.yahoofinance_xxxx (<class 'custom_components.yahoofinance.sensor.YahooFinanceSensor'>) is using state class 'measurement' which is impossible considering device class ('monetary') it is using; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

EUR=X doesn't compute

Hi,

If I use the symbol EUR=X I get the following errors:

Logger: custom_components.yahoofinance.coordinator
Source: custom_components/yahoofinance/coordinator.py:218
Integration: Yahoo Finance ([documentation](https://github.com/iprak/yahoofinance), [issues](https://github.com/iprak/yahoofinance/issues))
First occurred: 11:22:41 (22 occurrences)
Last logged: 15:54:01

    Received USDEUR=X not in symbol list
    No data received for ['EUR=X']

It looks like EUR=X is defined but USDEUR=X is used to query Yahoo?

Refresh interval

Is there any way to update the prices like every 10 minutes? Or is it a limitation in requests to the API?

FEATURE REQUEST: buy details

I have a feature request.

It would be nice to be able to enter details about the initial purchase of the stock, without creating an additional template entity for each symbol. For example:

sensor:
  - platform: yahoofinance
    symbols:
      - SYMBOL
        quantity: 43
        cost_per_share: 3.52
        date: 2020-04-29

Then add some additional attributes:

  • Cost basis (cost_per_share * quantity)
  • Gain/loss % (total since purchase)
  • Gain/loss $ (total since purchase)
  • Day change $ (current daily change * quantity)
  • Market value (quantity * current price)
  • Short/Long Term (boolean, 0=short term (held less than 1 year), 1=long term (held greater than 1 year))

Finally having some new entities could provide useful as well.

  • Total market value (all stocks combined current value)
  • Total cost basis (all stocks combined, value at purchase)
  • Total day change % (All stocks in yaml list)
  • Total day change $ (All stocks in yaml list)
  • Total gain loss % (All stocks in yaml difference of current value from purchased value)
  • Total gain loss $ (All stocks in yaml difference of current value from purchased value)

Currency Exchange

v1.0.0 appears to have broken the ability to include currency exchange rates? - working ok for me in v0.4:

- platform: yahoofinance
    symbols:
      - USDEUR=X

Thank you!

target_currency goes back to DOLLARS

yahoofinance:
    symbols:
      - symbol: RBOT.L
        target_currency: EUR
      - symbol: ECAR.L
        target_currency: EUR

After the first update, that shows up as EUR. It will set the currency as dollars again.
image

TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'

I just install HACS and when I restart the server and here is the issue. Please advise
Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/setup.py", line 229, in _async_setup_component result = await task File "/home/homeassistant/.homeassistant/custom_components/yahoofinance/__init__.py", line 171, in async_setup scan_interval = parse_scan_interval(domain_config.get(CONF_SCAN_INTERVAL)) File "/home/homeassistant/.homeassistant/custom_components/yahoofinance/__init__.py", line 136, in parse_scan_interval elif scan_interval < MINIMUM_SCAN_INTERVAL: TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'

Url to stock chart

Using your integration for quick look at my main stocks.
Would be nice to have a stock attribute in the form as an url to Yahoo charts for the stock.

Feature suggestion: variable or multiple scan interval

I would love to see the ability to set scan interval by symbol or group symbols and set scan interval by group. OR have multiple instances of the integration running. Reason: for most funds, etfs etc. a daily update would be more than enough. Only for a few stocks though I'd like to set updates by minute

Errors when starting home assistant

I get the following errors when starting home assistant
image

Logger: homeassistant.setup
Source: custom_components/yahoofinance/__init__.py:116
First occurred: 9:22:10 AM (1 occurrences)
Last logged: 9:22:10 AM

Error during setup of component yahoofinance
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/config/custom_components/yahoofinance/__init__.py", line 148, in async_setup
    scan_interval = parse_scan_interval(domain_config.get(CONF_SCAN_INTERVAL))
  File "/config/custom_components/yahoofinance/__init__.py", line 116, in parse_scan_interval
    elif scan_interval < MINIMUM_SCAN_INTERVAL:
TypeError: '<' not supported between instances of 'NoneType' and 'datetime.timedelta'
Logger: homeassistant.setup
Source: setup.py:280
First occurred: 9:22:10 AM (1 occurrences)
Last logged: 9:22:10 AM

Unable to prepare setup for platform yahoofinance.sensor: Unable to set up component.

This is the relevant part of my configuration.yaml

#sensors
sensor: !include_dir_merge_list include_files/sensor/

And inside that directory a file named yahoofinance.yaml

#yahoofinance
- platform: yahoofinance
  show_trending_icon: true
  scan_interval:
    minutes: 15
  symbols:
    - AMD
    - ALGT
    - AMZN

README fix

The README refers to/links browser_mod in relation to color-coding the trend icons. I think this should say card_mod.

Installation error

Log error after installing via HACS;

2022-01-08 16:04:13 ERROR (MainThread) [homeassistant.components.hassio] The system cannot restart because the configuration is not valid: Integration error: yahoofinance - Integration 'yahoofinance' not found.

Fully accept i might be doing something wrong, but can't see what?

Screenshot 2022-01-08 at 16 14 28

Configuration.yaml

yahoofinance:
  symbols:
    - HSBA.L
    - TEF.MC
  scan_interval:
    hours: 2
  show_trending_icon: true

Thanks.

GBPUSD

Hello, I am trying to use your integrations for currency conversion and having issue with that.

I have following configuration but get no data back.

Please do let me know if its possible.

  • platform: yahoofinance
    scan_interval:
    hours: 4
    symbols:
    • USDGBP

Kind Regards,

After update 2021.12.2 setup failed: unknown error

Since I updated to 2021.12.2 I can’t get any data. The following error occurs.

Logger: homeassistant.setup
Source: custom_components/yahoofinance/coordinator.py:36
Integration: yahoofinance (documentation, issues)
First occurred: 15 december 2021 22:07:54 (1 occurrences)
Last logged: 15 december 2021 22:07:54

Setup failed for yahoofinance: unknown error
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/setup.py", line 181, in _async_setup_component
component = integration.get_component()
File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/loader.py", line 522, in get_component
cache[self.domain] = importlib.import_module(self.pkg_path)
File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/homeassistant/.homeassistant/custom_components/yahoofinance/init.py", line 18, in
from custom_components.yahoofinance.coordinator import YahooSymbolUpdateCoordinator
File "/home/homeassistant/.homeassistant/custom_components/yahoofinance/coordinator.py", line 32, in
class YahooSymbolUpdateCoordinator(DataUpdateCoordinator):
File "/home/homeassistant/.homeassistant/custom_components/yahoofinance/coordinator.py", line 36, in YahooSymbolUpdateCoordinator
def parse_symbol_data(symbol_data: dict) -> dict[str, any]:
TypeError: 'type' object is not subscriptable

New request for configurable decimals

In fact, being able to enter the number of actions could be useful, but the possibility of managing the number of decimals would also simplify the output on the cards. Anyway thanks for the great job, this integration was missing in our Home Assistant.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.