1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)
|