本文整理汇总了Python中weboob.capabilities.bank.Investment.original_currency方法的典型用法代码示例。如果您正苦于以下问题:Python Investment.original_currency方法的具体用法?Python Investment.original_currency怎么用?Python Investment.original_currency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.capabilities.bank.Investment
的用法示例。
在下文中一共展示了Investment.original_currency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iter_investments
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import original_currency [as 别名]
def iter_investments(self, account):
# We did not get some html, but something like that (XX is a quantity, YY a price):
# "message='<total> €{<total> €{0,01 €{<liquidity> €{0,00{{05/17{{03/05/2017{11:06{-XX €{710TI81000029397EUR{XX €{XX €{|OPHTHOTECH(NASDAQ)#cotationValeur.php?val=OPHT&pl=11&nc=2&
# popup=2{6{E:ALO{PAR{{reel{695{380{ALSTOM REGROUPT#XX#YY,YY €#YY,YY €#1 YYY,YY €#-YYY,YY €#-42,42%#-0,98 %#42,42 %#|1|AXA#cotationValeur.php?val=E:CS&pl=6&nc=1&
# popup=2{6{E:CS{PAR{{reel{695{380{AXA#XX#YY,YY €#YY,YYY €#YYY,YY €#YY,YY €#3,70%#42,42 %#42,42 %#|1|blablablab #cotationValeur.php?val=P:CODE&pl=6&nc=1&
# [...]
data = self.browser.cache["investments_data"].get(account.id, self.doc)
lines = data.split("|1|")
message = lines[0]
if len(lines) > 1:
start = 1
lines[0] = lines[0].split("|")[1]
else:
start = 0
lines = data.split("popup=2")
lines.pop(0)
invests = []
for line in lines:
_id, _pl = None, None
columns = line.split('#')
if columns[1] != '':
_pl = columns[start].split('{')[1]
_id = columns[start].split('{')[2]
invest = Investment()
invest.label = columns[start].split('{')[-1]
invest.code = _id or NotAvailable
if invest.code and ':' in invest.code:
invest.code = self.browser.titrevalue.open(val=invest.code,pl=_pl).get_isin()
# The code we got is not a real ISIN code.
if invest.code and not re.match('^[A-Z]{2}[\d]{10}$|^[A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4}$', invest.code):
m = re.search('\{([A-Z]{2}[\d]{10})\{|\{([A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4})\{', line)
if m:
invest.code = m.group(1) or m.group(2)
for x, attr in enumerate(['quantity', 'unitprice', 'unitvalue', 'valuation', 'diff'], 1):
currency = FrenchTransaction.Currency().filter(columns[start + x])
amount = CleanDecimal(default=NotAvailable).filter(FrenchTransaction.clean_amount(columns[start + x]))
if currency and currency != account.currency:
invest.original_currency = currency
attr = "original_" + attr
setattr(invest, attr, amount)
# valuation is not nullable, use 0 as default value
if not invest.valuation:
invest.valuation = Decimal('0')
# On some case we have a multine investment with a total column
# for now we have only see this on 2 lines, we will need to adapt it when o
if columns[9 if start == 0 else 0] == u'|Total' and _id == 'fichevaleur':
prev_inv = invest
invest = invests.pop(-1)
if prev_inv.quantity:
invest.quantity = invest.quantity + prev_inv.quantity
if prev_inv.valuation:
invest.valuation = invest.valuation + prev_inv.valuation
if prev_inv.diff:
invest.diff = invest.diff + prev_inv.diff
invests.append(invest)
# There is no investment on life insurance in the process to be created.
if len(message.split('&')) >= 4:
# We also have to get the liquidity as an investment.
invest = Investment()
invest.label = "Liquidités"
invest.code = "XX-liquidity"
invest.valuation = CleanDecimal(None, True).filter(message.split('&')[3].replace('euro;{','').strip())
invests.append(invest)
for invest in invests:
yield invest