diff options
Diffstat (limited to 'python/Dawn/models.py')
| -rw-r--r-- | python/Dawn/models.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/python/Dawn/models.py b/python/Dawn/models.py new file mode 100644 index 00000000..efcd2703 --- /dev/null +++ b/python/Dawn/models.py @@ -0,0 +1,52 @@ +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy import Boolean, Sequence, Column, Integer, String, Date, Float, ForeignKey +from sqlalchemy.dialects.postgresql import ENUM, OID +from wtforms import FileField, SelectField +import datetime + +Base = declarative_base() + +class Counterparties(Base): + __tablename__ = 'counterparties' + code = Column(String(12), primary_key=True) + name = Column(String) + city = Column(String) + state = Column(String(2)) + dtc_number = Column(Integer) + sales_contact = Column(String) + sales_email = Column(String) + sales_phone = Column(String) + valuation_contact1 = Column(String) + valuation_email1 = Column(String) + valuation_contact2 = Column(String) + valuation_email2 = Column(String) + valuation_contact3 = Column(String) + valuation_email3 = Column(String) + notes = Column(String) + +BOND_STRAT = ENUM('M_STR_MAV', 'M_STR_SMEZZ', 'CSO_TRANCH', + 'M_CLO_BB20', 'M_CLO_AAA', 'M_CLO_BBB', 'M_MTG_IO', 'M_MTG_THRU', + 'M_MTG_GOOD', 'M_MTG_B4PR', 'M_MTG_RW', name='bond_strat', metadata=Base.metadata) +ASSET_CLASS = ENUM('CSO', 'Subprime', 'CLO', 'Tranches', 'Futures', 'Cash', 'FX', 'Cleared', + name='asset_class', metadata=Base.metadata) + +class BondDeal(Base): + __tablename__ = 'bonds' + dealid = Column(String(28), primary_key=True) + folder = Column(BOND_STRAT, nullable=False) + custodian = Column(String(12), nullable=False) + cashaccount = Column(String(10), nullable=False) + counterparty = Column(String, ForeignKey("counterparties.code"), + info={'choices': [(None, None)]}) + trade_date = Column(Date, nullable = False, default = datetime.date.today) + settle_date = Column(Date, nullable = False, default = datetime.date.today) + cusip = Column(String(9)) + isin = Column(String(12)) + description = Column(String(32)) + buysell = Column(Boolean, nullable = False, info={'choices':[(0, 'sell'), (1, 'buy')]}) + faceamount = Column(Float, nullable=False) + price = Column(Float, nullable=False) + account = Column(String(10)) + accrued = Column(Float) + asset_class = Column(ASSET_CLASS) + ticket = Column(OID, info={'form_field_class': FileField}) |
