diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/Dawn/dawn.py | 42 | ||||
| -rw-r--r-- | python/Dawn/trade_entry.html | 19 |
2 files changed, 47 insertions, 14 deletions
diff --git a/python/Dawn/dawn.py b/python/Dawn/dawn.py index cf702e71..1e951c10 100644 --- a/python/Dawn/dawn.py +++ b/python/Dawn/dawn.py @@ -1,14 +1,18 @@ 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.dialects.postgresql import ENUM, OID from sqlalchemy import create_engine +from wtforms_alchemy import ModelForm +from wtforms import IntegerField +from jinja2 import Environment, FileSystemLoader -Base = declarative_base() +engine = create_engine('postgresql://dawn_user@debian/dawndb') +Base = declarative_base(engine) class Counterparties(Base): __tablename__ = 'counterparties' - code = Column(String(6), primary_key=True) + code = Column(String(12), primary_key=True) name = Column(String) city = Column(String) state = Column(String(2)) @@ -30,22 +34,32 @@ BOND_STRAT = ENUM('M_STR_MAV', 'M_STR_SMEZZ', 'CSO_TRANCH', ASSET_CLASS = ENUM('CSO', 'Subprime', 'CLO', 'Tranches', 'Futures', 'Cash', 'FX', 'Cleared', name='asset_class', metadata=Base.metadata) -class Bonds(Base): +class BondDeal(Base): __tablename__ = 'bonds' - id = Column(Integer, primary_key=True) + 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"), nullable=False) 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) + description = Column(String(32)) + buysell = Column(Boolean, nullable = False) + faceamount = 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) + account = Column(String(10)) + accrued = Column(Float) asset_class = Column(ASSET_CLASS) + ticket = Column(OID, info={'form_field_class': IntegerField}) -engine = create_engine('postgresql://dawn_user@debian/dawndb') -Base.metadata.create_all(engine) +# Base.metadata.create_all(engine) + +class BondForm(ModelForm): + class Meta: + model = BondDeal + +form = BondForm() +jinja_env = Environment(loader = FileSystemLoader(".")) +print(jinja_env.get_template("trade_entry.html").render(form = form)) diff --git a/python/Dawn/trade_entry.html b/python/Dawn/trade_entry.html new file mode 100644 index 00000000..3fb8248a --- /dev/null +++ b/python/Dawn/trade_entry.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> + </head> + <body> + <form class="form-inline" method="POST" action="/submit"> + {% for field in form %} + <div class="form-group"> + <label for="{{ field.id }}" class="sr-only"> + {{ field.label.text }} + </label> + {{ field(class_="form-control") }}</div> + + {% endfor %} +</form> + </body> +</html> |
