wbportfolio 1.50.7__py2.py3-none-any.whl → 1.50.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 wbportfolio might be problematic. Click here for more details.

@@ -1,5 +1,4 @@
1
- import json
2
- from typing import TYPE_CHECKING
1
+ from typing import TYPE_CHECKING, Any
3
2
 
4
3
  from django.db.models import F, FloatField, Sum
5
4
  from django.db.models.functions import Cast, ExtractYear
@@ -11,7 +10,7 @@ if TYPE_CHECKING:
11
10
  from wbcrm.models import Account
12
11
 
13
12
 
14
- def get_holding_prompt(account: "Account") -> list["BaseMessage"]:
13
+ def get_holding_prompt(account: "Account") -> tuple[list["BaseMessage"], dict[str, Any]]:
15
14
  from wbportfolio.models import Product
16
15
  from wbportfolio.models.transactions.claim import Claim
17
16
 
@@ -23,19 +22,21 @@ def get_holding_prompt(account: "Account") -> list["BaseMessage"]:
23
22
 
24
23
  performances = {}
25
24
  for product_id, product_name in products:
26
- performances[product_name] = Instrument.extract_annual_performance_df(
27
- Product.objects.get(id=product_id).get_prices_df()
28
- ).to_dict()
25
+ performances[product_name] = (
26
+ Instrument.extract_annual_performance_df(Product.objects.get(id=product_id).get_prices_df())
27
+ .set_index("year")["performance"]
28
+ .to_dict()
29
+ )
29
30
 
30
31
  return [
31
32
  SystemMessage(
32
33
  "The following products are held by the account holder. Analyze their performances and check correlations between the holdings and their performances/interactions."
33
34
  ),
34
- HumanMessage(json.dumps(performances)),
35
- ]
35
+ HumanMessage("Performances per product ISIN per year: {performances}"),
36
+ ], {"performances": performances}
36
37
 
37
38
 
38
- def get_performances_prompt(account: "Account") -> list["BaseMessage"]:
39
+ def get_performances_prompt(account: "Account") -> tuple[list["BaseMessage"], dict[str, Any]]:
39
40
  from wbportfolio.models.transactions.claim import Claim
40
41
 
41
42
  holdings = (
@@ -48,11 +49,11 @@ def get_performances_prompt(account: "Account") -> list["BaseMessage"]:
48
49
  product_isin=F("product__isin"),
49
50
  )
50
51
  .values("product_name", "product_isin", "sum_shares", "year")
51
- )
52
+ ).order_by("year", "product")
52
53
 
53
54
  return [
54
55
  SystemMessage(
55
56
  "The following holdings (subscriptions/redemptions) have been found for this account. Please include this data in the analysis and check if there is any correlation between the holding data and the interactions."
56
57
  ),
57
- HumanMessage(json.dumps(list(holdings.order_by("year", "product")))),
58
- ]
58
+ HumanMessage("List of holdings for the account: {holdings}"),
59
+ ], {"holdings": list(holdings)}
@@ -34,11 +34,11 @@ from wbcrm.models.accounts import Account
34
34
  from wbfdm.models.instruments.instrument_prices import InstrumentPrice
35
35
  from wbfdm.models.instruments.instruments import InstrumentManager, InstrumentType
36
36
 
37
- from wbportfolio.models.llm.wbcrm.analyze_relationship import get_holding_prompt
38
37
  from wbportfolio.models.portfolio_relationship import InstrumentPortfolioThroughModel
39
38
 
40
39
  from ..preferences import get_product_termination_notice_period
41
40
  from . import PortfolioRole
41
+ from .llm.wbcrm.analyze_relationship import get_holding_prompt
42
42
  from .mixins.instruments import PMSInstrument, PMSInstrumentAbstractModel
43
43
 
44
44
 
@@ -1,3 +1,6 @@
1
+ from contextlib import suppress
2
+
3
+ from django.core.exceptions import ObjectDoesNotExist
1
4
  from django.db import models
2
5
  from django.dispatch import receiver
3
6
  from wbfdm.models import Instrument, InstrumentType
