diff --git a/custom_components/avanza_stock/sensor.py b/custom_components/avanza_stock/sensor.py index 99fa45a..4da1873 100644 --- a/custom_components/avanza_stock/sensor.py +++ b/custom_components/avanza_stock/sensor.py @@ -294,7 +294,7 @@ def _update_state_attributes(self, data): self._state_attributes[change] = round( data["quote"]["last"] - data["historicalClosingPrices"][price], - 2, + 5, ) else: self._state_attributes[change] = "unknown" @@ -308,7 +308,7 @@ def _update_state_attributes(self, data): data["quote"]["last"] - data["historicalClosingPrices"][price] ), - 2, + 5, ) else: self._state_attributes[change] = "unknown" @@ -323,7 +323,7 @@ def _update_state_attributes(self, data): - data["historicalClosingPrices"][price] ) / data["historicalClosingPrices"][price], - 2, + 3, ) else: self._state_attributes[change] = "unknown" @@ -331,10 +331,10 @@ def _update_state_attributes(self, data): if self._shares is not None: self._state_attributes["shares"] = self._shares self._state_attributes["totalValue"] = round( - self._shares * data["quote"]["last"], 2 + self._shares * data["quote"]["last"], 5 ) self._state_attributes["totalChange"] = round( - self._shares * data["quote"]["change"], 2 + self._shares * data["quote"]["change"], 5 ) self._update_profit_loss(data["quote"]["last"]) @@ -370,22 +370,22 @@ def _update_profit_loss(self, price): if self._purchase_price is not None: self._state_attributes["purchasePrice"] = self._purchase_price self._state_attributes["profitLoss"] = round( - price - self._purchase_price, 2 + price - self._purchase_price, 5 ) self._state_attributes["profitLossPercentage"] = round( - 100 * (price - self._purchase_price) / self._purchase_price, 2 + 100 * (price - self._purchase_price) / self._purchase_price, 3 ) if self._shares is not None: self._state_attributes["totalProfitLoss"] = round( - self._shares * (price - self._purchase_price), 2 + self._shares * (price - self._purchase_price), 5 ) def _update_conversion_rate(self, data): rate = data["quote"]["last"] if self._invert_conversion_currency: rate = 1.0 / rate - self._state = round(self._state * rate, 2) + self._state = round(self._state * rate, 5) if self._invert_conversion_currency: self._unit_of_measurement = data["name"].split("/")[0] else: @@ -397,7 +397,7 @@ def _update_conversion_rate(self, data): and self._state_attributes[attribute] != "unknown" ): self._state_attributes[attribute] = round( - self._state_attributes[attribute] * rate, 2 + self._state_attributes[attribute] * rate, 5 ) self._update_profit_loss(self._state)