diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/Dawn/dawn.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/python/Dawn/dawn.py b/python/Dawn/dawn.py new file mode 100644 index 00000000..cf702e71 --- /dev/null +++ b/python/Dawn/dawn.py @@ -0,0 +1,51 @@ +from sqlalchemy import Table, MetaData, create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy import Boolean, Sequence, Column, Integer, String, Date, Float, ForeignKey +from sqlalchemy.dialects.postgresql import ENUM +from sqlalchemy import create_engine + +Base = declarative_base() + +class Counterparties(Base): + __tablename__ = 'counterparties' + code = Column(String(6), 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 Bonds(Base): + __tablename__ = 'bonds' + id = Column(Integer, primary_key=True) + trade_date = Column(Date, nullable = False) + settle_date = Column(Date, nullable = False) + buysell = Column(Boolean, nullable = False) + cusip = Column(String(9)) + isin = Column(String(12)) + description = Column(String) + notional = Column(Float, nullable=False) + price = Column(Float, nullable=False) + counterparty = Column(String, ForeignKey("counterparties.code"), nullable=False) + strategy = Column(BOND_STRAT, nullable=False) + account = Column(String), + acc_int = Column(Float) + asset_class = Column(ASSET_CLASS) + +engine = create_engine('postgresql://dawn_user@debian/dawndb') +Base.metadata.create_all(engine) |
