wbportfolio 1.51.7__py2.py3-none-any.whl → 1.52.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/transactions/trade_proposals.py +8 -10
- wbportfolio/viewsets/configs/buttons/__init__.py +1 -0
- wbportfolio/viewsets/configs/buttons/trades.py +8 -0
- wbportfolio/viewsets/transactions/trade_proposals.py +1 -0
- wbportfolio/viewsets/transactions/trades.py +2 -0
- {wbportfolio-1.51.7.dist-info → wbportfolio-1.52.1.dist-info}/METADATA +1 -1
- {wbportfolio-1.51.7.dist-info → wbportfolio-1.52.1.dist-info}/RECORD +9 -9
- {wbportfolio-1.51.7.dist-info → wbportfolio-1.52.1.dist-info}/WHEEL +0 -0
- {wbportfolio-1.51.7.dist-info → wbportfolio-1.52.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -5,6 +5,7 @@ from decimal import Decimal
|
|
|
5
5
|
from typing import TypeVar
|
|
6
6
|
|
|
7
7
|
from celery import shared_task
|
|
8
|
+
from django.contrib.messages import info
|
|
8
9
|
from django.core.exceptions import ValidationError
|
|
9
10
|
from django.db import models
|
|
10
11
|
from django.utils.functional import cached_property
|
|
@@ -243,7 +244,6 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
243
244
|
effective_portfolio = self.portfolio._build_dto(last_effective_date)
|
|
244
245
|
if not target_portfolio:
|
|
245
246
|
target_portfolio = self._get_default_target_portfolio()
|
|
246
|
-
|
|
247
247
|
if target_portfolio:
|
|
248
248
|
service = TradingService(
|
|
249
249
|
self.trade_date,
|
|
@@ -251,7 +251,6 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
251
251
|
target_portfolio=target_portfolio,
|
|
252
252
|
)
|
|
253
253
|
if validate_trade:
|
|
254
|
-
service.normalize()
|
|
255
254
|
service.is_valid()
|
|
256
255
|
trades = service.validated_trades
|
|
257
256
|
else:
|
|
@@ -266,6 +265,7 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
266
265
|
try:
|
|
267
266
|
trade = self.trades.get(underlying_instrument=instrument)
|
|
268
267
|
trade.weighting = weighting
|
|
268
|
+
trade.comment = ""
|
|
269
269
|
trade.currency_fx_rate = currency_fx_rate
|
|
270
270
|
trade.status = Trade.Status.DRAFT
|
|
271
271
|
except Trade.DoesNotExist:
|
|
@@ -449,13 +449,7 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
449
449
|
)
|
|
450
450
|
def submit(self, by=None, description=None, **kwargs):
|
|
451
451
|
self.reset_trades(target_portfolio=self._build_dto().convert_to_portfolio())
|
|
452
|
-
trades
|
|
453
|
-
for trade in self.trades.all():
|
|
454
|
-
trade.status = Trade.Status.SUBMIT
|
|
455
|
-
trade.comment = ""
|
|
456
|
-
trades.append(trade)
|
|
457
|
-
|
|
458
|
-
Trade.objects.bulk_update(trades, ["status", "comment"])
|
|
452
|
+
self.trades.update(status=Trade.Status.SUBMIT)
|
|
459
453
|
|
|
460
454
|
# If we estimate cash on this trade proposal, we make sure to create the corresponding cash component
|
|
461
455
|
estimated_cash_position = self.get_estimated_target_cash(self.portfolio.currency)
|
|
@@ -470,7 +464,6 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
470
464
|
estimated_cash_position._build_dto()
|
|
471
465
|
)
|
|
472
466
|
target_portfolio = PortfolioDTO(positions=tuple(target_portfolio.positions_map.values()))
|
|
473
|
-
|
|
474
467
|
self.evaluate_active_rules(self.trade_date, target_portfolio, asynchronously=True)
|
|
475
468
|
|
|
476
469
|
def can_submit(self):
|
|
@@ -543,6 +536,11 @@ class TradeProposal(CloneMixin, RiskCheckMixin, WBModel):
|
|
|
543
536
|
if estimated_cash_position.weighting and len(trades) > 0:
|
|
544
537
|
estimated_cash_position.pre_save()
|
|
545
538
|
assets.append(estimated_cash_position)
|
|
539
|
+
if (fsm_context := getattr(self, "fsm_context", None)) and (request := fsm_context.get("request", None)):
|
|
540
|
+
info(
|
|
541
|
+
request,
|
|
542
|
+
f"We created automatically a cash position of weight {estimated_cash_position.weighting:.2%}",
|
|
543
|
+
)
|
|
546
544
|
|
|
547
545
|
Trade.objects.bulk_update(trades, ["status"])
|
|
548
546
|
self.portfolio.bulk_create_positions(
|
|
@@ -16,6 +16,7 @@ from .registers import RegisterButtonConfig
|
|
|
16
16
|
from .trades import (
|
|
17
17
|
TradeButtonConfig,
|
|
18
18
|
TradeInstrumentButtonConfig,
|
|
19
|
+
TradeTradeProposalButtonConfig
|
|
19
20
|
)
|
|
20
21
|
from .trade_proposals import TradeProposalButtonConfig
|
|
21
22
|
from .reconciliations import AccountReconciliationButtonViewConfig, AccountReconciliationLineButtonViewConfig
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from rest_framework.reverse import reverse
|
|
2
2
|
from wbcore.contrib.icons import WBIcon
|
|
3
3
|
from wbcore.metadata.configs import buttons as bt
|
|
4
|
+
from wbcore.metadata.configs.buttons.enums import Button
|
|
4
5
|
from wbcore.metadata.configs.buttons.view_config import ButtonViewConfig
|
|
5
6
|
from wbfdm.models import Instrument
|
|
6
7
|
|
|
@@ -58,3 +59,10 @@ class TradeInstrumentButtonConfig(TradeButtonConfig):
|
|
|
58
59
|
)
|
|
59
60
|
)
|
|
60
61
|
return res
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class TradeTradeProposalButtonConfig(ButtonViewConfig):
|
|
65
|
+
def get_create_buttons(self):
|
|
66
|
+
return {
|
|
67
|
+
Button.SAVE_AND_CLOSE.value,
|
|
68
|
+
}
|
|
@@ -98,6 +98,7 @@ class TradeProposalModelViewSet(CloneMixin, RiskCheckViewSetMixin, InternalUserP
|
|
|
98
98
|
def reset(self, request, pk=None):
|
|
99
99
|
trade_proposal = get_object_or_404(TradeProposal, pk=pk)
|
|
100
100
|
if trade_proposal.status == TradeProposal.Status.DRAFT:
|
|
101
|
+
trade_proposal.trades.all().delete()
|
|
101
102
|
trade_proposal.reset_trades()
|
|
102
103
|
return Response({"send": True})
|
|
103
104
|
return Response({"status": "Trade proposal is not Draft"}, status=status.HTTP_400_BAD_REQUEST)
|
|
@@ -64,6 +64,7 @@ from ..configs import (
|
|
|
64
64
|
TradePortfolioEndpointConfig,
|
|
65
65
|
TradePortfolioTitleConfig,
|
|
66
66
|
TradeTitleConfig,
|
|
67
|
+
TradeTradeProposalButtonConfig,
|
|
67
68
|
TradeTradeProposalDisplayConfig,
|
|
68
69
|
TradeTradeProposalEndpointConfig,
|
|
69
70
|
)
|
|
@@ -388,6 +389,7 @@ class TradeTradeProposalModelViewSet(
|
|
|
388
389
|
display_config_class = TradeTradeProposalDisplayConfig
|
|
389
390
|
endpoint_config_class = TradeTradeProposalEndpointConfig
|
|
390
391
|
serializer_class = TradeTradeProposalModelSerializer
|
|
392
|
+
button_config_class = TradeTradeProposalButtonConfig
|
|
391
393
|
|
|
392
394
|
@cached_property
|
|
393
395
|
def trade_proposal(self):
|
|
@@ -283,7 +283,7 @@ wbportfolio/models/transactions/dividends.py,sha256=92-jG8bZN9nU9oDubpu-UDH43Ri7
|
|
|
283
283
|
wbportfolio/models/transactions/expiry.py,sha256=vnNHdcC1hf2HP4rAbmoGgOfagBYKNFytqOwzOI0MlVI,144
|
|
284
284
|
wbportfolio/models/transactions/fees.py,sha256=ffvqo8I4A0l5rLi00jJ6sGot0jmnkoxaNsbDzdPLwCg,5712
|
|
285
285
|
wbportfolio/models/transactions/rebalancing.py,sha256=obzgewWKOD4kJbCoF5fhtfDk502QkbrjPKh8T9KDGew,7355
|
|
286
|
-
wbportfolio/models/transactions/trade_proposals.py,sha256=
|
|
286
|
+
wbportfolio/models/transactions/trade_proposals.py,sha256=o6yMqfE5XavUY-kocf2P9DF-VZQbf8vJCiGrpbr-D6M,31313
|
|
287
287
|
wbportfolio/models/transactions/trades.py,sha256=JBy89HPSMa-jDxIHcDfxNyWFHTjThcnSNY_OcWxZNoc,29188
|
|
288
288
|
wbportfolio/models/transactions/transactions.py,sha256=fWoDf0TSV0L0gLUDOQpCRLzjMt1H4MUvUHGEaMsilCc,7027
|
|
289
289
|
wbportfolio/pms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -428,7 +428,7 @@ wbportfolio/viewsets/signals.py,sha256=URxNz-7tKNBgvaFIE3FItfao3Md0dKQN_eVFwxxiE
|
|
|
428
428
|
wbportfolio/viewsets/charts/__init__.py,sha256=mNSpDrsqK-afRxGBfEsfgupUc20xU-JW08FpxIyudok,71
|
|
429
429
|
wbportfolio/viewsets/charts/assets.py,sha256=rZM4Ul0ZXVr7uz3SU44J5IYU7-FivjDgR1it_4ewk2o,10547
|
|
430
430
|
wbportfolio/viewsets/configs/__init__.py,sha256=K5opfVQvgGwSyw3XwDGkv3lo5i9jBxOJXYhLqyCdfeQ,137
|
|
431
|
-
wbportfolio/viewsets/configs/buttons/__init__.py,sha256=
|
|
431
|
+
wbportfolio/viewsets/configs/buttons/__init__.py,sha256=nqXdv0VEG8MM8IKHHf2PDAulYVinCuvmic5Ru03jVBw,881
|
|
432
432
|
wbportfolio/viewsets/configs/buttons/adjustments.py,sha256=sUY_3vxqP0kuqs8i5hklfboZI6QiAOrmu30eb29Xupo,492
|
|
433
433
|
wbportfolio/viewsets/configs/buttons/assets.py,sha256=6HqSyUpczK66iL0Jg8BbvAJuci3jm8OsB9p9Nt_o14Q,5680
|
|
434
434
|
wbportfolio/viewsets/configs/buttons/claims.py,sha256=G1GFK1jQyR9M0dyXthYA6krG2JFvHhc3D7pFh6IUQ30,3684
|
|
@@ -441,7 +441,7 @@ wbportfolio/viewsets/configs/buttons/reconciliations.py,sha256=lw4r22GHpqKPUF1Mr
|
|
|
441
441
|
wbportfolio/viewsets/configs/buttons/registers.py,sha256=aS89TsYHql83k-NHojOrLDqtBpnpsUUO8x63PiMfrXM,445
|
|
442
442
|
wbportfolio/viewsets/configs/buttons/signals.py,sha256=6sKBQI_eDvZuZR5bUUwvur5R67A3oChAGxPfayWUelE,2739
|
|
443
443
|
wbportfolio/viewsets/configs/buttons/trade_proposals.py,sha256=eZBfYk5ZhancCVcu7bvRKPGBKTl_tGlgz6BZrGPpPxQ,2953
|
|
444
|
-
wbportfolio/viewsets/configs/buttons/trades.py,sha256=
|
|
444
|
+
wbportfolio/viewsets/configs/buttons/trades.py,sha256=bPOqqwdgadSUbU9l5aSirqr5UAMFe2AiFNsXLRsKwn8,2535
|
|
445
445
|
wbportfolio/viewsets/configs/display/__init__.py,sha256=SmazY-YEp-Xf8G08Uz1-CzePZRCRtHrziRMIYYIGpCk,2176
|
|
446
446
|
wbportfolio/viewsets/configs/display/adjustments.py,sha256=jIOEc23OCYBguLaZRlZxC916kocYT35ZV9Jsiocs9nk,3334
|
|
447
447
|
wbportfolio/viewsets/configs/display/assets.py,sha256=SkWwzvrn4gOVbCThGJMV63V-iJh517qfUs4f4Wt3dBA,10573
|
|
@@ -525,10 +525,10 @@ wbportfolio/viewsets/transactions/claim.py,sha256=Pb1WftoO-w-ZSTbLRhmQubhy7hgd68
|
|
|
525
525
|
wbportfolio/viewsets/transactions/fees.py,sha256=7VUXIogmRrXCz_D9tvDiiTae0t5j09W9zPUzxXzBGTE,7031
|
|
526
526
|
wbportfolio/viewsets/transactions/mixins.py,sha256=WipvJoi5hylkpD0y9VATe30WAcwIHUIroVkK10FYw7k,636
|
|
527
527
|
wbportfolio/viewsets/transactions/rebalancing.py,sha256=6rIrdK0rtKL1afJ-tYfAGdQVTN2MH1kG_yCeVkmyK8k,1263
|
|
528
|
-
wbportfolio/viewsets/transactions/trade_proposals.py,sha256=
|
|
529
|
-
wbportfolio/viewsets/transactions/trades.py,sha256
|
|
528
|
+
wbportfolio/viewsets/transactions/trade_proposals.py,sha256=rCJoJSL11qpjxciX25Q5ZU3ewELyyDBUPXcj4Z88Vdg,6037
|
|
529
|
+
wbportfolio/viewsets/transactions/trades.py,sha256=wCyTTyVKjYuMRsrFcmwD3_yggWxCNm-mdoYzVnhGP0U,21727
|
|
530
530
|
wbportfolio/viewsets/transactions/transactions.py,sha256=ixDp-nsNA8t_A06rBCT19hOMJHy0iRmdz1XKdV1OwAs,4450
|
|
531
|
-
wbportfolio-1.
|
|
532
|
-
wbportfolio-1.
|
|
533
|
-
wbportfolio-1.
|
|
534
|
-
wbportfolio-1.
|
|
531
|
+
wbportfolio-1.52.1.dist-info/METADATA,sha256=uubsZOzJQrVgjTFOgljan267Y_G6ufoynoPcmCy19MY,702
|
|
532
|
+
wbportfolio-1.52.1.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
|
533
|
+
wbportfolio-1.52.1.dist-info/licenses/LICENSE,sha256=jvfVH0SY8_YMHlsJHKe_OajiscQDz4lpTlqT6x24sVw,172
|
|
534
|
+
wbportfolio-1.52.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|