You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document describes the Django ORM models, their fields, relationships,
and the constraints enforced at the database level.
Entity Relationship Summary
Bond (1) ----< (0..*) CallSchedule
Bond (1) ----< (0..*) Position
Portfolio (1) ----< (1..*) Position
YieldCurve (1) ----< (2..*) CurveDataPoint
Bond
Table:bonds_bond
Stores the economic terms of a fixed income instrument. Analytics (price,
duration, yield) are computed on demand from stored terms and are never
persisted.
Column
Type
Nullable
Default
Description
id
UUID
No
uuid4()
Primary key
isin
VARCHAR(12)
Yes
NULL
ISO 6166 ISIN, unique
name
VARCHAR(255)
No
-
Bond display name
issuer
VARCHAR(255)
No
-
Issuing entity
face_value
DECIMAL(18,6)
No
1000.000000
Par value
coupon_rate
DECIMAL(10,8)
No
-
Annual rate as decimal
maturity_date
DATE
No
-
Final maturity
issue_date
DATE
No
-
Original issue date
settlement_date
DATE
Yes
NULL
Optional settlement date override
coupon_frequency
VARCHAR(20)
No
semiannual
Payment frequency
bond_type
VARCHAR(20)
No
fixed
Instrument type
day_count
VARCHAR(20)
No
actual/actual
Day count convention
currency
VARCHAR(3)
No
USD
ISO 4217 currency code
credit_rating
VARCHAR(10)
Yes
NULL
Credit rating string
sector
VARCHAR(100)
Yes
NULL
Industry sector
description
TEXT
Yes
NULL
Free-text notes
created_at
TIMESTAMP
No
NOW()
Record creation time
updated_at
TIMESTAMP
No
NOW()
Last modification time
Enumerated Values
coupon_frequency
Value
Label
annual
Annual
semiannual
Semi-Annual
quarterly
Quarterly
monthly
Monthly
zero
Zero (Discount)
bond_type
Value
Label
fixed
Fixed Rate
floating
Floating Rate
zero_coupon
Zero Coupon
inflation_linked
Inflation Linked
callable
Callable
day_count
Value
Label
actual/actual
Actual/Actual
actual/360
Actual/360
actual/365
Actual/365
30/360
30/360
Constraints
Constraint
Rule
maturity_after_issue
maturity_date must be strictly after issue_date
isin_format
Must match [A-Z]{2}[A-Z0-9]{9}[0-9]
zero_coupon_rate
Zero coupon bonds must have coupon_rate = 0
coupon_rate_range
0 <= coupon_rate <= 1
face_value_positive
face_value > 0
Indexes
Index
Columns
Type
bonds_bond_issuer
issuer
BTree
bonds_bond_type
bond_type
BTree
bonds_bond_sector
sector
BTree
bonds_bond_rating
credit_rating
BTree
bonds_bond_currency
currency
BTree
bonds_bond_maturity
maturity_date
BTree
CallSchedule
Table:bonds_callschedule
Stores individual call dates for callable bonds. A bond with no rows in
this table is treated as a bullet bond by the OAS engine.
Column
Type
Nullable
Default
Description
id
UUID
No
uuid4()
Primary key
bond_id
UUID
No
FK
Foreign key to Bond
call_date
DATE
No
-
Date on which the call option may be exercised
call_price
DECIMAL(10,4)
No
100.0000
Call price as percentage of face value
Constraints
Constraint
Rule
unique_bond_date
(bond_id, call_date) must be unique
call_price_positive
call_price > 0
Portfolio
Table:portfolios_portfolio
Stores metadata for a named collection of bond positions. Market value and
risk metrics are computed dynamically from positions.
Column
Type
Nullable
Default
Description
id
UUID
No
uuid4()
Primary key
name
VARCHAR(255)
No
-
Portfolio name
description
TEXT
Yes
NULL
Optional description
currency
VARCHAR(3)
No
USD
Base currency for reporting
created_at
TIMESTAMP
No
NOW()
Record creation time
updated_at
TIMESTAMP
No
NOW()
Last modification time
Indexes
Index
Columns
portfolios_portfolio_currency
currency
portfolios_portfolio_name
name
Position
Table:portfolios_position
Represents a single bond holding within a portfolio.
Column
Type
Nullable
Default
Description
id
UUID
No
uuid4()
Primary key
portfolio_id
UUID
No
FK
Foreign key to Portfolio
bond_id
UUID
No
FK
Foreign key to Bond (PROTECT on delete)
face_amount
DECIMAL(20,4)
No
-
Notional face amount held
purchase_price
DECIMAL(12,6)
Yes
NULL
Entry clean price per unit of face value
purchase_date
DATE
Yes
NULL
Date position was established
notes
TEXT
Yes
NULL
Position-level notes
created_at
TIMESTAMP
No
NOW()
Record creation time
updated_at
TIMESTAMP
No
NOW()
Last modification time
Constraints
Constraint
Rule
unique_portfolio_bond
(portfolio_id, bond_id) must be unique
face_amount_positive
face_amount > 0
bond_protected
Bond cannot be deleted while held in a portfolio
YieldCurve
Table:curves_yieldcurve
Stores a fitted yield curve with its model parameters. The raw data
points that were used to fit the curve are stored in CurveDataPoint.