mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 10:56:24 +00:00
Hotfix for weighted median premium (#180)
* hotfix for empty array handling
This commit is contained in:
parent
b5dd4fbea5
commit
41f3df570e
13
api/utils.py
13
api/utils.py
@ -185,10 +185,11 @@ def compute_avg_premium(queryset):
|
|||||||
total_volume = sum(volumes)
|
total_volume = sum(volumes)
|
||||||
|
|
||||||
# weighted_median_premium is the weighted median of the premiums by volume
|
# weighted_median_premium is the weighted median of the premiums by volume
|
||||||
|
if len(premiums) > 0 and len(volumes)>0:
|
||||||
weighted_median_premium = weighted_median(values=premiums,
|
weighted_median_premium = weighted_median(values=premiums,
|
||||||
sample_weight=volumes,
|
sample_weight=volumes,
|
||||||
quantiles=0.5,
|
quantiles=0.5,
|
||||||
values_sorted=False)
|
values_sorted=False)
|
||||||
|
else:
|
||||||
|
weighted_median_premium = 0.0
|
||||||
return weighted_median_premium, total_volume
|
return weighted_median_premium, total_volume
|
||||||
|
Loading…
Reference in New Issue
Block a user