aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn')
-rw-r--r--python/Dawn/models.py77
1 files changed, 75 insertions, 2 deletions
diff --git a/python/Dawn/models.py b/python/Dawn/models.py
index fdfff8fd..10f1b042 100644
--- a/python/Dawn/models.py
+++ b/python/Dawn/models.py
@@ -1,4 +1,4 @@
-from flask.ext.sqlalchemy import SQLAlchemy
+from flask_sqlalchemy import SQLAlchemy
from flask_wtf import Form
from flask_wtf.file import FileField
from sqlalchemy.dialects.postgresql import ENUM
@@ -37,7 +37,18 @@ BOND_STRAT = ENUM('M_STR_MAV', 'M_STR_MEZZ', 'CSO_TRANCH',
CDS_STRAT = ENUM('HEDGE_CSO', 'HEDGE_CLO', 'HEDGE_MAC', 'HEDGE_MBS',
'SER_IGSNR', 'SER_IGMEZ', 'SER_IGEQY', 'SER_IGINX', 'SER_HYSNR',
- 'SER_HYMEZ', 'SER_HYEQY', 'SER_HYINX', 'SER_IGCURVE', 'MBSCDS', name='cds_strat')
+ 'SER_HYMEZ', 'SER_HYEQY', 'SER_HYINX', 'SER_IGCURVE', 'MBSCDS',
+ 'IGOPTDEL', 'HYOPTDEL', name='cds_strat')
+
+SWAPTION_STRAT = ENUM('IGPAYER', 'IGREC', 'HYPAYER', 'HYREC',
+ name='swaption_strat')
+
+SWAPTION_TYPE = ENUM('PAYER', 'RECEIVER',
+ name='swaption_type')
+
+REPO_TYPE = ENUM('REPO', 'REVERSE REPO', name='repo_type')
+CALL_NOTICE = ENUM('24H', '48H', '3D', '4D', '5D', '6D',
+ '1W', '8D', '9D', '10D', '2W', '1M', '2M', name='call_notice')
ASSET_CLASS = ENUM('CSO', 'Subprime', 'CLO', 'Tranches', 'Futures', 'Cash', 'FX', 'Cleared',
name='asset_class')
@@ -128,6 +139,68 @@ class CDSDeal(db.Model):
__table_args__ = (db.CheckConstraint("swap_type!='CD_INDEX_TRANCHE' or " \
"(attach is not NULL and detach is not NULL)"),)
+class RepoDeal(db.Model):
+ __tablename__ = 'repo'
+ id = db.Column('id', db.Integer, primary_key=True)
+ lastupdate = db.Column(db.DateTime, server_default=db.func.now(), onupdate=db.func.now())
+ action = db.Column(ACTION)
+ folder = db.Column(CDS_STRAT, nullable = False)
+ custodian = db.Column(db.String(12), default='ML', nullable=False)
+ cashaccount = db.Column(db.String(10), default='MLNSCLMASW', nullable=False)
+ cp_code = db.Column(db.String(12), db.ForeignKey('counterparties.code'),
+ info={'choices': [(None, '')],
+ 'label': 'counterparty'}, nullable = False)
+ trade_date = db.Column(db.Date, nullable = False)
+ settle_date = db.Column(db.Date, nullable = False)
+ cusip = db.Column(db.String(9), info={'validators': Length(9,9),
+ 'filters': [lambda x: x or None,],
+ 'trim': True})
+ isin = db.Column(db.String(12), info={'validators': Length(12, 12),
+ 'filters': [lambda x: x or None,],
+ 'trim': True})
+ identifier = db.Column(db.String(12), info={'filters': [lambda x: x or None,],
+ 'trim': True})
+ description = db.Column(db.String(32), nullable = False, info={'trim': True})
+ transation_indicator = db.Column(REPO_TYPE)
+ faceamount = db.Column(db.Float, nullable = False)
+ price = db.Column(db.Float, nullable = False)
+ currency = db.Column(CCY, nullable = False)
+ expiration_date = db.Column(db.Date)
+ weighted_amount = db.Column(db.Float)
+ haircut = db.Column(db.Float)
+ repo_rate = db.Column(db.Float, nullable = False)
+ call_notice = db.Column(CALL_NOTICE)
+ daycount = db.Column(DAY_COUNT)
+ ticket = db.Column(db.String, info={'form_field_class': FileField})
+ __table__args = (db.CheckConstraint("haircut is not NULL and weighted_amount is NULL) or " \
+ "haircut is NULL and weighted_amount is NOT NULL)"),
+ db.CheckConstraint("cusip is NOT NULL or isin is NOT NULL"))
+
+class SwaptionDeal(db.Model):
+ __tablename__ = 'swaptions'
+ id = db.Column('id', db.Integer, primary_key=True)
+ dealid = db.Column(db.String(28))
+ lastupdate = db.Column(db.DateTime, server_default=db.func.now(), onupdate=db.func.now())
+ action = db.Column(ACTION)
+ folder = db.Column(SWAPTION_STRAT, nullable = False)
+ custodian = db.Column(db.String(12), default='NONE', nullable=False)
+ cashaccount = db.Column(db.String(10), default='MLNSCLMASW', nullable=False)
+ cp_code = db.Column(db.String(12), db.ForeignKey('counterparties.code'),
+ info={'choices': [(None, '')],
+ 'label': 'counterparty'}, nullable = False)
+ trade_date = db.Column(db.Date, nullable = False)
+ settle_date = db.Column(db.Date, nullable = False)
+ buysell = db.Column(db.Boolean, nullable = False, info={'choices':[(0, 'sell'), (1, 'buy')],
+ 'coerce': lambda x: bool(int(x)) \
+ if x is not None else x})
+ notional = db.Column(db.Float, nullable = False)
+ swaption_type = db.Column(SWAPTION_TYPE, nullable = False)
+ price = db.Column(db.Float, nullable = False)
+ expiration_date = db.Column(db.Date, nullable = False)
+ security_id = db.Column(db.String(12), nullable = False)
+ security_desc = db.Column(db.String(32), nullable = False)
+ counterparty = db.relationship(Counterparties)
+
BaseModelForm = model_form_factory(Form)
class ModelForm(BaseModelForm):
@classmethod