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

@@ -75,6 +75,8 @@ class DSWSMarketDataDataloader(MarketDataProtocol, Dataloader):
75
75
  parameters["end"] = to_date.strftime("%Y-%m-%d")
76
76
  for chunked_identifiers in client.get_chunked_list(identifiers, len(fields)):
77
77
  df = client.get_timeserie_df(chunked_identifiers, fields, **parameters)
78
+ if exact_date:
79
+ df = df[df["Dates"] == exact_date]
78
80
  for row in df.to_dict("records"):
79
81
  jsondate = row["Dates"].date()
80
82
  external_id = row["Instrument"]
@@ -1,6 +1,7 @@
1
1
  from typing import Any, Dict, Optional
2
2
 
3
3
  from django.db import models
4
+ from django.utils.translation import gettext_lazy as _
4
5
  from django_fsm import FSMField, transition
5
6
  from wbcore.contrib.authentication.models import User
6
7
  from wbcore.contrib.currency.models import Currency
@@ -112,7 +113,7 @@ class InstrumentRequest(WBModel):
112
113
 
113
114
  def can_approve(self):
114
115
  if self._check_already_existing_instrument():
115
- return {"non_field_errors": "An instrument already exists with the proposed identifier"}
116
+ return {"non_field_errors": [_("An instrument already exists with the proposed identifier")]}
116
117
 
