wbfdm 1.54.2__py2.py3-none-any.whl → 1.54.4__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.

@@ -7,6 +7,14 @@ from wbfdm.contrib.metric.models import InstrumentMetric
7
7
  from .registry import backend_registry
8
8
 
9
9
 
10
+ def get_metrics_content_type(request, view):
11
+ return {
12
+ "id__in": list(
13
+ InstrumentMetric.objects.values_list("basket_content_type", flat=True).distinct("basket_content_type")
14
+ )
15
+ }
16
+
17
+
10
18
  class InstrumentMetricFilterSet(filters.FilterSet):
11
19
  parent_metric = filters.ModelChoiceFilter(
12
20
  label="Parent",
@@ -25,6 +33,7 @@ class InstrumentMetricFilterSet(filters.FilterSet):
25
33
  value_key="id",
26
34
  label_key="{{app_label}} | {{model}}",
27
35
  label=_("Basket Content Type"),
36
+ filter_params=get_metrics_content_type,
28
37
  )
29
38
 
30
39
  class Meta:
@@ -5,6 +5,7 @@ from typing import Callable
5
5
 
6
6
  import pytz
7
7
  from django.conf import settings
8
+ from django.core.exceptions import ObjectDoesNotExist
8
9
  from django.db import IntegrityError, connections
9
10
  from django.db.models import Max, QuerySet
10
11
  from django.template.loader import get_template
