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):
|
class HistoForm(Form):
|
||||||
no_id = IntegerField(widget=HiddenInput())
|
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):
|
class AllocationForm(Form):
|
||||||
no_cat = IntegerField(widget=HiddenInput())
|
no_cat = IntegerField(widget=HiddenInput())
|
||||||
|
|||||||
@@ -61,8 +61,13 @@ class PFService(object):
|
|||||||
request.dbsession.query(Actifs).filter(Actifs.devise == devise).update({'parite': taux})
|
request.dbsession.query(Actifs).filter(Actifs.devise == devise).update({'parite': taux})
|
||||||
return
|
return
|
||||||
|
|
||||||
def update_actif_valeur(request, symbole, cours, dividends):
|
def update_actif_valeur(request, symbole, cours, valeur, plus_value, pc_plusvalue):
|
||||||
request.dbsession.query(Actifs).filter(Actifs.symbole == symbole).update({'cours': cours, 'rendement': dividends})
|
request.dbsession.query(Actifs).filter(Actifs.symbole == symbole
|
||||||
|
).update({'cours': cours,
|
||||||
|
'valeur': valeur,
|
||||||
|
'plus_value':plus_value,
|
||||||
|
'pc_plusvalue': pc_plusvalue,
|
||||||
|
})
|
||||||
return
|
return
|
||||||
|
|
||||||
def update_portefeuille(request):
|
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)
|
request.dbsession.query(Actifs).filter(Actifs.no_id == no_id).delete(synchronize_session=False)
|
||||||
return
|
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;
|
font-size: 20px;
|
||||||
color: #111;
|
color: #111;
|
||||||
}
|
}
|
||||||
.container {
|
|
||||||
padding: 80px 120px;
|
|
||||||
}
|
|
||||||
.person {
|
.person {
|
||||||
border: 10px solid transparent;
|
border: 10px solid transparent;
|
||||||
margin-bottom: 25px;
|
margin-bottom: 25px;
|
||||||
@@ -38,6 +35,22 @@ h3, h4 {
|
|||||||
display: none; /* Hide the carousel text when the screen is less than 600 pixels wide */
|
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 {
|
.bg-1 {
|
||||||
background: #bc2131;
|
background: #bc2131;
|
||||||
color: #bdbdbd;
|
color: #bdbdbd;
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if request.authenticated_userid %}
|
{% if request.authenticated_userid %}
|
||||||
<p><a href="{{ request.route_url('blog_edit', id='0') }}" class="btn btn-success" role="button">
|
<p><a href="{{ request.route_url('blog_edit', id='0') }}">[ Nouveau ]</a>
|
||||||
<span class="glyphicon glyphicon-plus"></span> Nouveau</a>
|
|
||||||
</p>
|
</p>
|
||||||
{% endif%}
|
{% endif%}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,12 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="required-field" for="tag">{{form.mvt_cash.label}}</label>
|
<label class="required-field" for="tag">{{form.mvt_cash.label}}</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">€</div>
|
||||||
{{form.mvt_cash(class_='form-control')}}
|
{{form.mvt_cash(class_='form-control')}}
|
||||||
</div>
|
</div>
|
||||||
|
<p class="form-control-static">(si le montant est négatif, le montant est retiré du portefeuille)</b></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="allocation_edit/0" class="btn btn-success" role="button">
|
<a href="allocation_edit/0">[ Nouvelle classe ]</a>
|
||||||
<span class="glyphicon glyphicon-plus"></span> Nouvelle classe</a>
|
|
||||||
</p>
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
@@ -92,12 +91,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button id="updateButton" class="btn btn-primary" type="submit" name="form.submitted">
|
<button id="updateButton" class="btn btn-primary" type="submit" name="form.submitted">
|
||||||
<i class="glyphicon glyphicon-refresh"></i> MAJ du portefeuille</button>
|
<i class="glyphicon glyphicon-refresh"></i> MAJ du portefeuille</button>
|
||||||
<a href="#" class="btn btn-success" role="button"
|
<a href="#" data-toggle="modal" data-target="#choixTypeActif">[ Nouvel actif ]</a>
|
||||||
data-toggle="modal" data-target="#choixTypeActif"><span class="glyphicon glyphicon-plus"></span> Nouvel actif</a>
|
<a href="/histo_list">[ Historique ]</a>
|
||||||
<a href="/histo_list" class="btn btn-default" role="button">
|
<a href="/blog/2/mouvements-du-portefeuille">[ Mouvements ]</a>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -53,18 +53,19 @@ def portfolio(request):
|
|||||||
|
|
||||||
for item in actifs:
|
for item in actifs:
|
||||||
if item.Allocation.type == 'ACTION':
|
if item.Allocation.type == 'ACTION':
|
||||||
|
symbole = item.Actifs.symbole
|
||||||
# lire le cours de l'action
|
# lire le cours de l'action
|
||||||
ticker = yf.Ticker(item.Actifs.symbole)
|
ticker = yf.Ticker(symbole)
|
||||||
# ticker delisted ?
|
# ticker delisted ?
|
||||||
if item.Actifs.symbole == 'SHLDQ':
|
if symbole == 'SHLDQ':
|
||||||
price = 0
|
cours = 0
|
||||||
dividends = 0
|
|
||||||
else:
|
else:
|
||||||
price = ticker.fast_info.get('lastPrice')
|
cours = ticker.fast_info.get('lastPrice')
|
||||||
# caluler son rendement
|
|
||||||
dividends = PFService.get_dividends(ticker)
|
|
||||||
|
|
||||||
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
|
# time.sleep(1) # attendre 2 secondes
|
||||||
|
|
||||||
# update du portefeuille
|
# update du portefeuille
|
||||||
@@ -178,6 +179,7 @@ def histo_edit(request):
|
|||||||
if no_id == '0':
|
if no_id == '0':
|
||||||
# create a new tag
|
# create a new tag
|
||||||
entry = Histo()
|
entry = Histo()
|
||||||
|
entry.mvt_cash = 0
|
||||||
entry.date = datetime.datetime.now()
|
entry.date = datetime.datetime.now()
|
||||||
form = HistoForm(request.POST, entry)
|
form = HistoForm(request.POST, entry)
|
||||||
page_title = "Nouveau Histo"
|
page_title = "Nouveau Histo"
|
||||||
|
|||||||
Reference in New Issue
Block a user