wbportfolio 1.50.0__py2.py3-none-any.whl → 1.50.1__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.
- wbportfolio/models/asset.py +2 -2
- wbportfolio/models/transactions/trade_proposals.py +1 -1
- wbportfolio/models/transactions/trades.py +23 -23
- {wbportfolio-1.50.0.dist-info → wbportfolio-1.50.1.dist-info}/METADATA +1 -1
- {wbportfolio-1.50.0.dist-info → wbportfolio-1.50.1.dist-info}/RECORD +7 -7
- {wbportfolio-1.50.0.dist-info → wbportfolio-1.50.1.dist-info}/WHEEL +0 -0
- {wbportfolio-1.50.0.dist-info → wbportfolio-1.50.1.dist-info}/licenses/LICENSE +0 -0
wbportfolio/models/asset.py
CHANGED
|
@@ -185,8 +185,8 @@ class AssetPositionIterator:
|
|
|
185
185
|
return dict(self._weights)
|
|
186
186
|
|
|
187
187
|
def __iter__(self):
|
|
188
|
-
# return an iterable excluding the position
|
|
189
|
-
yield from filter(lambda a: a.weighting, self.positions.values())
|
|
188
|
+
# return an iterable excluding the position with a null weight if the portfolio is manageable (otherwise, we assume the 0-weight position is valid)
|
|
189
|
+
yield from filter(lambda a: not a.portfolio.is_manageable or a.weighting, self.positions.values())
|
|
190
190
|
|
|
191
191
|
def __getitem__(self, item: tuple[date, Instrument]) -> float:
|
|
192
192
|
return self._weights[item[0]][item[1].id]
|
|
@@ -524,7 +524,7 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
524
524
|
|
|
525
525
|
for trade in self.trades.all():
|
|
526
526
|
with suppress(ValueError):
|
|
527
|
-
asset = trade.
|
|
527
|
+
asset = trade.get_asset()
|
|
528
528
|
# we add the corresponding asset only if it is not the cache position (already included in estimated_cash_position)
|
|
529
529
|
if asset.underlying_quote != estimated_cash_position.underlying_quote:
|
|
530
530
|
assets.append(asset)
|
|
@@ -299,31 +299,9 @@ class Trade(ShareMixin, Transaction, OrderedModel, WBModel):
|
|
|
299
299
|
)
|
|
300
300
|
},
|
|
301
301
|
)
|
|
302
|
-
def to_asset(self) -> AssetPosition:
|
|
303
|
-
last_underlying_quote_price = self.last_underlying_quote_price
|
|
304
|
-
if not last_underlying_quote_price:
|
|
305
|
-
raise ValueError("No price found")
|
|
306
|
-
asset = AssetPosition(
|
|
307
|
-
underlying_quote=self.underlying_instrument,
|
|
308
|
-
portfolio_created=None,
|
|
309
|
-
portfolio=self.portfolio,
|
|
310
|
-
date=self.transaction_date,
|
|
311
|
-
initial_currency_fx_rate=self.currency_fx_rate,
|
|
312
|
-
weighting=self._target_weight,
|
|
313
|
-
initial_price=self.last_underlying_quote_price.net_value,
|
|
314
|
-
initial_shares=None,
|
|
315
|
-
underlying_quote_price=self.last_underlying_quote_price,
|
|
316
|
-
asset_valuation_date=self.transaction_date,
|
|
317
|
-
currency=self.currency,
|
|
318
|
-
is_estimated=False,
|
|
319
|
-
)
|
|
320
|
-
asset.set_weighting(self._target_weight)
|
|
321
|
-
asset.pre_save()
|
|
322
|
-
return asset
|
|
323
|
-
|
|
324
302
|
def execute(self, **kwargs):
|
|
325
303
|
with suppress(ValueError):
|
|
326
|
-
asset = self.
|
|
304
|
+
asset = self.get_asset()
|
|
327
305
|
AssetPosition.unannotated_objects.update_or_create(
|
|
328
306
|
underlying_quote=asset.underlying_quote,
|
|
329
307
|
portfolio_created=asset.portfolio_created,
|
|
@@ -570,6 +548,28 @@ class Trade(ShareMixin, Transaction, OrderedModel, WBModel):
|
|
|
570
548
|
|
|
571
549
|
"""
|
|
572
550
|
|
|
551
|
+
def get_asset(self) -> AssetPosition:
|
|
552
|
+
last_underlying_quote_price = self.last_underlying_quote_price
|
|
553
|
+
if not last_underlying_quote_price:
|
|
554
|
+
raise ValueError("No price found")
|
|
555
|
+
asset = AssetPosition(
|
|
556
|
+
underlying_quote=self.underlying_instrument,
|
|
557
|
+
portfolio_created=None,
|
|
558
|
+
portfolio=self.portfolio,
|
|
559
|
+
date=self.transaction_date,
|
|
560
|
+
initial_currency_fx_rate=self.currency_fx_rate,
|
|
561
|
+
weighting=self._target_weight,
|
|
562
|
+
initial_price=self.last_underlying_quote_price.net_value,
|
|
563
|
+
initial_shares=None,
|
|
564
|
+
underlying_quote_price=self.last_underlying_quote_price,
|
|
565
|
+
asset_valuation_date=self.transaction_date,
|
|
566
|
+
currency=self.currency,
|
|
567
|
+
is_estimated=False,
|
|
568
|
+
)
|
|
569
|
+
asset.set_weighting(self._target_weight)
|
|
570
|
+
asset.pre_save()
|
|
571
|
+
return asset
|
|
572
|
+
|
|
573
573
|
def delete(self, **kwargs):
|
|
574
574
|
pre_collection.send(sender=self.__class__, instance=self)
|
|
575
575
|
super().delete(**kwargs)
|
|
@@ -245,7 +245,7 @@ wbportfolio/migrations/0076_alter_dividendtransaction_price_and_more.py,sha256=4
|
|
|
245
245
|
wbportfolio/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
246
246
|
wbportfolio/models/__init__.py,sha256=IIS_PNRxyX2Dcvyk1bcQOUzFt0B9SPC0WlM88CXqj04,881
|
|
247
247
|
wbportfolio/models/adjustments.py,sha256=osXWkJZOiansPWYPyHtl7Z121zDWi7u1YMtrBQtbHVo,10272
|
|
248
|
-
wbportfolio/models/asset.py,sha256
|
|
248
|
+
wbportfolio/models/asset.py,sha256=wwAWW2vl21nJS7RVswjvB1PAZRjJ1VzCyLF4fb7R0Gw,45264
|
|
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
|
|
@@ -276,8 +276,8 @@ wbportfolio/models/transactions/dividends.py,sha256=92-jG8bZN9nU9oDubpu-UDH43Ri7
|
|
|
276
276
|
wbportfolio/models/transactions/expiry.py,sha256=vnNHdcC1hf2HP4rAbmoGgOfagBYKNFytqOwzOI0MlVI,144
|
|
277
277
|
wbportfolio/models/transactions/fees.py,sha256=ffvqo8I4A0l5rLi00jJ6sGot0jmnkoxaNsbDzdPLwCg,5712
|
|
278
278
|
wbportfolio/models/transactions/rebalancing.py,sha256=obzgewWKOD4kJbCoF5fhtfDk502QkbrjPKh8T9KDGew,7355
|
|
279
|
-
wbportfolio/models/transactions/trade_proposals.py,sha256=
|
|
280
|
-
wbportfolio/models/transactions/trades.py,sha256=
|
|
279
|
+
wbportfolio/models/transactions/trade_proposals.py,sha256=qUuCftA7iPLprSVSM7Opkf4hgWxhE-WivRkVWIaFzBw,30541
|
|
280
|
+
wbportfolio/models/transactions/trades.py,sha256=4qA0cEff_hcV3kMnmJKXr0wSThpKhhm0HbzHbspBuxw,28919
|
|
281
281
|
wbportfolio/models/transactions/transactions.py,sha256=fWoDf0TSV0L0gLUDOQpCRLzjMt1H4MUvUHGEaMsilCc,7027
|
|
282
282
|
wbportfolio/pms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
283
283
|
wbportfolio/pms/typing.py,sha256=b2pBWYt1E8ok-Kqm0lEFIakSnWJ6Ib57z-VX3C3gkQc,6081
|
|
@@ -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=-yJ4j8NJTu2VWyhCq5BXGNND_925Ietoxx9k07SLVh0,21634
|
|
523
523
|
wbportfolio/viewsets/transactions/transactions.py,sha256=ixDp-nsNA8t_A06rBCT19hOMJHy0iRmdz1XKdV1OwAs,4450
|
|
524
|
-
wbportfolio-1.50.
|
|
525
|
-
wbportfolio-1.50.
|
|
526
|
-
wbportfolio-1.50.
|
|
527
|
-
wbportfolio-1.50.
|
|
524
|
+
wbportfolio-1.50.1.dist-info/METADATA,sha256=Yi-dunYxBzs9RvSKEaW9q4m6NkFz9WvbeNf9gWUSJfY,734
|
|
525
|
+
wbportfolio-1.50.1.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
|
526
|
+
wbportfolio-1.50.1.dist-info/licenses/LICENSE,sha256=jvfVH0SY8_YMHlsJHKe_OajiscQDz4lpTlqT6x24sVw,172
|
|
527
|
+
wbportfolio-1.50.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|