本文整理汇总了Python中weboob.capabilities.bank.Investment.label方法的典型用法代码示例。如果您正苦于以下问题:Python Investment.label方法的具体用法?Python Investment.label怎么用?Python Investment.label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.capabilities.bank.Investment
的用法示例。
在下文中一共展示了Investment.label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iter_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investment(self):
item = self.doc.xpath(u'//table[@summary="Liste des échéances"]/tfoot/tr/td[@class="tot _c1 d _c1"]')[0]
total = CleanDecimal(Regexp(CleanText('.'), '(.*) .*'),
default=1, replace_dots=True)(item)
item_xpath = u'((//table[@summary="Liste des échéances"])[1]/tbody/tr)[position() < last() and not(contains(./td[1]/@class, "tittot"))]'
obj = None
for tr in self.doc.xpath(item_xpath):
tds = tr.xpath('./td')
if len(tds) > 3:
if obj is not None:
obj.portfolio_share = (obj.valuation / total).quantize(Decimal('.0001'))
yield obj
obj = Investment()
obj.label = CleanText('.')(tds[0])
obj.vdate = date.today() # * En réalité derniere date de valorisation connue
obj.unitvalue = CleanDecimal('.', replace_dots=True)(tds[2])
obj.valuation = CleanDecimal('.', replace_dots=True)(tds[5])
obj.quantity = CleanDecimal('.', replace_dots=True)(tds[4])
elif obj is not None:
obj.quantity += CleanDecimal('.', replace_dots=True)(tds[1])
obj.valuation += CleanDecimal('.', replace_dots=True)(tds[2])
if obj is not None:
obj.portfolio_share = (obj.valuation / total).quantize(Decimal('.0001'))
yield obj
示例2: iter_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investment(self):
for line in self.document.xpath('//table[contains(@class, "ca-data-table")]/descendant::tr[count(td)>=7]'):
for sub in line.xpath('./td[@class="info-produit"]'):
sub.drop_tree()
cells = line.findall('td')
if cells[self.COL_ID].find('div/a') is None:
continue
inv = Investment()
inv.label = unicode(cells[self.COL_ID].find('div/a').text.strip())
inv.code = cells[self.COL_ID].find('div/br').tail.strip().split(u'\xa0')[0]
inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY].find('span').text)
inv.valuation = self.parse_decimal(cells[self.COL_VALUATION].text)
inv.diff = self.parse_decimal(cells[self.COL_DIFF].text_content())
if "%" in cells[self.COL_UNITPRICE].text and "%" in cells[self.COL_UNITVALUE].text:
inv.unitvalue = inv.valuation / inv.quantity
inv.unitprice = (inv.valuation - inv.diff) / inv.quantity
else:
inv.unitprice = self.parse_decimal(cells[self.COL_UNITPRICE].text)
inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE].text)
date = cells[self.COL_UNITVALUE].find('span').text
if ':' in date:
inv.vdate = ddate.today()
else:
day, month = map(int, date.split('/', 1))
date_guesser = LinearDateGuesser()
inv.vdate = date_guesser.guess_date(day, month)
yield inv
示例3: get_accounts_list
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def get_accounts_list(self):
data = {'clang': self.LANG,
'ctcc': self.CTCC,
'login': self.username,
'session': self.sessionId}
for dispositif in self.accountsp.open(data=data).get_list():
if dispositif['montantBrutDispositif'] == 0:
continue
a = Account()
a.id = dispositif['codeDispositif']
a.type = Account.TYPE_MARKET
a.balance = Decimal(dispositif["montantBrutDispositif"]).quantize(Decimal('.01'))
a.label = dispositif['titreDispositif']
a.currency = u"EUR" # Don't find any possbility to get that from configuration.
a._investments = []
for fund in dispositif['listeFonds']:
if fund['montantValeurEuro'] == 0:
continue
i = Investment()
i.id = i.code = dispositif['codeEntreprise'] + dispositif["codeDispositif"] + fund["codeSupport"]
i.label = fund['libelleSupport']
i.unitvalue = Decimal(fund["montantValeur"]).quantize(Decimal('.01'))
i.valuation = Decimal(fund["montantValeurEuro"]).quantize(Decimal('.01'))
i.quantity = i.valuation / i.unitvalue
i.vdate = parse_date(fund['dateValeur'], dayfirst=True)
a._investments.append(i)
yield a
示例4: iter_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investment(self, account):
if account.type == Account.TYPE_LIFE_INSURANCE:
if not self.goto_spirica(account):
return iter([])
return self.spirica.iter_investment(account)
elif account.type in (Account.TYPE_MARKET, Account.TYPE_PEA):
bourse_account = self.get_bourse_account(account)
if not bourse_account:
return iter([])
self.location(bourse_account._market_link)
assert self.bourse.is_here()
invs = list(self.page.iter_investment())
# _especes is set during BoursePage accounts parsing. BoursePage
# inherits from lcl module BoursePage
if bourse_account._especes:
i = Investment()
i.valuation = bourse_account._especes
i.code = u"XX-liquidity"
i.label = u"Liquidités"
invs.append(i)
self.leave_espace_bourse()
return invs
raise NotImplementedError()
示例5: get_market_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def get_market_investment(self):
COL_LABEL = 0
COL_QUANTITY = 1
COL_UNITPRICE = 2
COL_UNITVALUE = 3
COL_VALUATION = 4
COL_PERF = 5
for table in self.document.xpath('//table[@class="datas-large"]'):
for tr in table.xpath('.//tr[not(@class="entete")]'):
cols = tr.findall('td')
if len(cols) < 7:
continue
delta = 0
if len(cols) == 9:
delta = 1
inv = Investment()
inv.code = self.parser.tocleanstring(cols[COL_LABEL + delta].xpath('.//span')[1])
inv.label = self.parser.tocleanstring(cols[COL_LABEL + delta].xpath('.//span')[0])
inv.quantity = self.parse_decimal(cols[COL_QUANTITY + delta])
inv.unitprice = self.parse_decimal(cols[COL_UNITPRICE + delta])
inv.unitvalue = self.parse_decimal(cols[COL_UNITVALUE + delta])
inv.valuation = self.parse_decimal(cols[COL_VALUATION + delta])
inv.diff = self.parse_decimal(cols[COL_PERF + delta])
yield inv
示例6: get_market_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def get_market_investment(self):
if CleanText('//div[contains(text(), "restreint aux fonctions de bourse")]')(self.doc):
return
COL_LABEL = 0
COL_QUANTITY = 1
COL_UNITPRICE = 2
COL_UNITVALUE = 3
COL_VALUATION = 4
COL_PERF = 5
for table in self.doc.xpath('//table[@class="datas-large"]'):
for tr in table.xpath('.//tr[not(@class="entete")]'):
cols = tr.findall('td')
if len(cols) < 7:
continue
delta = 0
if len(cols) == 9:
delta = 1
inv = Investment()
inv.code = CleanText('.')(cols[COL_LABEL + delta].xpath('.//span')[1]).split(' ')[0].split(u'\xa0')[0]
inv.label = CleanText('.')(cols[COL_LABEL + delta].xpath('.//span')[0])
inv.quantity = MyDecimal('.')(cols[COL_QUANTITY + delta])
inv.unitprice = MyDecimal('.')(cols[COL_UNITPRICE + delta])
inv.unitvalue = MyDecimal('.')(cols[COL_UNITVALUE + delta])
inv.valuation = MyDecimal('.')(cols[COL_VALUATION + delta])
inv.diff = MyDecimal('.')(cols[COL_PERF + delta])
yield inv
示例7: get_investments
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def get_investments(self, account):
if account is not None:
# the balance is highly dynamic, fetch it along with the investments to grab a snapshot
account.balance = CleanDecimal(None, replace_dots=True).filter(self.get_balance(account.type))
for line in self.doc.xpath('//table[@id="t_intraday"]/tbody/tr'):
if line.find_class('categorie') or line.find_class('detail') or line.find_class('detail02'):
continue
cols = line.findall('td')
inv = Investment()
inv.label = CleanText(None).filter(cols[self.COL_LABEL])
link = cols[self.COL_LABEL].xpath('./a[contains(@href, "cdReferentiel")]')[0]
inv.id = re.search('cdReferentiel=(.*)', link.attrib['href']).group(1)
inv.code = re.match('^[A-Z]+[0-9]+(.*)$', inv.id).group(1)
inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY], True)
inv.unitprice = self.parse_decimal(cols[self.COL_UNITPRICE], True)
inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE], False)
inv.valuation = self.parse_decimal(cols[self.COL_VALUATION], True)
diff = cols[self.COL_PERF].text.strip()
if diff == "-":
inv.diff = NotAvailable
else:
inv.diff = CleanDecimal(None, replace_dots=True).filter(diff)
if is_isin_valid(inv.code):
inv.code_type = Investment.CODE_TYPE_ISIN
yield inv
if account.type != account.TYPE_MARKET:
valuation = CleanDecimal(None, True).filter(self.doc.xpath('//*[@id="valorisation_compte"]/table/tr[3]/td[2]'))
yield create_french_liquidity(valuation)
示例8: get_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def get_investment(self, account):
if account.type == Account.TYPE_LIFE_INSURANCE and account._form:
self.assurancevie.stay_or_go()
account._form.submit()
if self.calie.is_here():
# come back to syntese
self.assurancevie.go()
return
if self.page.is_restricted():
self.logger.warning('restricted access to account %s', account)
else:
for inv in self.page.iter_investment():
yield inv
if self.avdetail.is_here():
self.page.come_back()
elif hasattr(account, '_market_link') and account._market_link:
self.connexion_bourse()
for inv in self.location(account._market_link).page.iter_investment():
yield inv
self.deconnexion_bourse()
elif account.id in self.get_bourse_accounts_ids():
inv = Investment()
inv.id = account.id
inv.code = 'XX-Liquidity'
inv.label = "Liquidités"
inv.valuation = account.balance
yield inv
示例9: get_transactions_from_detail
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def get_transactions_from_detail(self, account):
for label, page in account._history_pages:
amounts = page.doc.xpath('//span[contains(text(), "Montant")]/following-sibling::span')
if len(amounts) == 3:
amounts.pop(0)
for table in page.doc.xpath('//table'):
t = Transaction()
t.date = Date(CleanText(page.doc.xpath('//span[contains(text(), "Date d\'effet")]/following-sibling::span')), dayfirst=True)(page)
t.label = label
t.amount = CleanDecimal(replace_dots=True).filter(amounts[0])
amounts.pop(0)
t._is_coming = False
t.investments = []
sum_amount = 0
for tr in table.xpath('./tbody/tr'):
i = Investment()
i.label = CleanText().filter(tr.xpath('./td[1]'))
i.vdate = Date(CleanText(tr.xpath('./td[2]')), dayfirst=True)(tr)
i.unitvalue = CleanDecimal(replace_dots=True).filter(tr.xpath('./td[3]'))
i.quantity = CleanDecimal(replace_dots=True).filter(tr.xpath('./td[4]'))
i.valuation = CleanDecimal(replace_dots=True).filter(tr.xpath('./td[5]'))
sum_amount += i.valuation
t.investments.append(i)
if t.label == 'prélèvement':
t.amount = sum_amount
yield t
示例10: iter_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investment(self):
doc = self.browser.get_document(self.browser.openurl('/brs/fisc/fisca10a.html'), encoding='utf-8')
num_page = None
try:
num_page = int(self.parser.tocleanstring(doc.xpath(u'.//tr[contains(td[1], "Relevé des plus ou moins values latentes")]/td[2]')[0]).split('/')[1])
except IndexError:
pass
docs = [doc]
if num_page:
for n in range(2, num_page + 1):
docs.append(self.browser.get_document(self.browser.openurl('%s%s' % ('/brs/fisc/fisca10a.html?action=12&numPage=', str(n))), encoding='utf-8'))
for doc in docs:
for tr in doc.xpath('//tr[count(td)=6 and td[1]/strong]'):
cells = tr.findall('td')
inv = Investment()
inv.label = unicode(cells[self.COL_LABEL].xpath('.//span')[0].attrib['title'].split(' - ')[0])
inv.code = unicode(cells[self.COL_LABEL].xpath('.//span')[0].attrib['title'].split(' - ')[1])
inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY])
inv.unitprice = self.parse_decimal(tr.xpath('./following-sibling::tr/td[3]')[0])
inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE])
inv.valuation = self.parse_decimal(cells[self.COL_VALUATION])
inv.diff = self.parse_decimal(cells[self.COL_DIFF])
yield inv
示例11: iter_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investment(self):
for line in self.document.xpath('//table[@summary and count(descendant::td) > 1]/tbody/tr'):
cells = line.findall('td')
if len(cells) < 5:
continue
inv = Investment()
inv.label = unicode(cells[self.COL_ID].text_content().strip())
a = cells[self.COL_ID].find('a')
if a is not None:
try:
inv.code = a.attrib['id']
except KeyError:
#For "Mandat d'arbitrage" which is a recapitulatif of more investement
continue
else:
inv.code = NotAvailable
inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY].text_content())
inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE].text_content())
inv.valuation = self.parse_decimal(cells[self.COL_VALUATION].text_content())
inv.unitprice = NotAvailable
inv.diff = NotAvailable
yield inv
示例12: parse
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def parse(self, el):
i = Investment()
i.label = Field('label')(self)
i.code = CleanText(TableCell('code'))(self)
i.quantity = MyDecimal(TableCell('quantity'))(self)
i.valuation = Field('amount')(self)
i.vdate = Field('date')(self)
self.env['investments'] = [i]
示例13: iter_investment
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investment(self):
not_rounded_valuations = self.get_not_rounded_valuations()
doc = self.browser.open('/brs/fisc/fisca10a.html').page.doc
num_page = None
try:
num_page = int(CleanText('.')(doc.xpath(u'.//tr[contains(td[1], "Relevé des plus ou moins values latentes")]/td[2]')[0]).split('/')[1])
except IndexError:
pass
docs = [doc]
if num_page:
for n in range(2, num_page + 1):
docs.append(self.browser.open('%s%s' % ('/brs/fisc/fisca10a.html?action=12&numPage=', str(n))).page.doc)
for doc in docs:
# There are two different tables possible depending on the market account type.
is_detailed = bool(doc.xpath(u'//span[contains(text(), "Années d\'acquisition")]'))
tr_xpath = '//tr[@height and td[@colspan="6"]]' if is_detailed else '//tr[count(td)>5]'
for tr in doc.xpath(tr_xpath):
cells = tr.findall('td')
inv = Investment()
title_split = cells[self.COL_LABEL].xpath('.//span')[0].attrib['title'].split(' - ')
inv.label = unicode(title_split[0])
for code in title_split[1:]:
if is_isin_valid(code):
inv.code = unicode(code)
inv.code_type = Investment.CODE_TYPE_ISIN
break
else:
inv.code = NotAvailable
inv.code_type = NotAvailable
if is_detailed:
inv.quantity = MyDecimal('.')(tr.xpath('./following-sibling::tr/td[2]')[0])
inv.unitprice = MyDecimal('.', replace_dots=True)(tr.xpath('./following-sibling::tr/td[3]')[1])
inv.unitvalue = MyDecimal('.', replace_dots=True)(tr.xpath('./following-sibling::tr/td[3]')[0])
try: # try to get not rounded value
inv.valuation = not_rounded_valuations[inv.label]
except KeyError: # ok.. take it from the page
inv.valuation = MyDecimal('.')(tr.xpath('./following-sibling::tr/td[4]')[0])
inv.diff = MyDecimal('.')(tr.xpath('./following-sibling::tr/td[5]')[0]) or \
MyDecimal('.')(tr.xpath('./following-sibling::tr/td[6]')[0])
else:
inv.quantity = MyDecimal('.')(cells[self.COL_QUANTITY])
inv.diff = MyDecimal('.')(cells[self.COL_DIFF])
inv.unitprice = MyDecimal('.')(cells[self.COL_UNITPRICE].xpath('.//tr[1]/td[2]')[0])
inv.unitvalue = MyDecimal('.')(cells[self.COL_VALUATION].xpath('.//tr[1]/td[2]')[0])
inv.valuation = MyDecimal('.')(cells[self.COL_VALUATION].xpath('.//tr[2]/td[2]')[0])
yield inv
示例14: obj_investments
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def obj_investments(self):
inv = Investment()
inv.quantity = CleanDecimal(TableCell('quantity'), replace_dots=True)(self)
inv.code_type = Investment.CODE_TYPE_ISIN
txt = CleanText(TableCell('name'))(self)
match = re.match('(?:(.*) )?- ([^-]+)$', txt)
inv.label = match.group(1) or NotAvailable
inv.code = match.group(2)
if inv.code in self.parent.labels:
inv.label = inv.label or self.parent.labels[inv.code]
elif inv.label:
self.parent.labels[inv.code] = inv.label
else:
inv.label = inv.code
return [inv]
示例15: iter_investments
# 需要导入模块: from weboob.capabilities.bank import Investment [as 别名]
# 或者: from weboob.capabilities.bank.Investment import label [as 别名]
def iter_investments(self):
# We did not get some html, but something like that (XX is a quantity, YY a price):
# message='[...]
# 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&
# [...]
lines = self.doc.split("popup=2")
lines.pop(0)
invests = []
for line in lines:
columns = line.split('#')
_pl = columns[0].split('{')[1]
_id = columns[0].split('{')[2]
invest = Investment(_id)
invest.label = unicode(columns[0].split('{')[-1])
invest.code = unicode(_id)
if ':' 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 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 = unicode(m.group(1) or m.group(2))
quantity = FrenchTransaction.clean_amount(columns[1])
invest.quantity = CleanDecimal(default=NotAvailable).filter(quantity)
unitprice = FrenchTransaction.clean_amount(columns[2])
invest.unitprice = CleanDecimal(default=NotAvailable).filter(unitprice)
unitvalue = FrenchTransaction.clean_amount(columns[3])
invest.unitvalue = CleanDecimal(default=NotAvailable).filter(unitvalue)
valuation = FrenchTransaction.clean_amount(columns[4])
# valuation is not nullable, use 0 as default value
invest.valuation = CleanDecimal(default=Decimal('0')).filter(valuation)
diff = FrenchTransaction.clean_amount(columns[5])
invest.diff = CleanDecimal(default=NotAvailable).filter(diff)
# 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] == 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)
for invest in invests:
yield invest