Skip to content

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

License

Notifications You must be signed in to change notification settings

SjaakJ/yahoofinance

 
 

Repository files navigation

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:

attribution: Data provided by Yahoo Finance
currencySymbol: $
symbol: ISTNX
quoteType: MUTUALFUND
quoteSourceName: Delayed Quote
marketState: CLOSED
averageDailyVolume10Day: 0
averageDailyVolume3Month: 0
regularMarketChange: 0.26
regularMarketChangePercent: 0.23
regularMarketDayHigh: 0
regularMarketDayLow: 0
regularMarketPreviousClose: 12.63
regularMarketPrice: 12.89
regularMarketVolume: 0
regularMarketTime: 1618617625
dividendDate: 2021-11-11
fiftyDayAverage: 107.54
fiftyDayAverageChange: 5.35
fiftyDayAverageChangePercent: 0.05
preMarketChange: 0
preMarketChangePercent: 0
preMarketTime: 0
preMarketPrice: 0
postMarketChange: 0
postMarketChangePercent: 0
postMarketPrice: 0
postMarketTime: 0
twoHundredDayAverage: 14.69
twoHundredDayAverageChange: 8.2
twoHundredDayAverageChangePercent: 0.08
trending: up
unit_of_measurement: USD
friendly_name: Ivy Science & Technology Fund C
icon: mdi:trending-up

The dividendDate is in ISO format (YYYY-MM-DD) and can be null.

Optional Configuration

  • 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 None 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
  • 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<