From a22194e21696016e002fa72466a93debff37b503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Schmidts?= Date: Wed, 20 Nov 2019 17:45:53 +0100 Subject: [PATCH] [hsbc] correcting diff ratio for investments --- modules/hsbc/pages/investments.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/hsbc/pages/investments.py b/modules/hsbc/pages/investments.py index 9e8a0094e3..02f6898ee7 100644 --- a/modules/hsbc/pages/investments.py +++ b/modules/hsbc/pages/investments.py @@ -385,10 +385,15 @@ def obj_vdate(self): obj_valuation = CleanDecimal(Dict( 'holdingDetailInformation/0/holdingDetailMultipleCurrencyInformation/0/productHoldingMarketValueAmount' ), default=NotAvailable) - obj_diff_ratio = CleanDecimal(Dict( - 'holdingDetailInformation/0/holdingDetailMultipleCurrencyInformation/0' - '/profitLossUnrealizedPercent' - ), default=NotAvailable) + + def obj_diff_ratio(self): + ratio = CleanDecimal(Dict( + 'holdingDetailInformation/0/holdingDetailMultipleCurrencyInformation/0/profitLossUnrealizedPercent' + ), default=NotAvailable)(self) + if ratio is not NotAvailable: + ratio /= 100 + return ratio + obj_portfolio_share = NotAvailable # must be computed from the sum of iter_investments def obj_original_currency(self): @@ -443,9 +448,15 @@ def obj__invest_account_id(self): obj_unitprice = CleanDecimal(Dict( 'holdingSummaryMultipleCurrencyInformation/0/productHoldingUnitCostAverageAmount' ), default=NotAvailable) - obj_diff_ratio = CleanDecimal(Dict( - 'holdingSummaryMultipleCurrencyInformation/0/profitLossUnrealizedPercent' - ), default=NotAvailable) + + def obj_diff_ratio(self): + ratio = CleanDecimal(Dict( + 'holdingSummaryMultipleCurrencyInformation/0/profitLossUnrealizedPercent' + ), default=NotAvailable)(self) + if ratio is not NotAvailable: + ratio /= 100 + return ratio + obj_diff = CleanDecimal(Dict( 'holdingSummaryMultipleCurrencyInformation/0/profitLossUnrealizedAmount' ), default=NotAvailable) -- GitLab