wbportfolio 1.49.4__py2.py3-none-any.whl → 1.49.5__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.

@@ -718,10 +718,13 @@ class Portfolio(DeleteToDisableMixin, WBModel):
718
718
  for rel in PortfolioPortfolioThroughModel.objects.filter(
719
719
  dependency_portfolio=self, type=PortfolioPortfolioThroughModel.Type.PRIMARY, portfolio__is_lookthrough=True
720
720
  ):
721
+ lookthrough_portfolio = rel.portfolio
721
722
  portfolio_total_asset_value = (
722
- self.get_total_asset_under_management(val_date) if not self.only_weighting else None
723
+ self.get_total_asset_under_management(val_date) if not lookthrough_portfolio.only_weighting else None
724
+ )
725
+ lookthrough_portfolio.compute_lookthrough(
726
+ val_date, portfolio_total_asset_value=portfolio_total_asset_value
723
727
  )
724
- rel.portfolio.compute_lookthrough(val_date, portfolio_total_asset_value=portfolio_total_asset_value)
725
728
  for rel in PortfolioPortfolioThroughModel.objects.filter(
726
729
  dependency_portfolio=self, type=PortfolioPortfolioThroughModel.Type.MODEL
727
730
  ):
@@ -922,7 +925,7 @@ class Portfolio(DeleteToDisableMixin, WBModel):
922
925
  positions = []
923
926
  for val_date in pd.date_range(from_date, to_date, freq="B").date:
924
927
  portfolio_total_asset_value = (
925
- self.get_total_asset_under_management(val_date) if not self.only_weighting else None
928
+ self.primary_portfolio.get_total_asset_under_management(val_date) if not self.only_weighting else None
926
929
  )
927
930
  positions.extend(self.primary_portfolio.get_lookthrough_positions(val_date, portfolio_total_asset_value))
928
931
  self.bulk_create_positions(list(positions), delete_leftovers=True, compute_metrics=False)
@@ -685,7 +685,7 @@ class TestPortfolioModel(PortfolioTestMixin):
685
685
  )
686
686
 
687
687
  product_base_portfolio = active_product.primary_portfolio
688
- product_portfolio = portfolio_factory.create(is_lookthrough=True)
688
+ product_portfolio = portfolio_factory.create(is_lookthrough=True, only_weighting=True)
689
689
  instrument_portfolio_through_model_factory.create(instrument=active_product, portfolio=product_portfolio)
690
690
  trade_factory.create(
691
691
  underlying_instrument=active_product,
@@ -766,6 +766,18 @@ class TestPortfolioModel(PortfolioTestMixin):
766
766
  )
767
767
  assert Decimal(1.0) == pytest.approx(product_portfolio.assets.aggregate(s=Sum("weighting"))["s"])
768
768
 
769
+ product_portfolio.is_weighting = True
770
+ product_portfolio.save()
771
+ product_portfolio.compute_lookthrough(weekday, portfolio_total_asset_value=Decimal(1_000_000))
772
+ position = product_portfolio.assets.get(
773
+ portfolio_created=index1_portfolio,
774
+ underlying_instrument=a1_1.underlying_instrument,
775
+ date=weekday,
776
+ )
777
+ assert position.initial_shares == (position.weighting * Decimal(1_000_000)) / (
778
+ position.initial_price * position.initial_currency_fx_rate
779
+ )
780
+
769
781
  def test_estimate_net_asset_values(
770
782
  self,
771
783
  weekday,
@@ -1144,3 +1156,24 @@ class TestPortfolioModel(PortfolioTestMixin):
1144
1156
  )
1145
1157
  expected_returns.index = pd.to_datetime(expected_returns.index)
1146
1158
  pd.testing.assert_frame_equal(returns, expected_returns, check_names=False, check_freq=False, atol=1e-6)
