Skip to content

Commit fd2eed5

Browse files
committed
#137 bug fix with RUB funds access. Implemented safer dictionary handling.
Replaced conditional checks with a single safe `.get` access for retrieving RUB funds. This ensures default values are applied when keys are missing, reducing code complexity and potential errors.
1 parent 86192ff commit fd2eed5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

tksbrokerapi/TKSBrokerAPI.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,11 +2264,7 @@ def Overview(self, show: bool = False, details: str = "full", onlyFiles=False) -
22642264
continue
22652265

22662266
# --- total changes in Russian Ruble:
2267-
if "rub" in view["stat"]["funds"]:
2268-
view["stat"]["availableRUB"] = view["stat"]["funds"]["rub"]["total"] # available RUB without other currencies
2269-
2270-
else:
2271-
view["stat"]["availableRUB"] = 0.
2267+
view["stat"]["availableRUB"] = view["stat"]["funds"].get("rub", {"total": 0.0}).get("total", 0.0) # Safe access to RUB funds.
22722268

22732269
view["stat"]["totalChangesPercentRUB"] = NanoToFloat(view["raw"]["headers"]["expectedYield"]["units"], view["raw"]["headers"]["expectedYield"]["nano"]) if "expectedYield" in view["raw"]["headers"] else 0.
22742270
startCost = view["stat"]["portfolioCostRUB"] / (1 + view["stat"]["totalChangesPercentRUB"] / 100)

0 commit comments

Comments
 (0)