From 679fdc47c0b952d322e97a05000475625a97566a Mon Sep 17 00:00:00 2001 From: Indu Prakash <6459774+iprak@users.noreply.github.com> Date: Mon, 13 May 2024 16:23:03 -0500 Subject: [PATCH] Added ratios (#133) * Added forwardPE,trailingPE * Updated Readme and configuration --- .devcontainer/configuration.yaml | 1 + README.md | 49 ++++++++++++++----------- custom_components/yahoofinance/const.py | 10 +++-- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 67c82bd..875b0fd 100755 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -22,6 +22,7 @@ yahoofinance: scan_interval: 30 symbols: + - symbol: "ISTNX" - symbol: GBPUSD=X no_unit: true - symbol: IDFCBANK.BO diff --git a/README.md b/README.md index 1577706..f958f89 100755 --- a/README.md +++ b/README.md @@ -22,26 +22,29 @@ yahoofinance: 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: CLOSED +marketState: PRE averageDailyVolume10Day: 0 averageDailyVolume3Month: 0 -regularMarketChange: 0.26 -regularMarketChangePercent: 0.23 +regularMarketChange: 0.35 +regularMarketChangePercent: 0.5 regularMarketDayHigh: 0 regularMarketDayLow: 0 -regularMarketPreviousClose: 12.63 -regularMarketPrice: 12.89 +regularMarketPreviousClose: 69.93 +regularMarketPrice: 70.28 regularMarketVolume: 0 -regularMarketTime: 1618617625 -dividendDate: 2021-11-11 -fiftyDayAverage: 107.54 -fiftyDayAverageChange: 5.35 -fiftyDayAverageChangePercent: 0.05 +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 @@ -50,22 +53,26 @@ postMarketChange: 0 postMarketChangePercent: 0 postMarketPrice: 0 postMarketTime: 0 -twoHundredDayAverage: 14.69 -twoHundredDayAverageChange: 8.2 -twoHundredDayAverageChangePercent: 0.08 -fiftyTwoWeekLow: 125 -fiftyTwoWeekLowChange: 20.37 -fiftyTwoWeekLowChangePercent: 16.29 -fiftyTwoWeekHigh: 153.1 -fiftyTwoWeekHighChange: -7.74 -fiftyTwoWeekHighChangePercent: -5.05 +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 -friendly_name: Ivy Science & Technology Fund C icon: mdi:trending-up +friendly_name: Ivy Science & Technology Fund C ``` -The `dividendDate` is in ISO format (YYYY-MM-DD) and can be `null`. +### Attributes +* The attributes can be null if there is no data present. +* The `dividendDate` is in ISO format (YYYY-MM-DD). + + ## Optional Configuration diff --git a/custom_components/yahoofinance/const.py b/custom_components/yahoofinance/const.py index 72b174e..ed102ca 100755 --- a/custom_components/yahoofinance/const.py +++ b/custom_components/yahoofinance/const.py @@ -16,6 +16,8 @@ ATTR_REGULAR_MARKET_TIME: Final = "regularMarketTime" ATTR_PRE_MARKET_TIME: Final = "preMarketTime" ATTR_POST_MARKET_TIME: Final = "postMarketTime" +ATTR_FORWARD_PE: Final = "forwardPE" +ATTR_TRAILING_PE: Final = "trailingPE" # Hass data HASS_DATA_CONFIG: Final = "config" @@ -30,10 +32,10 @@ DATA_MARKET_STATE: Final = "marketState" DATA_DIVIDEND_DATE: Final = "dividendDate" DATA_REGULAR_MARKET_TIME: Final = "regularMarketTime" -DATA_PRE_MARKET_TIME: Final = 'preMarketTime' +DATA_PRE_MARKET_TIME: Final = "preMarketTime" DATA_POST_MARKET_TIME: Final = "postMarketTime" - - +DATA_FORWARD_PE: Final = "forwardPE" +DATA_TRAILING_PE: Final = "trailingPE" DATA_REGULAR_MARKET_PREVIOUS_CLOSE: Final = "regularMarketPreviousClose" DATA_REGULAR_MARKET_PRICE: Final = "regularMarketPrice" @@ -76,6 +78,8 @@ ("regularMarketVolume", False), (DATA_REGULAR_MARKET_TIME, False), (DATA_DIVIDEND_DATE, False), + (DATA_FORWARD_PE, False), + (DATA_TRAILING_PE, False), ], CONF_INCLUDE_FIFTY_DAY_VALUES: [ ("fiftyDayAverage", True),