1159
+
1160
+ @patch.object(Portfolio, "get_total_asset_under_management")
1161
+ @patch.object(Portfolio, "compute_lookthrough", autospec=True)
1162
+ def test_handle_controlling_portfolio_change_at_date(
1163
+ self, mock_compute_lookthrough, mock_get_total_asset_under_management, weekday, portfolio_factory
1164
+ ):
1165
+ portfolio_total_asset_value = Decimal(1_000_000)
1166
+ mock_get_total_asset_under_management.return_value = portfolio_total_asset_value
1167
+
1168
+ primary_portfolio = portfolio_factory.create(only_weighting=True)
1169
+ lookthrough_portfolio = portfolio_factory.create(is_lookthrough=True, only_weighting=False)
1170
+ PortfolioPortfolioThroughModel.objects.create(
1171
+ portfolio=lookthrough_portfolio,
1172
+ dependency_portfolio=primary_portfolio,
1173
+ type=PortfolioPortfolioThroughModel.Type.PRIMARY,
1174
+ )
1175
+
1176
+ primary_portfolio.handle_controlling_portfolio_change_at_date(weekday)
1177
+ mock_compute_lookthrough.assert_called_once_with(
1178
+ lookthrough_portfolio, weekday, portfolio_total_asset_value=portfolio_total_asset_value
1179
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbportfolio
3
- Version: 1.49.4
3
+ Version: 1.49.5
4
4
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
5
5
  License-File: LICENSE
6
6
  Requires-Dist: cryptography==3.4.*
@@ -249,7 +249,7 @@ wbportfolio/models/asset.py,sha256=yf4vBPfN1eZlWXG9SowQwr5-goG8rO1yYDitHDLZCBs,3
249
249
  wbportfolio/models/custodians.py,sha256=owTiS2Vm5CRKzh9M_P9GOVg-s-ndQ9UvRmw3yZP7cw0,3815
250
250
  wbportfolio/models/exceptions.py,sha256=3ix0tWUO-O6jpz8f07XIwycw2x3JFRoWzjwil8FVA2Q,52
251
251
  wbportfolio/models/indexes.py,sha256=iLYF2gzNzX4GLj_Nh3fybUcAQ1TslnT0wgQ6mN164QI,728
252
- wbportfolio/models/portfolio.py,sha256=KtuPMWtYoKrIOwp9T_REnOjT9CI2kjtEijF3uA0Twsc,59595
252
+ wbportfolio/models/portfolio.py,sha256=NxJVUtIUxmm_iHnO9UU0_HWmGOwExTz5NZRzHdehhj0,59718
253
253
  wbportfolio/models/portfolio_cash_flow.py,sha256=2blPiXSw7dbhUVd-7LcxDBb4v0SheNOdvRK3MFYiChA,7273
254
254
  wbportfolio/models/portfolio_cash_targets.py,sha256=WmgG-etPisZsh2yaFQpz7EkpvAudKBEzqPsO715w52U,1498
255
255
  wbportfolio/models/portfolio_relationship.py,sha256=mMb18UMRWg9kx_9uIPkMktwORuXXLjKdgRPQQvB6fVE,5486
@@ -374,7 +374,7 @@ wbportfolio/tests/models/test_merge.py,sha256=sdsjiZsmR6vsUKwTa5kkvL6QTeAZqtd_EP
374
374
  wbportfolio/tests/models/test_portfolio_cash_flow.py,sha256=X8dsXexsb1b0lBiuGzu40ps_Az_1UmmKT0eo1vbXH94,5792
375
375
  wbportfolio/tests/models/test_portfolio_cash_targets.py,sha256=q8QWAwt-kKRkLC0E05GyRhF_TTQXIi8bdHjXVU0fCV0,965
376
376
  wbportfolio/tests/models/test_portfolio_swing_pricings.py,sha256=kr2AOcQkyg2pX3ULjU-o9ye-NVpjMrrfoe-DVbYCbjs,1656
377
- wbportfolio/tests/models/test_portfolios.py,sha256=IxJy0fLkUx3m4qKzvkqixYl_0lR7TU-cQJ_DhTkh8V8,52207
377
+ wbportfolio/tests/models/test_portfolios.py,sha256=LFAYrfhEbcDB2fyC0q1TNUy9vWE9oQpqLNKJ5sx_aCw,53872
378
378
  wbportfolio/tests/models/test_product_groups.py,sha256=AcdxhurV-n_bBuUsfD1GqVtwLFcs7VI2CRrwzsIUWbU,3337
379
379
  wbportfolio/tests/models/test_products.py,sha256=nBEgyUoY-4F_pfHYnAr7KXdNYvdIkSu-PWJrqp5tPHg,9482
380
380
  wbportfolio/tests/models/test_roles.py,sha256=4Cn7WyrA2ztJNeWLk5cy9kYo5XLWMbFSvo1O-9JYxeA,3323
@@ -521,7 +521,7 @@ wbportfolio/viewsets/transactions/rebalancing.py,sha256=6rIrdK0rtKL1afJ-tYfAGdQV
521
521
  wbportfolio/viewsets/transactions/trade_proposals.py,sha256=iQpC_Thbj56SmM05vPRsF1JZguGBDaTUH3I-_iCHCV0,5958
522
522
  wbportfolio/viewsets/transactions/trades.py,sha256=xeEzx7GP34aBNPlDmiUmT86labsbb8_f1U2RCN1Jatg,21494
523
523
  wbportfolio/viewsets/transactions/transactions.py,sha256=ixDp-nsNA8t_A06rBCT19hOMJHy0iRmdz1XKdV1OwAs,4450
524
- wbportfolio-1.49.4.dist-info/METADATA,sha256=smy-QwtXQoL-BxaKxICXFKvRxjhBiYcuJ-zwR7b36AM,734
525
- wbportfolio-1.49.4.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
526
- wbportfolio-1.49.4.dist-info/licenses/LICENSE,sha256=jvfVH0SY8_YMHlsJHKe_OajiscQDz4lpTlqT6x24sVw,172
527
- wbportfolio-1.49.4.dist-info/RECORD,,
524
+ wbportfolio-1.49.5.dist-info/METADATA,sha256=5rVe6Q67fXJTmyNtQe8MP7cfiBkqOQ7z-sRlfgU5f-U,734
525
+ wbportfolio-1.49.5.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
526
+ wbportfolio-1.49.5.dist-info/licenses/LICENSE,sha256=jvfVH0SY8_YMHlsJHKe_OajiscQDz4lpTlqT6x24sVw,172
527
+ wbportfolio-1.49.5.dist-info/RECORD,,