@@ -6,10 +9,11 @@ from wbportfolio.models import InstrumentPortfolioThroughModel, Product, Product
6
9
 
7
10
 
8
11
  def _compute_str(instrument):
9
- if instrument.instrument_type == InstrumentType.PRODUCT_GROUP:
10
- return ProductGroup.objects.get(id=instrument.id).compute_str()
11
- elif instrument.instrument_type == InstrumentType.PRODUCT:
12
- return Product.objects.get(id=instrument.id).compute_str()
12
+ with suppress(ObjectDoesNotExist):
13
+ if instrument.instrument_type == InstrumentType.PRODUCT_GROUP:
14
+ return ProductGroup.objects.get(id=instrument.id).compute_str()
15
+ elif instrument.instrument_type == InstrumentType.PRODUCT:
16
+ return Product.objects.get(id=instrument.id).compute_str()
13
17
  return instrument.get_compute_str()
14
18
 
15
19
 
@@ -35,9 +35,8 @@ from wbcrm.models import AccountRole
35
35
  from wbcrm.models.accounts import Account
36
36
  from wbfdm.models.instruments.instrument_prices import InstrumentPrice
37
37
 
38
- from wbportfolio.models.llm.wbcrm.analyze_relationship import get_performances_prompt
39
-
40
38
  from ..custodians import Custodian
39
+ from ..llm.wbcrm.analyze_relationship import get_performances_prompt
41
40
  from ..roles import PortfolioRole
42
41
  from .trades import Trade
43
42
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbportfolio
3
- Version: 1.50.7
3
+ Version: 1.50.9
4
4
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
5
5
  License-File: LICENSE
6
6
  Requires-Dist: cryptography==3.4.*
@@ -255,15 +255,15 @@ wbportfolio/models/portfolio_cash_targets.py,sha256=WmgG-etPisZsh2yaFQpz7EkpvAud
255
255
  wbportfolio/models/portfolio_relationship.py,sha256=ZGECiPZiLdlk4uSamOrEfuzO0hduK6OMKJLUSnh5_kc,5190
256
256
  wbportfolio/models/portfolio_swing_pricings.py,sha256=_LqYC1VRjnnFFmVqFPRdnbgYsVxocMVpClTk2dnooig,1778
257
257
  wbportfolio/models/product_groups.py,sha256=qoT8qv6tRdD6zmNDxsHO6dtnWw1-TRnyS5NqOq_gwhI,7901
258
- wbportfolio/models/products.py,sha256=5z9OMLVS0ps6aOJbG3JE7gKTf3PlbC4rXIPpv55dD1A,22863
258
+ wbportfolio/models/products.py,sha256=CkI7SBKWXgMkIcaGijZ-ghc_pPq075YjNgH-LWk1XCc,22845
259
259
  wbportfolio/models/registers.py,sha256=qA6T33t4gxFYnabQFBMd90WGIr6wxxirDLKDFqjOfok,4667
260
260
  wbportfolio/models/roles.py,sha256=wF5Atp0xsJxDrYjmFw9XHgEOe_4C-lm4pppeYdymOrA,7343
261
- wbportfolio/models/signals.py,sha256=yDKg2ingDBFQY1oOFpDrMU2C2c0f2aIgRul5UEBqhIs,899
261
+ wbportfolio/models/signals.py,sha256=jZKC43nIqVdLapwo3getIMSqPUwbK5M36MmvA50jY24,1041
262
262
  wbportfolio/models/utils.py,sha256=iBdMjRCvr6aOL0nLgfSCWUKe0h39h3IGmUbYo6l9t6w,394
263
263
  wbportfolio/models/graphs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
264
264
  wbportfolio/models/graphs/portfolio.py,sha256=NwkehWvTcyTYrKO5ku3eNNaYLuBwuLdSbTEuugGuSIU,6541
265
265
  wbportfolio/models/graphs/utils.py,sha256=1AMpEE9mDuUZ82XgN2irxjCW1-LmziROhKevEBo0mJE,2347