@@ -258,7 +259,10 @@ def update_or_create_item(
258
259
  _save_single_instrument(instrument)
259
260
  return instrument
260
261
 
261
- except InvalidMove:
262
+ except (
263
+ InvalidMove,
264
+ ObjectDoesNotExist,
265
+ ): # we might encounter a object does not exist error in case the inserted parent does not exist yet in our db which might happen if it was just deleted because invalid
262
266
  logger.warning(
263
267
  f"We encountered a MPTT ill-formed node for source ID {external_id}. Rebuilding the tree might be necessary."
264
268
  )
@@ -989,6 +989,10 @@ class Cash(Instrument):
989
989
 
990
990
  def save(self, *args, **kwargs):
991
991
  self.is_cash = True
992
+ self.dl_parameters["market_data"] = {
993
+ "path": "wbfdm.contrib.internal.dataloaders.market_data.MarketDataDataloader"
994
+ }
995
+
992
996
  super().save(*args, **kwargs)
993
997
 
994
998
  class Meta:
@@ -46,7 +46,10 @@ class InstrumentPMSMixin:
46
46
 
47
47
  def _build_dto(self, val_date: date, price_date_timedelta: int = 3) -> PriceDTO: # for backward compatibility
48
48
  try:
49
- price = self.valuations.get(date=val_date)
49
+ try:
50
+ price = self.valuations.get(date=val_date)
51
+ except InstrumentPrice.DoesNotExist:
52
+ price = self.prices.get(date=val_date)
50
53
  close = float(price.net_value)
51
54
  return PriceDTO(
52
55
  pk=price.id,
@@ -38,23 +38,25 @@ class TestInstrumentModel:
38
38
  assert res[0]["market_capitalization"] == price.market_capitalization
39
39
  assert res[0]["outstanding_shares"] == float(price.outstanding_shares)
40
40
 
41
- def test_get_price(self, instrument_factory, instrument_price_factory):
41
+ def test_get_price(self, weekday, instrument_factory, instrument_price_factory):
42
42
  instrument = instrument_factory.create()
43
43
  other_instrument = instrument_factory.create()
44
- price = instrument_price_factory.create(instrument=instrument)
45
- price.refresh_from_db()
44
+ price_calculated = instrument_price_factory.create(date=weekday, instrument=instrument, calculated=True)
45
+
46
46
  instrument_price_factory.create(instrument=other_instrument) # Noise
47
- assert instrument.get_price(price.date) == float(price.net_value)
48
- assert instrument.get_price((price.date + BDay(1)).date()) == float(price.net_value)
49
- assert instrument.get_price((price.date + BDay(2)).date()) == float(price.net_value)
50
- assert instrument.get_price((price.date + BDay(3)).date()) == float(price.net_value)
47
+ assert instrument.get_price(weekday) == float(price_calculated.net_value)
48
+ price_real = instrument_price_factory.create(date=weekday, instrument=instrument, calculated=False)
49
+ assert instrument.get_price(weekday) == float(price_real.net_value) # we prioritize real price
50
+ assert instrument.get_price((weekday + BDay(1)).date()) == float(price_real.net_value)
51
+ assert instrument.get_price((weekday + BDay(2)).date()) == float(price_real.net_value)
52
+ assert instrument.get_price((weekday + BDay(3)).date()) == float(price_real.net_value)
51
53
  with pytest.raises(ValueError):
52
- instrument.get_price((price.date + BDay(4)).date()) # for return the latest valid price 3 days earlier.
54
+ instrument.get_price((weekday + BDay(4)).date()) # for return the latest valid price 3 days earlier.
53
55
 
54
56
  # if the instrument is considered cash, we always return a value of 1
55
57
  instrument.is_cash = True
56
58
  instrument.save()
57
- assert instrument.get_price(price.date) == Decimal(1)
59
+ assert instrument.get_price(weekday) == Decimal(1)
58
60
 
59
61
  def test_extract_daily_performance_df(self):
60
62
  tidx = pd.date_range("2016-07-01", periods=4, freq="B")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbfdm
3
- Version: 1.54.2
3
+ Version: 1.54.4
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.*
@@ -49,7 +49,7 @@ wbfdm/contrib/metric/dispatch.py,sha256=io6p4EJf36OdnxZDTw-sRRKfr_q8TLYvIDGWCkb3
49
49
  wbfdm/contrib/metric/dto.py,sha256=vS93tUvfusWdE7gUJsp320GwfwWpb8bGJDdrb1GB6M8,3413
50
50
  wbfdm/contrib/metric/exceptions.py,sha256=6IuEVde7aOyQaXHE817bCNdUw8LTI3sOSU9LiV3NZbM,200
51
51
  wbfdm/contrib/metric/factories.py,sha256=b6-3fSERbZGjGw6QC0k3hhSpyQKVy2MJoZzX4y3GPEo,1123
52
- wbfdm/contrib/metric/filters.py,sha256=a6TAN-_EaRUhJ34JCFwFmEgj8uKZMNXFLOoMS2qvwZI,1427
52
+ wbfdm/contrib/metric/filters.py,sha256=TBFnA2gWuJU_QE5BPvpnBU4SVAsUemM__gSeUvmHQxQ,1690
53
53
  wbfdm/contrib/metric/models.py,sha256=lI_ZmK7058GT_5ngC45UdXRc7ju-ULbcOtO5w_CMBwU,7002
54
54
  wbfdm/contrib/metric/orchestrators.py,sha256=YyVVKKm3Sl1zVr2mw9A7LSJs6YnmElbg1yESREF3lFk,3736
55
55
  wbfdm/contrib/metric/registry.py,sha256=SdZff6FIrtdbyAO0X0BpXndJAIhU6VVojNui_MEw7jI,3167
@@ -115,7 +115,7 @@ wbfdm/contrib/qa/jinja2/qa/sql/ibes/estimates.sql,sha256=OWgeogSFj7-OdXvJTvNsThN
115
115
  wbfdm/contrib/qa/jinja2/qa/sql/ibes/financials.sql,sha256=0jXNMdX8ixVRJ8YyvtoJRQ510pHFYEioMy7NTp5ecck,2582
116
116
  wbfdm/contrib/qa/sync/exchanges.py,sha256=XU7dj-rQzMlDku9lnmAACaTRoxx8pFSyr5kCK79cYAc,3124
117
117
  wbfdm/contrib/qa/sync/instruments.py,sha256=8aTQVJ_cw1phe4FWikn79pjCfUijaTcwkdhQCtSXKH0,3156
118
- wbfdm/contrib/qa/sync/utils.py,sha256=8bJoKrTqosOofVLu5fBtHTLw4df86wgD2illJeUmbZM,11516
118
+ wbfdm/contrib/qa/sync/utils.py,sha256=LUnjNR28moT92cjP04SVCRQ_Ssp6SaO9kehgWV4zvOs,11782
119
119
  wbfdm/dataloaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
120
120
  wbfdm/dataloaders/cache.py,sha256=K9BeVxT7p-BMvjurINt18bfrUDccp840uIjfDBLJRNk,4841
121
121
  wbfdm/dataloaders/protocols.py,sha256=xFbexmhh38MWmkWsOSsfcNxdtrrWfO02qNihsqwA_BQ,2987
@@ -238,7 +238,7 @@ wbfdm/models/instruments/instrument_lists.py,sha256=GxfFyfYxEcJS36LAarHja49TOM8f
238
238
  wbfdm/models/instruments/instrument_prices.py,sha256=4xDZ2ulwQ1grVuznchz3m3920LTmHkxWfiSLy-c2u0g,22306
239
239
  wbfdm/models/instruments/instrument_relationships.py,sha256=zpCZCnt5CqIg5bd6le_6TyirsSwGV2NaqTVKw3bd5vM,10660
240
240
  wbfdm/models/instruments/instrument_requests.py,sha256=XbpofRS8WHadHlTFjvXJyd0o7K9r2pzJtnpjVQZOLdI,7832
241
- wbfdm/models/instruments/instruments.py,sha256=3I7s5hHcIQcBKjVjF4go9SSTw3Kr1RX9vImYYctjszQ,44035
241
+ wbfdm/models/instruments/instruments.py,sha256=N_g3yM5bajyo1tQBIeKkmQ4SdpPkUcEhKeEuTOJGwLw,44182
242
242
  wbfdm/models/instruments/options.py,sha256=hFprq7B5t4ctz8nVqzFsBEzftq_KDUSsSXl1zJyh7tE,7094
243
243
  wbfdm/models/instruments/private_equities.py,sha256=uzwZi8IkmCKAHVTxnuFya9tehx7kh57sTlTEi1ieDaM,2198
244
244
  wbfdm/models/instruments/querysets.py,sha256=zBY3lX_l0_gqIGjX4vkfn7DQ5QyF_okmIYZ6SV1Y6I4,7729
@@ -248,7 +248,7 @@ wbfdm/models/instruments/llm/create_instrument_news_relationships.py,sha256=f9MT
248
248
  wbfdm/models/instruments/mixin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
249
249
  wbfdm/models/instruments/mixin/financials_computed.py,sha256=L5wjXDsR0maiwfOKP6KyWNJNH4nGOoAjSc_hDM7fsj0,35105
250
250
  wbfdm/models/instruments/mixin/financials_serializer_fields.py,sha256=-OkpcUt1rZmB3nUcO2vckpJdVm8IxRqkPDEgcPqqoRU,68886
251
- wbfdm/models/instruments/mixin/instruments.py,sha256=W9v29cjST-5MAMMuXVnlH4ItdRTdoA_vMCkLUhQgW2s,9888
251
+ wbfdm/models/instruments/mixin/instruments.py,sha256=BNcI1pnGQFjHHTx2qqzYnbfcJ_dq84OzO5g_uxxDOVI,10013
252
252
  wbfdm/serializers/__init__.py,sha256=AXb03RKHo6B0ts_IQOvx89n9wKG8pxiumYv9cr4EhvA,197
253
253
  wbfdm/serializers/esg.py,sha256=epoX8cjkPuVv45aW-Jf85-rSO_ZrSnXcTxMcadKdC-I,1086
254
254
  wbfdm/serializers/exchanges.py,sha256=wYvy0XBS9tRFHqin23gABQ_pj3Rmsx1B075SZ5GqwDo,1211
@@ -280,7 +280,7 @@ wbfdm/tests/models/test_classifications.py,sha256=f2aM9UyV54fkEncp-uewEdOc3_0D-i
280
280
  wbfdm/tests/models/test_exchanges.py,sha256=KwK278MpA3FkpVgjW2l2PIHL7e8uDur7dOzIaTQEwyw,138
281
281
  wbfdm/tests/models/test_instrument_list.py,sha256=UIxKgBd4U-T2I4WDZfwacgJ1nKwJWYX1HKhdQDpx1tA,4899
282
282
  wbfdm/tests/models/test_instrument_prices.py,sha256=ObqFbJxZveiOPAK9_kC_JO9VBNmZB6bvGM4BejsFJ3c,16633
283
- wbfdm/tests/models/test_instruments.py,sha256=DCl73yP2n6hIBZWtXGr2H5UvYbVO_5iGN5lwGo3bgtk,9544
283
+ wbfdm/tests/models/test_instruments.py,sha256=Vg2cYWAwdu00dziKDUe_MrTzrsygHaZQHnvibF8pvew,9784
284
284
  wbfdm/tests/models/test_merge.py,sha256=tXD5xIxZyZtXpm9WIQ4Yc8TQwsUnkxkKIvMNwaHOvgM,4632
285
285
  wbfdm/tests/models/test_options.py,sha256=DoEAHhNQE4kucpBRRm2S05ozabkERz-I4mUolsE2Qi8,2269
286
286
  wbfdm/viewsets/__init__.py,sha256=ZM29X0-5AkSH2rzF_gKUI4FoaEWCcMTXPjruJ4Gi_x8,383
@@ -359,6 +359,6 @@ wbfdm/viewsets/statements/__init__.py,sha256=odxtFYUDICPmz8WCE3nx93EvKZLSPBEI4d7
359
359
  wbfdm/viewsets/statements/statements.py,sha256=gA6RCI8-B__JwjEb6OZxpn8Y-9aF-YQ3HIQ7e1vfJMw,4304
360
360
  wbfdm/viewsets/technical_analysis/__init__.py,sha256=qtCIBg0uSiZeJq_1tEQFilnorMBkMe6uCMfqar6-cLE,77
361
361
  wbfdm/viewsets/technical_analysis/monthly_performances.py,sha256=O1j8CGfOranL74LqVvcf7jERaDIboEJZiBf_AbbVDQ8,3974
362
- wbfdm-1.54.2.dist-info/METADATA,sha256=rJqeVQ3mwcMqF3EaqmkFHxjZCiFBjTkFdKBEuN1JD8U,768
363
- wbfdm-1.54.2.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
364
- wbfdm-1.54.2.dist-info/RECORD,,
362
+ wbfdm-1.54.4.dist-info/METADATA,sha256=XI3xyUaklo297IMvhNPC2hGUjqL5e2HaJmQzWkN5esM,768
363
+ wbfdm-1.54.4.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
364
+ wbfdm-1.54.4.dist-info/RECORD,,
File without changes