fixed bug when ticker is delisted
This commit is contained in:
@@ -61,6 +61,16 @@
|
||||
max-width: 900px;
|
||||
}
|
||||
}
|
||||
@media print {
|
||||
/* ne pas affichier l'url after the link */
|
||||
a[href]:after {
|
||||
content: none !important;
|
||||
}
|
||||
* {
|
||||
color: inherit !important;
|
||||
background-color: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
.container h2{
|
||||
color: crimson !important;
|
||||
|
||||
@@ -63,17 +63,19 @@ def portfolio(request):
|
||||
ticker = yf.Ticker('EUR=X')
|
||||
|
||||
# maj des parités des devises
|
||||
update_actif_devise(request, 'USD', ticker.info.get('regularMarketPrice'))
|
||||
update_actif_devise(request, 'USD', ticker.fast_info.last_price)
|
||||
|
||||
for item in actifs:
|
||||
if item.type == 'ACTION':
|
||||
# ticker delisted ?
|
||||
# import pdb;pdb.set_trace()
|
||||
if item.symbole == 'SHLDQ':
|
||||
price = 0
|
||||
dividends = 0
|
||||
else:
|
||||
# lire le cours de l'action
|
||||
ticker = yf.Ticker(item.symbole)
|
||||
# ticker delisted ?
|
||||
if ticker.info == None:
|
||||
price = 0
|
||||
else:
|
||||
price = ticker.info.get('regularMarketPrice')
|
||||
price = ticker.fast_info.last_price
|
||||
# caluler son rendement
|
||||
dividends = get_dividends(ticker)
|
||||
update_actif_valeur(request, item.symbole, price, dividends)
|
||||
@@ -169,7 +171,7 @@ def actif_edit(request):
|
||||
|
||||
# récupérer le cours du symbole de Yahoo finance
|
||||
ticker = yf.Ticker(symbole)
|
||||
new_values['cours'] = ticker.info.get('regularMarketPrice')
|
||||
new_values['cours'] = ticker.fast_info.last_price
|
||||
new_values['devise'] = ticker.info.get('currency')
|
||||
libelle = html.unescape(ticker.info.get('shortName'))
|
||||
# raccourcir le libelle
|
||||
@@ -344,7 +346,7 @@ def histo_edit(request):
|
||||
if new_values:
|
||||
# lire le cours de l'indice de réfence : Carmignac Investissement A EUR Acc
|
||||
ticker = yf.Ticker('0P00000FB2.F')
|
||||
new_values['cours_ref'] = ticker.info.get('regularMarketPrice')
|
||||
new_values['cours_ref'] = ticker.fast_info.last_price
|
||||
|
||||
update_histo(request, no_id, new_values)
|
||||
request.session.flash(u"La fiche a été mise à jour avec succès.", 'success')
|
||||
|
||||
Reference in New Issue
Block a user