117
118
  @transition(
118
119
  field=status,
@@ -178,7 +179,7 @@ class InstrumentRequest(WBModel):
178
179
 
179
180
  def can_submit(self) -> Dict[str, Any]:
180
181
  if self._check_already_existing_instrument():
181
- return {"non_field_errors": "An instrument already exists with the proposed identifier"}
182
+ return {"non_field_errors": [_("An instrument already exists with the proposed identifier")]}
182
183
 
183
184
  @classmethod
184
185
  def get_representation_endpoint(cls) -> str:
@@ -130,6 +130,9 @@ class InstrumentManager(TreeManager):
130
130
  def annotate_all(self):
131
131
  return self.get_queryset().annotate_all()
132
132
 
133
+ def filter_active_at_date(self, val_date: date):
134
+ return self.get_queryset().filter_active_at_date(val_date)
135
+
133
136
 
134
137
  class SecurityInstrumentManager(InstrumentManager):
135
138
  def get_queryset(self) -> InstrumentQuerySet:
@@ -142,19 +145,8 @@ class ClassifiableInstrumentManager(InstrumentManager):
142
145
 
143
146
 
144
147
  class ActiveInstrumentManager(InstrumentManager):
145
- def get_queryset_at_date(self, val_date: date):
146
- return (
147
- super()
148
- .get_queryset()
149
- .filter(
150
- (models.Q(delisted_date__isnull=True) | models.Q(delisted_date__gte=val_date))
151
- & models.Q(inception_date__isnull=False)
152
- & models.Q(inception_date__lte=val_date)
153
- )
154
- )
155
-
156
148
  def get_queryset(self):
157
- return self.get_queryset_at_date(date.today())
149
+ return super().get_queryset().filter_active_at_date(date.today())
158
150
 
159
151
 
160
152
  class InvestableUniverseManager(InstrumentManager):
@@ -579,6 +571,18 @@ class Instrument(ComplexToStringMixin, TagModelMixin, ImportMixin, InstrumentPMS
579
571
  if favorite_classification := self.classifications.filter(group=get_default_classification_group()).first():
580
572
  return favorite_classification
581
573
 
574
+ def get_primary_quote(self):
575
+ if self.children.exists():
576
+ # we try the primary children first, then the first children within the investable universe and we fallback to the first children otherwise
577
+ try:
578
+ instrument = self.children.get(is_primary=True)
579
+ except Instrument.DoesNotExist:
580
+ instrument = self.children.filter(is_investable_universe=True).first()
581
+ if not instrument:
582
+ instrument = self.children.first()
583
+ return instrument.get_primary_quote()
584
+ return self
585
+
582
586
  @property
583
587
  def active(self) -> bool:
584
588
  today = date.today()
@@ -10,6 +10,7 @@ from django.db.models import (
10
10
  ExpressionWrapper,
11
11
  F,
12
12
  OuterRef,
13
+ Q,
13
14
  QuerySet,
14
15
  Subquery,
15
16
  )
@@ -20,6 +21,12 @@ from wbfdm.enums import MarketData
20
21
 
21
22
 
22
23
  class InstrumentQuerySet(QuerySet):
24
+ def filter_active_at_date(self, val_date: date):
25
+ return self.filter(
26
+ (Q(delisted_date__isnull=True) | Q(delisted_date__gte=val_date))
27
+ & (Q(inception_date__isnull=True) | Q(inception_date__lte=val_date))
28
+ )
29
+
23
30
  def annotate_classification_for_group(
24
31
  self, classification_group, classification_height: int = 0, **kwargs
25
32
  ) -> QuerySet:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbfdm
3
- Version: 1.49.0
3
+ Version: 1.49.2
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.*
@@ -38,7 +38,7 @@ wbfdm/backends/dto.py,sha256=5IdeGVsrk8trEi9rqtq-zisqiEDE_VLBP8RxlfZZnjk,596
38
38
  wbfdm/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  wbfdm/contrib/dsws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  wbfdm/contrib/dsws/client.py,sha256=C598w5P85kvX7_gR0Yf-WHRLj77HqztUhofBMl3JWAE,14508
41
- wbfdm/contrib/dsws/dataloaders/market_data.py,sha256=TVL0Vzmg8hDzjbqBWx1342dvT_qC5gVp8E4i3hVcivA,6003
41
+ wbfdm/contrib/dsws/dataloaders/market_data.py,sha256=7Vj64nLqJAA3BiNeJPr3uLnnZ5kFOY2XGyAAJRL7vOk,6097
42
42
  wbfdm/contrib/internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  wbfdm/contrib/internal/dataloaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  wbfdm/contrib/internal/dataloaders/market_data.py,sha256=aoWSMamtnMbejYZrHzr37dQCG40nuA3fNBQNOyqhceQ,3260
@@ -230,11 +230,11 @@ wbfdm/models/instruments/classifications.py,sha256=EeZ_P8f1F1NfjUmLf9fDMF0iPM73q
230
230
  wbfdm/models/instruments/instrument_lists.py,sha256=GxfFyfYxEcJS36LAarHja49TOM8ffhIivpZX2-tPtZg,4234
231
231
  wbfdm/models/instruments/instrument_prices.py,sha256=WCaFMZ9sF7xeGTp9jkq7TA8RfYHrwvTjujzqgCKj9SI,22070
232
232
  wbfdm/models/instruments/instrument_relationships.py,sha256=zpCZCnt5CqIg5bd6le_6TyirsSwGV2NaqTVKw3bd5vM,10660
233
- wbfdm/models/instruments/instrument_requests.py,sha256=wC07CEqQxMGfrnATyr56T6GWxXknai105G2WIw1i3xk,7767
234
- wbfdm/models/instruments/instruments.py,sha256=jbk3rsTIddstWi6DfFPt_UHtthQb0BUtOZUwA2gocJA,39573
233
+ wbfdm/models/instruments/instrument_requests.py,sha256=XbpofRS8WHadHlTFjvXJyd0o7K9r2pzJtnpjVQZOLdI,7832
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=c5Op5VxR0A0uRPGHmnLJ6b7d2X5Kb5IX5bnk7MUfTjA,6475
237
+ wbfdm/models/instruments/querysets.py,sha256=gL-uC5MfsX58RInK64Pok49tqeZhZY7xKPvPiwmraSQ,6732
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
@@ -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.0.dist-info/METADATA,sha256=C8Y0mUVZ76A9TxM7gsYtL6k28hNfD4qHqnQWytjJyAI,737
356
- wbfdm-1.49.0.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
357
- wbfdm-1.49.0.dist-info/RECORD,,
355
+ wbfdm-1.49.2.dist-info/METADATA,sha256=L1Z7pyHHJyzLnwLBcKxunvp7Cj0lWXdw58lcNLFDF4o,737
356
+ wbfdm-1.49.2.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
357
+ wbfdm-1.49.2.dist-info/RECORD,,
File without changes