266
- wbportfolio/models/llm/wbcrm/analyze_relationship.py,sha256=_y2Myc-M2hXQDkRGXvzsM0ZNC31dmxSHHz5BKMtymww,2106
266
+ wbportfolio/models/llm/wbcrm/analyze_relationship.py,sha256=etKdmt9m6Ra5u7EA9t98RVSqFKpbFd4iwBVaH9T26M8,2320
267
267
  wbportfolio/models/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
268
268
  wbportfolio/models/mixins/instruments.py,sha256=SgBreTpa_X3uyCWo7t8B0VaTtl49IjmBMe4Pab6TjAM,6796
269
269
  wbportfolio/models/mixins/liquidity_stress_test.py,sha256=whkzjtbOyl_ncNyaQBORb_Z_rDgcvfdTYPgqPolu7dA,58865
@@ -272,7 +272,7 @@ wbportfolio/models/reconciliations/account_reconciliation_lines.py,sha256=QP6M7h
272
272
  wbportfolio/models/reconciliations/account_reconciliations.py,sha256=_teOTNePxua9C894auy8CvdOFsmUnQiOM2_TZAHvzY4,3955
273
273
  wbportfolio/models/reconciliations/reconciliations.py,sha256=kF-BNhUoT4TCn1RIgPSkdEk1iX4NQeZlGGFd_ZulAZU,686
274
274
  wbportfolio/models/transactions/__init__.py,sha256=R-4fHylrUf3773kGSEt09vtYj3LUlia5yf7rxHXjvHA,295
275
- wbportfolio/models/transactions/claim.py,sha256=hcx_tJ9luf2-s1qqsUZXtoDEuxFyty2A1rXSDkljoQo,25890
275
+ wbportfolio/models/transactions/claim.py,sha256=XUSephKt-VkILe2i-Sd9aoVxB-50PJANCPIDLa_dKl4,25872
276
276
  wbportfolio/models/transactions/dividends.py,sha256=92-jG8bZN9nU9oDubpu-UDH43Ri7kVjhqE_esOSmOzo,471
277
277
  wbportfolio/models/transactions/expiry.py,sha256=vnNHdcC1hf2HP4rAbmoGgOfagBYKNFytqOwzOI0MlVI,144
278
278
  wbportfolio/models/transactions/fees.py,sha256=ffvqo8I4A0l5rLi00jJ6sGot0jmnkoxaNsbDzdPLwCg,5712
@@ -522,7 +522,7 @@ wbportfolio/viewsets/transactions/rebalancing.py,sha256=6rIrdK0rtKL1afJ-tYfAGdQV
522
522
  wbportfolio/viewsets/transactions/trade_proposals.py,sha256=iQpC_Thbj56SmM05vPRsF1JZguGBDaTUH3I-_iCHCV0,5958
523
523
  wbportfolio/viewsets/transactions/trades.py,sha256=-yJ4j8NJTu2VWyhCq5BXGNND_925Ietoxx9k07SLVh0,21634
524
524
  wbportfolio/viewsets/transactions/transactions.py,sha256=ixDp-nsNA8t_A06rBCT19hOMJHy0iRmdz1XKdV1OwAs,4450
525
- wbportfolio-1.50.7.dist-info/METADATA,sha256=_3QdVIySIlzglfZnVOyVWrGDA7tv9HcUPA6Sy-iT4XY,702
526
- wbportfolio-1.50.7.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
527
- wbportfolio-1.50.7.dist-info/licenses/LICENSE,sha256=jvfVH0SY8_YMHlsJHKe_OajiscQDz4lpTlqT6x24sVw,172
528
- wbportfolio-1.50.7.dist-info/RECORD,,
525
+ wbportfolio-1.50.9.dist-info/METADATA,sha256=ykBmDv1llZ2irZi3thH6lVehwGjZPNVasF7jU4Z06_A,702
526
+ wbportfolio-1.50.9.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
527
+ wbportfolio-1.50.9.dist-info/licenses/LICENSE,sha256=jvfVH0SY8_YMHlsJHKe_OajiscQDz4lpTlqT6x24sVw,172
528
+ wbportfolio-1.50.9.dist-info/RECORD,,