diff options
Diffstat (limited to 'python/Dawn/views.py')
| -rw-r--r-- | python/Dawn/views.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py index 97873eaf..3cecf2b5 100644 --- a/python/Dawn/views.py +++ b/python/Dawn/views.py @@ -10,7 +10,7 @@ from flask import (abort, request, render_template, redirect, from .models import (ModelForm, CASH_STRAT, CCY, BondDeal, CDSDeal, SwaptionDeal, FutureDeal, CashFlowDeal, - CapFloorDeal, Counterparties, Accounts) + CapFloorDeal, SpotDeal, Counterparties, Accounts) from sqlalchemy.exc import IntegrityError from wtforms.fields import BooleanField @@ -34,7 +34,7 @@ def cp_choices(kind='bond'): if kind == 'bond': return (Counterparties.query.order_by('name'). with_entities(Counterparties.code, Counterparties.name)) - elif kind == 'future': + elif kind in ['future', 'spot']: return [] elif kind in ['cds', 'swaption', 'capfloor']: return (Counterparties.query. @@ -123,6 +123,14 @@ class FutureForm(ModelForm): include_foreign_keys = True exclude = ['dealid', 'lastupdate'] +class SpotForm(ModelForm): + upload_globeop = BooleanField(label="Upload to globeop?") + + class Meta: + model = SpotDeal + include_foreign_keys = True + exclude = ['dealid', 'lastupdate'] + class CapFloorForm(ModelForm): upload_globeop = BooleanField(label="Upload to globeop?") @@ -147,6 +155,8 @@ def get_deal(kind): return CashFlowDeal elif kind == 'capfloor': return CapFloorDeal + elif kind == 'spot': + return SpotDeal else: raise RuntimeError(f'Unknown Deal type: {kind}') @@ -162,6 +172,8 @@ def _get_form(kind): return FutureForm elif kind == 'capfloor': return CapFloorForm + elif kind == 'spot': + return SpotForm else: raise RuntimeError('Unknown Deal type') @@ -179,6 +191,9 @@ def get_form(trade, kind): upfront_settle_date=today.date() + 3 * bus_day) if kind == 'cds': form.account_code.choices = fcm_accounts() + elif kind == 'spot': + form = Form(trade_date=today.date(), + settlement_date=today.date() + 2 * bus_day) else: form = Form(trade_date=today.date(), settle_date=today.date() + 2 * bus_day) |
