wbfdm 1.49.8__py2.py3-none-any.whl → 1.49.9__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of wbfdm might be problematic. Click here for more details.
- wbfdm/models/instruments/querysets.py +41 -35
- wbfdm/tasks.py +0 -1
- wbfdm/viewsets/configs/display/instrument_prices.py +2 -70
- {wbfdm-1.49.8.dist-info → wbfdm-1.49.9.dist-info}/METADATA +1 -1
- {wbfdm-1.49.8.dist-info → wbfdm-1.49.9.dist-info}/RECORD +6 -6
- {wbfdm-1.49.8.dist-info → wbfdm-1.49.9.dist-info}/WHEEL +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import math
|
|
2
1
|
from contextlib import suppress
|
|
3
2
|
from datetime import date
|
|
3
|
+
from decimal import Decimal
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import pandas as pd
|
|
7
|
+
from django.core.exceptions import ValidationError
|
|
8
|
+
from django.core.validators import DecimalValidator
|
|
7
9
|
from django.db.models import (
|
|
8
10
|
AutoField,
|
|
9
11
|
Exists,
|
|
@@ -88,43 +90,46 @@ class InstrumentQuerySet(QuerySet):
|
|
|
88
90
|
from wbfdm.models import InstrumentPrice
|
|
89
91
|
|
|
90
92
|
def _dict_to_object(instrument, row):
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
close = row.get("close", None)
|
|
94
|
+
price_date = row.get("date")
|
|
95
|
+
if price_date and close is not None:
|
|
96
|
+
close = round(Decimal(close), 6)
|
|
97
|
+
# we validate that close can be inserting into our table<
|
|
98
|
+
with suppress(ValidationError):
|
|
99
|
+
validator = DecimalValidator(16, 6)
|
|
100
|
+
validator(close)
|
|
97
101
|
try:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
p.id = None
|
|
109
|
-
return p
|
|
110
|
-
except InstrumentPrice.DoesNotExist:
|
|
111
|
-
with suppress(CurrencyFXRates.DoesNotExist):
|
|
112
|
-
p = InstrumentPrice(
|
|
113
|
-
currency_fx_rate_to_usd=CurrencyFXRates.objects.get(
|
|
114
|
-
# we need to get the currency rate because we bulk create the object, and thus save is not called
|
|
115
|
-
date=price_date,
|
|
116
|
-
currency=instrument.currency,
|
|
117
|
-
),
|
|
118
|
-
instrument=instrument,
|
|
119
|
-
date=price_date,
|
|
120
|
-
calculated=row["calculated"],
|
|
121
|
-
net_value=close,
|
|
122
|
-
gross_value=close,
|
|
123
|
-
volume=row.get("volume", None),
|
|
124
|
-
market_capitalization=row.get("market_capitalization", None),
|
|
125
|
-
)
|
|
102
|
+
try:
|
|
103
|
+
p = InstrumentPrice.objects.get(instrument=instrument, date=price_date, calculated=False)
|
|
104
|
+
except InstrumentPrice.DoesNotExist:
|
|
105
|
+
p = InstrumentPrice.objects.get(instrument=instrument, date=price_date, calculated=True)
|
|
106
|
+
p.net_value = close
|
|
107
|
+
p.gross_value = close
|
|
108
|
+
p.calculated = row["calculated"]
|
|
109
|
+
p.volume = row.get("volume", p.volume)
|
|
110
|
+
p.market_capitalization = row.get("market_capitalization", p.market_capitalization)
|
|
111
|
+
p.market_capitalization_consolidated = p.market_capitalization
|
|
126
112
|
p.set_dynamic_field(False)
|
|
113
|
+
p.id = None
|
|
127
114
|
return p
|
|
115
|
+
except InstrumentPrice.DoesNotExist:
|
|
116
|
+
with suppress(CurrencyFXRates.DoesNotExist):
|
|
117
|
+
p = InstrumentPrice(
|
|
118
|
+
currency_fx_rate_to_usd=CurrencyFXRates.objects.get(
|
|
119
|
+
# we need to get the currency rate because we bulk create the object, and thus save is not called
|
|
120
|
+
date=price_date,
|
|
121
|
+
currency=instrument.currency,
|
|
122
|
+
),
|
|
123
|
+
instrument=instrument,
|
|
124
|
+
date=price_date,
|
|
125
|
+
calculated=row["calculated"],
|
|
126
|
+
net_value=close,
|
|
127
|
+
gross_value=close,
|
|
128
|
+
volume=row.get("volume", None),
|
|
129
|
+
market_capitalization=row.get("market_capitalization", None),
|
|
130
|
+
)
|
|
131
|
+
p.set_dynamic_field(False)
|
|
132
|
+
return p
|
|
128
133
|
|
|
129
134
|
df = pd.DataFrame(
|
|
130
135
|
self.dl.market_data(
|
|
@@ -154,6 +159,7 @@ class InstrumentQuerySet(QuerySet):
|
|
|
154
159
|
dff = dff.reset_index(names="date").dropna(subset=["close"])
|
|
155
160
|
dff = dff.replace([np.inf, -np.inf, np.nan], None)
|
|
156
161
|
instrument = self.get(id=instrument_id)
|
|
162
|
+
|
|
157
163
|
yield from filter(
|
|
158
164
|
lambda x: x, map(lambda row: _dict_to_object(instrument, row), dff.to_dict("records"))
|
|
159
165
|
)
|
wbfdm/tasks.py
CHANGED
|
@@ -51,7 +51,6 @@ def update_of_investable_universe_data(
|
|
|
51
51
|
Instrument.investable_universe.update(
|
|
52
52
|
is_investable_universe=True
|
|
53
53
|
) # ensure all the investable universe is marked as such
|
|
54
|
-
|
|
55
54
|
instruments = Instrument.active_objects.filter(is_investable_universe=True, delisted_date__isnull=True).exclude(
|
|
56
55
|
Q(is_managed=True)
|
|
57
56
|
| Q(dl_parameters__market_data__path="wbfdm.contrib.internal.dataloaders.market_data.MarketDataDataloader")
|
|
@@ -37,70 +37,6 @@ perf_formatting_rules_bold = [
|
|
|
37
37
|
),
|
|
38
38
|
]
|
|
39
39
|
|
|
40
|
-
instrument_formatting_rules = [
|
|
41
|
-
dp.Formatting(
|
|
42
|
-
column="instrument_vs_benchmark",
|
|
43
|
-
formatting_rules=[
|
|
44
|
-
dp.FormattingRule(
|
|
45
|
-
style={"color": WBColor.GREEN_DARK.value},
|
|
46
|
-
condition=("==", True),
|
|
47
|
-
),
|
|
48
|
-
dp.FormattingRule(
|
|
49
|
-
style={"color": WBColor.RED_DARK.value},
|
|
50
|
-
condition=("==", False),
|
|
51
|
-
),
|
|
52
|
-
],
|
|
53
|
-
),
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
benchmark_formatting_rules = [
|
|
57
|
-
dp.Formatting(
|
|
58
|
-
column="instrument_vs_benchmark",
|
|
59
|
-
formatting_rules=[
|
|
60
|
-
dp.FormattingRule(
|
|
61
|
-
style={"color": WBColor.GREEN_DARK.value},
|
|
62
|
-
condition=("==", False),
|
|
63
|
-
),
|
|
64
|
-
dp.FormattingRule(
|
|
65
|
-
style={"color": WBColor.RED_DARK.value},
|
|
66
|
-
condition=("==", True),
|
|
67
|
-
),
|
|
68
|
-
],
|
|
69
|
-
),
|
|
70
|
-
]
|
|
71
|
-
|
|
72
|
-
instrument_one_year_formatting_rules = [
|
|
73
|
-
dp.Formatting(
|
|
74
|
-
column="instrument_vs_benchmark_one_year",
|
|
75
|
-
formatting_rules=[
|
|
76
|
-
dp.FormattingRule(
|
|
77
|
-
style={"color": WBColor.GREEN_DARK.value},
|
|
78
|
-
condition=("==", True),
|
|
79
|
-
),
|
|
80
|
-
dp.FormattingRule(
|
|
81
|
-
style={"color": WBColor.RED_DARK.value},
|
|
82
|
-
condition=("==", False),
|
|
83
|
-
),
|
|
84
|
-
],
|
|
85
|
-
),
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
benchmark_one_year_formatting_rules = [
|
|
89
|
-
dp.Formatting(
|
|
90
|
-
column="instrument_vs_benchmark_one_year",
|
|
91
|
-
formatting_rules=[
|
|
92
|
-
dp.FormattingRule(
|
|
93
|
-
style={"color": WBColor.GREEN_DARK.value},
|
|
94
|
-
condition=("==", False),
|
|
95
|
-
),
|
|
96
|
-
dp.FormattingRule(
|
|
97
|
-
style={"color": WBColor.RED_DARK.value},
|
|
98
|
-
condition=("==", True),
|
|
99
|
-
),
|
|
100
|
-
],
|
|
101
|
-
),
|
|
102
|
-
]
|
|
103
|
-
|
|
104
40
|
|
|
105
41
|
class InstrumentPriceDisplayConfig(DisplayViewConfig):
|
|
106
42
|
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
@@ -170,19 +106,15 @@ class FinancialStatisticsInstrumentPandasDisplayConfig(DisplayViewConfig):
|
|
|
170
106
|
),
|
|
171
107
|
],
|
|
172
108
|
),
|
|
173
|
-
dp.Field(
|
|
174
|
-
|
|
175
|
-
),
|
|
176
|
-
dp.Field(key="benchmark_statistics", label="Benchmark", formatting_rules=benchmark_formatting_rules),
|
|
109
|
+
dp.Field(key="instrument_statistics", label="Instrument"),
|
|
110
|
+
dp.Field(key="benchmark_statistics", label="Benchmark"),
|
|
177
111
|
dp.Field(
|
|
178
112
|
key="instrument_one_year",
|
|
179
113
|
label="Instrument - One Year",
|
|
180
|
-
formatting_rules=instrument_one_year_formatting_rules,
|
|
181
114
|
),
|
|
182
115
|
dp.Field(
|
|
183
116
|
key="benchmark_one_year",
|
|
184
117
|
label="Benchmark - One Year",
|
|
185
|
-
formatting_rules=benchmark_one_year_formatting_rules,
|
|
186
118
|
),
|
|
187
119
|
]
|
|
188
120
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wbfdm
|
|
3
|
-
Version: 1.49.
|
|
3
|
+
Version: 1.49.9
|
|
4
4
|
Summary: The workbench module ensures rapid access to diverse financial data (market, fundamental, forecasts, ESG), with features for storing instruments, classifying them, and conducting financial analysis.
|
|
5
5
|
Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
|
|
6
6
|
Requires-Dist: roman==4.*
|
|
@@ -6,7 +6,7 @@ wbfdm/jinja2.py,sha256=pkIC1U-0rf6vn0DDEUzZ8dPYiTGEPY8LBTRMi9wYiuc,199
|
|
|
6
6
|
wbfdm/menu.py,sha256=c_uP0wIxboHvY0BfHbYPI9GI4F41UxSgREqbzcaxzHM,399
|
|
7
7
|
wbfdm/preferences.py,sha256=8ghDcaapOMso1kjtNfKbSFykPUTxzqI5R77gM3BgiMs,927
|
|
8
8
|
wbfdm/signals.py,sha256=PhAsFpQZF1YVe5UpedaRelUD_TVjemqRYm1HzV-bhmY,597
|
|
9
|
-
wbfdm/tasks.py,sha256=
|
|
9
|
+
wbfdm/tasks.py,sha256=rjbbDewuiDmfO54tBUwPiNV9AoDKnIx382riyExWwnI,4362
|
|
10
10
|
wbfdm/urls.py,sha256=pDp9I0kktxicad8sXXEUT7402jZPMJNcE5R1doTlcMw,8887
|
|
11
11
|
wbfdm/utils.py,sha256=4cWrCpqXxHIjtSlt4DDPFvmtaqXw_H0nqhM6sGuXx0o,1938
|
|
12
12
|
wbfdm/admin/__init__.py,sha256=Z1VtH_gjD71K79KcD-2Q2Lu_p_7j0akMZj7gNxdz1CQ,1398
|
|
@@ -234,7 +234,7 @@ wbfdm/models/instruments/instrument_requests.py,sha256=XbpofRS8WHadHlTFjvXJyd0o7
|
|
|
234
234
|
wbfdm/models/instruments/instruments.py,sha256=T0Ey5tMbUnA8DMroY1c959hOL9bI-CwTZnq5XhxCmi4,39934
|
|
235
235
|
wbfdm/models/instruments/options.py,sha256=hFprq7B5t4ctz8nVqzFsBEzftq_KDUSsSXl1zJyh7tE,7094
|
|
236
236
|
wbfdm/models/instruments/private_equities.py,sha256=uzwZi8IkmCKAHVTxnuFya9tehx7kh57sTlTEi1ieDaM,2198
|
|
237
|
-
wbfdm/models/instruments/querysets.py,sha256=
|
|
237
|
+
wbfdm/models/instruments/querysets.py,sha256=c9fbHVvIRyaFU7jm_CM90lfIVzB8beOD8YII9-FqdT4,7191
|
|
238
238
|
wbfdm/models/instruments/utils.py,sha256=88jnWINSSC0OwH-mCEOPLZXuhBCtEsxBpSaZ38GteaE,1365
|
|
239
239
|
wbfdm/models/instruments/llm/__init__.py,sha256=dSmxRmEWb0A4O_lUoWuRKt2mBtUuLCTPVVJqGyi_n40,52
|
|
240
240
|
wbfdm/models/instruments/llm/create_instrument_news_relationships.py,sha256=Eza39rlkNJxpURroIsJLImKC6F-KtTmkdjHn1kv4F3Q,3439
|
|
@@ -295,7 +295,7 @@ wbfdm/viewsets/configs/display/esg.py,sha256=NcBZDxkIsGd-APYt4yJRNJjfmbmkC0O-H1q
|
|
|
295
295
|
wbfdm/viewsets/configs/display/exchanges.py,sha256=uo-rh_20FjreGmqAiPbU0zTZ-I2CoV0bBC4uxX4hQbs,1946
|
|
296
296
|
wbfdm/viewsets/configs/display/financial_summary.py,sha256=K8CPV9uy0wsK-yLQIDTqMAXTb-W1-pUp6OCMwii7jYo,4738
|
|
297
297
|
wbfdm/viewsets/configs/display/instrument_lists.py,sha256=UF_M41sBDDxGLDlKxLdAHqo8S1iHJfvIwZbLuoeaGuA,5239
|
|
298
|
-
wbfdm/viewsets/configs/display/instrument_prices.py,sha256=
|
|
298
|
+
wbfdm/viewsets/configs/display/instrument_prices.py,sha256=CdZg-Fwd__DP0Ym8TBsupbVZzhoMbNfOJQKCmgKvwCc,4908
|
|
299
299
|
wbfdm/viewsets/configs/display/instrument_requests.py,sha256=CarX1MGe64roHZETm2N4HsEMssHVI5mWw2xTUBjgi-k,5129
|
|
300
300
|
wbfdm/viewsets/configs/display/instruments.py,sha256=PTSl-d8iLvm_rbUF-3hf4s85R2lhttJX9FNi9JHTr2M,17413
|
|
301
301
|
wbfdm/viewsets/configs/display/instruments_relationships.py,sha256=BLAl2ZciWR5Waf3qPd1QQwdiupgIf_wGK6rmYe9byuY,2480
|
|
@@ -352,6 +352,6 @@ wbfdm/viewsets/statements/__init__.py,sha256=odxtFYUDICPmz8WCE3nx93EvKZLSPBEI4d7
|
|
|
352
352
|
wbfdm/viewsets/statements/statements.py,sha256=kmtM0uZ3f7eJJe5gVmd-iVra9dHwTB9x12p7f5qTEx8,4084
|
|
353
353
|
wbfdm/viewsets/technical_analysis/__init__.py,sha256=qtCIBg0uSiZeJq_1tEQFilnorMBkMe6uCMfqar6-cLE,77
|
|
354
354
|
wbfdm/viewsets/technical_analysis/monthly_performances.py,sha256=O1j8CGfOranL74LqVvcf7jERaDIboEJZiBf_AbbVDQ8,3974
|
|
355
|
-
wbfdm-1.49.
|
|
356
|
-
wbfdm-1.49.
|
|
357
|
-
wbfdm-1.49.
|
|
355
|
+
wbfdm-1.49.9.dist-info/METADATA,sha256=4J-SnkMs8VvigqFshpnyVP-SDd-YDUSVvhBkw5NYfKQ,737
|
|
356
|
+
wbfdm-1.49.9.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
|
357
|
+
wbfdm-1.49.9.dist-info/RECORD,,
|
|
File without changes
|