finalized update portfolio
This commit is contained in:
BIN
cao_blogr.sqlite
BIN
cao_blogr.sqlite
Binary file not shown.
Binary file not shown.
@@ -31,7 +31,7 @@ class UserCreateForm(Form):
|
||||
|
||||
class HistoForm(Form):
|
||||
no_id = IntegerField(widget=HiddenInput())
|
||||
mvt_cash = DecimalField(places=2, validators=[InputRequired()])
|
||||
mvt_cash = DecimalField('Montant à ajouter au portefeuille', places=2, validators=[InputRequired()])
|
||||
|
||||
class AllocationForm(Form):
|
||||
no_cat = IntegerField(widget=HiddenInput())
|
||||
|
||||
@@ -61,8 +61,13 @@ class PFService(object):
|
||||
request.dbsession.query(Actifs).filter(Actifs.devise == devise).update({'parite': taux})
|
||||
return
|
||||
|
||||
def update_actif_valeur(request, symbole, cours, dividends):
|
||||
request.dbsession.query(Actifs).filter(Actifs.symbole == symbole).update({'cours': cours, 'rendement': dividends})
|
||||
def update_actif_valeur(request, symbole, cours, valeur, plus_value, pc_plusvalue):
|
||||
request.dbsession.query(Actifs).filter(Actifs.symbole == symbole
|
||||
).update({'cours': cours,
|
||||
'valeur': valeur,
|
||||
'plus_value':plus_value,
|
||||
'pc_plusvalue': pc_plusvalue,
|
||||
})
|
||||
return
|
||||
|
||||
def update_portefeuille(request):
|
||||
@@ -89,17 +94,7 @@ class PFService(object):
|
||||
request.dbsession.query(Actifs).filter(Actifs.no_id == no_id).delete(synchronize_session=False)
|
||||
return
|
||||
|
||||
def get_dividends(ticker):
|
||||
d = 0
|
||||
# le ticker a des dividendes ?
|
||||
if len(ticker.dividends) > 0:
|
||||
# oui, cumuler les dividendes sur un an
|
||||
h = ticker.history(period="1y")
|
||||
nb = len(ticker.dividends)
|
||||
for i in range(nb):
|
||||
d += ticker.dividends[nb - 1 - i]
|
||||
|
||||
return d
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@ h3, h4 {
|
||||
font-size: 20px;
|
||||
color: #111;
|
||||
}
|
||||
.container {
|
||||
padding: 80px 120px;
|
||||
}
|
||||
.person {
|
||||
border: 10px solid transparent;
|
||||
margin-bottom: 25px;
|
||||
@@ -38,6 +35,22 @@ h3, h4 {
|
||||
display: none; /* Hide the carousel text when the screen is less than 600 pixels wide */
|
||||
}
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
.container{
|
||||
padding: 70px 0 0 0;
|
||||
max-width: 950px;
|
||||
}
|
||||
}
|
||||
@media print {
|
||||
/* ne pas affichier l'url after the link */
|
||||
a[href]:after {
|
||||
content: none !important;
|
||||
}
|
||||
* {
|
||||
color: inherit !important;
|
||||
background-color: inherit !important;
|
||||
}
|
||||
}
|
||||
.bg-1 {
|
||||
background: #bc2131;
|
||||
color: #bdbdbd;
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
{% block content %}
|
||||
|
||||
{% if request.authenticated_userid %}
|
||||
<p><a href="{{ request.route_url('blog_edit', id='0') }}" class="btn btn-success" role="button">
|
||||
<span class="glyphicon glyphicon-plus"></span> Nouveau</a>
|
||||
<p><a href="{{ request.route_url('blog_edit', id='0') }}">[ Nouveau ]</a>
|
||||
</p>
|
||||
{% endif%}
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
{% endfor %}
|
||||
<div class="form-group">
|
||||
<label class="required-field" for="tag">{{form.mvt_cash.label}}</label>
|
||||
{{form.mvt_cash(class_='form-control')}}
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">€</div>
|
||||
{{form.mvt_cash(class_='form-control')}}
|
||||
</div>
|
||||
<p class="form-control-static">(si le montant est négatif, le montant est retiré du portefeuille)</b></p>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
{% block content %}
|
||||
|
||||
<p>
|
||||
<a href="allocation_edit/0" class="btn btn-success" role="button">
|
||||
<span class="glyphicon glyphicon-plus"></span> Nouvelle classe</a>
|
||||
<a href="allocation_edit/0">[ Nouvelle classe ]</a>
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@@ -92,12 +91,9 @@
|
||||
<div class="form-group">
|
||||
<button id="updateButton" class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<i class="glyphicon glyphicon-refresh"></i> MAJ du portefeuille</button>
|
||||
<a href="#" class="btn btn-success" role="button"
|
||||
data-toggle="modal" data-target="#choixTypeActif"><span class="glyphicon glyphicon-plus"></span> Nouvel actif</a>
|
||||
<a href="/histo_list" class="btn btn-default" role="button">
|
||||
<span class="glyphicon glyphicon-stats"></span> Historique</a>
|
||||
<a href="/blog/2/mouvements-du-portefeuille" class="btn btn-default" role="button">
|
||||
<span class="glyphicon glyphicon-folder-close"></span> Mouvements</a>
|
||||
<a href="#" data-toggle="modal" data-target="#choixTypeActif">[ Nouvel actif ]</a>
|
||||
<a href="/histo_list">[ Historique ]</a>
|
||||
<a href="/blog/2/mouvements-du-portefeuille">[ Mouvements ]</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -53,18 +53,19 @@ def portfolio(request):
|
||||
|
||||
for item in actifs:
|
||||
if item.Allocation.type == 'ACTION':
|
||||
symbole = item.Actifs.symbole
|
||||
# lire le cours de l'action
|
||||
ticker = yf.Ticker(item.Actifs.symbole)
|
||||
ticker = yf.Ticker(symbole)
|
||||
# ticker delisted ?
|
||||
if item.Actifs.symbole == 'SHLDQ':
|
||||
price = 0
|
||||
dividends = 0
|
||||
if symbole == 'SHLDQ':
|
||||
cours = 0
|
||||
else:
|
||||
price = ticker.fast_info.get('lastPrice')
|
||||
# caluler son rendement
|
||||
dividends = PFService.get_dividends(ticker)
|
||||
cours = ticker.fast_info.get('lastPrice')
|
||||
|
||||
PFService.update_actif_valeur(request, item.Actifs.symbole, price, dividends)
|
||||
valeur = cours * item.Actifs.parite * item.Actifs.nombre
|
||||
plus_value = valeur - (item.Actifs.pru * item.Actifs.nombre)
|
||||
pc_plusvalue = valeur * 100 / (item.Actifs.pru * item.Actifs.nombre) - 100
|
||||
PFService.update_actif_valeur(request, symbole, cours, valeur, plus_value, pc_plusvalue)
|
||||
# time.sleep(1) # attendre 2 secondes
|
||||
|
||||
# update du portefeuille
|
||||
@@ -178,6 +179,7 @@ def histo_edit(request):
|
||||
if no_id == '0':
|
||||
# create a new tag
|
||||
entry = Histo()
|
||||
entry.mvt_cash = 0
|
||||
entry.date = datetime.datetime.now()
|
||||
form = HistoForm(request.POST, entry)
|
||||
page_title = "Nouveau Histo"
|
||||
|
||||
Reference in New Issue
Block a user