Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
49a54327
Commit
49a54327
authored
5 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#807
fix zerosum referentials using "last" fields in blockchain
parent
2ba1c4d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!781
0.52.0
,
!780
Issue 807
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sakia/money/quant_zerosum.py
+5
-6
5 additions, 6 deletions
src/sakia/money/quant_zerosum.py
src/sakia/money/relative_zerosum.py
+13
-19
13 additions, 19 deletions
src/sakia/money/relative_zerosum.py
with
18 additions
and
25 deletions
src/sakia/money/quant_zerosum.py
+
5
−
6
View file @
49a54327
...
...
@@ -11,14 +11,14 @@ class QuantitativeZSum(BaseReferential):
_UNITS_STR_
=
QT_TRANSLATE_NOOP
(
"
QuantitativeZSum
"
,
"
Q0
"
)
_FORMULA_STR_
=
QT_TRANSLATE_NOOP
(
"
QuantitativeZSum
"
,
"""
Q0 = Q - ( M(t
-1
) / N )
"""
Q0 = Q - ( M(t) / N
(t)
)
<br >
<table>
<tr><td>Q0</td><td>Quantitative value at zero sum</td></tr>
<tr><td>Q</td><td>Quantitative value</td></tr>
<tr><td>M</td><td>Monetary mass</td></tr>
<tr><td>N</td><td>Members count</td></tr>
<tr><td>t
-1
</td><td>
Previous
UD time</td></tr>
<tr><td>t</td><td>
Last
UD time</td></tr>
</table>
"""
,
)
_DESCRIPTION_STR_
=
QT_TRANSLATE_NOOP
(
...
...
@@ -68,12 +68,11 @@ class QuantitativeZSum(BaseReferential):
"""
Return quantitative value of amount minus the average value
Z0 = Q - ( M(t
-1
) / N(t) )
Z0 = Q - ( M(t) / N(t) )
Z0 = Quantitative value at zero sum
Q = Quantitative value
t = last UD block time
t-1 = penultimate UD block time
M = Monetary mass
N = Members count
...
...
@@ -84,7 +83,7 @@ class QuantitativeZSum(BaseReferential):
last_members_count
=
self
.
_blockchain_processor
.
last_members_count
(
self
.
currency
)
monetary_mass
=
self
.
_blockchain_processor
.
curren
t_mass
(
self
.
currency
)
monetary_mass
=
self
.
_blockchain_processor
.
las
t_mass
(
self
.
currency
)
if
last_members_count
!=
0
:
average
=
int
(
monetary_mass
/
last_members_count
)
else
:
...
...
@@ -112,7 +111,7 @@ class QuantitativeZSum(BaseReferential):
last_members_count
=
self
.
_blockchain_processor
.
last_members_count
(
self
.
currency
)
monetary_mass
=
self
.
_blockchain_processor
.
curren
t_mass
(
self
.
currency
)
monetary_mass
=
self
.
_blockchain_processor
.
las
t_mass
(
self
.
currency
)
if
last_members_count
!=
0
:
average
=
int
(
monetary_mass
/
last_members_count
)
else
:
...
...
This diff is collapsed.
Click to expand it.
src/sakia/money/relative_zerosum.py
+
13
−
19
View file @
49a54327
...
...
@@ -11,7 +11,7 @@ class RelativeZSum(BaseReferential):
_UNITS_STR_
=
QT_TRANSLATE_NOOP
(
"
RelativeZSum
"
,
"
R0 UD
"
)
_FORMULA_STR_
=
QT_TRANSLATE_NOOP
(
"
RelativeZSum
"
,
"""
R0 = (Q / UD(t)) - (( M(t
-1
) / N ) / UD(t))
"""
R0 = (Q / UD(t)) - (( M(t) / N
(t)
) / UD(t))
<br >
<table>
<tr><td>R0</td><td>Relative value at zero sum</td></tr>
...
...
@@ -19,7 +19,6 @@ class RelativeZSum(BaseReferential):
<tr><td>M</td><td>Monetary mass</td></tr>
<tr><td>N</td><td>Members count</td></tr>
<tr><td>t</td><td>Last UD time</td></tr>
<tr><td>t-1</td><td>Penultimate UD time</td></tr>
</table>
"""
,
)
_DESCRIPTION_STR_
=
QT_TRANSLATE_NOOP
(
...
...
@@ -65,24 +64,21 @@ class RelativeZSum(BaseReferential):
"""
Return relative value of amount minus the average value
zsum value = (value / UD(t)) - (( M(t) / N(t) ) / UD(t))
t = last UD block
t-1 = penultimate UD block
M = Monetary mass
N = Members count
zsum value = (value / UD(t)) - (( M(t-1) / N(t) ) / UD(t))
:param int amount: Value
:param sakia.core.community.Community community: Community instance
:return: float
"""
dividend
,
base
=
self
.
_blockchain_processor
.
previous_ud
(
self
.
currency
)
previous_monetary_mass
=
self
.
_blockchain_processor
.
previous_monetary_mass
(
self
.
currency
)
members_count
=
self
.
_blockchain_processor
.
current_members_count
(
self
.
currency
)
if
previous_monetary_mass
and
members_count
>
0
:
median
=
previous_monetary_mass
/
members_count
dividend
,
base
=
self
.
_blockchain_processor
.
last_ud
(
self
.
currency
)
monetary_mass
=
self
.
_blockchain_processor
.
last_mass
(
self
.
currency
)
members_count
=
self
.
_blockchain_processor
.
last_members_count
(
self
.
currency
)
if
monetary_mass
and
members_count
>
0
:
median
=
monetary_mass
/
members_count
relative_value
=
self
.
amount
/
float
(
dividend
*
10
**
base
)
relative_median
=
median
/
float
(
dividend
*
10
**
base
)
else
:
...
...
@@ -100,13 +96,11 @@ class RelativeZSum(BaseReferential):
:param value: Value in referential units
:return:
"""
dividend
,
base
=
self
.
_blockchain_processor
.
previous_ud
(
self
.
currency
)
previous_monetary_mass
=
self
.
_blockchain_processor
.
previous_monetary_mass
(
self
.
currency
)
members_count
=
self
.
_blockchain_processor
.
current_members_count
(
self
.
currency
)
if
previous_monetary_mass
and
members_count
>
0
:
median
=
previous_monetary_mass
/
members_count
dividend
,
base
=
self
.
_blockchain_processor
.
last_ud
(
self
.
currency
)
monetary_mass
=
self
.
_blockchain_processor
.
last_mass
(
self
.
currency
)
members_count
=
self
.
_blockchain_processor
.
last_members_count
(
self
.
currency
)
if
monetary_mass
and
members_count
>
0
:
median
=
monetary_mass
/
members_count
relative_median
=
median
/
float
(
dividend
*
10
**
base
)
else
:
relative_median
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment