diff options
Diffstat (limited to 'python/Dawn/views.py')
| -rw-r--r-- | python/Dawn/views.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py index 3aa374ac..c427e97c 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, - Counterparties, Accounts) + CapFloorDeal, Counterparties, Accounts) from sqlalchemy.exc import IntegrityError from wtforms.fields import BooleanField @@ -36,7 +36,7 @@ def cp_choices(kind='bond'): with_entities(Counterparties.code, Counterparties.name)) elif kind == 'future': return [] - elif kind == 'cds' or kind == 'swaption': + elif kind in ['cds', 'swaption', 'capfloor']: return (Counterparties.query. order_by('name'). filter(Counterparties.name.ilike('%CDS%')). @@ -117,6 +117,14 @@ class FutureForm(ModelForm): include_foreign_keys = True exclude = ['dealid', 'lastupdate'] +class CapFloorForm(ModelForm): + upload_globeop = BooleanField(label="Upload to globeop?") + + class Meta: + model = CapFloorDeal + include_foreign_keys = True + exclude = ['dealid', 'lastupdate', 'termination_amount', + 'termination_cp', 'termination_date'] def get_deal(kind): if kind == 'cds': @@ -129,6 +137,8 @@ def get_deal(kind): return FutureDeal elif kind == 'wire': return CashFlowDeal + elif kind == 'capfloor': + return CapFloorDeal else: raise RuntimeError(f'Unknown Deal type: {kind}') @@ -142,6 +152,8 @@ def _get_form(kind): return SwaptionForm elif kind == 'future': return FutureForm + elif kind == 'capfloor': + return CapFloorForm else: raise RuntimeError('Unknown Deal type') @@ -389,11 +401,14 @@ def get_bbg_id(): tenor = tenor[:-1] + 'yr' series = int(series[1:]) sqlstr1 = "SELECT * FROM index_redcode(%s::index_type, %s::smallint, %s)" - sqlstr2 = "SELECT maturity, coupon FROM index_maturity WHERE index=%s and series=%s and tenor=%s" + sqlstr2 = ("SELECT maturity, coupon FROM index_maturity WHERE index=%s " + "and series=%s and tenor=%s") db = get_db() with db.cursor() as c: c.execute(sqlstr1, (indextype, series, pd.datetime.today().date())) (redcode,) = c.fetchone() c.execute(sqlstr2, (indextype, series, tenor)) maturity, coupon = c.fetchone() - return jsonify({'maturity': maturity.strftime('%Y-%m-%d'), 'redcode': redcode, 'coupon': coupon}) + return jsonify({'maturity': maturity.strftime('%Y-%m-%d'), + 'redcode': redcode, + 'coupon': coupon}) |
