Spaces:
Running
Running
File size: 1,515 Bytes
cc752f9 | 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # src/prism/database/seed_data.py
from .connection import DatabaseConnection
def seed_positions():
"""Insert sample swap positions for testing."""
db = DatabaseConnection()
db.connect()
# Sample positions
positions = [
(
"SWP001",
"2024-01-15",
"2029-01-15",
10000000,
4.25,
"SOFR",
"PAY_FIXED",
"USD",
),
(
"SWP002",
"2024-03-20",
"2034-03-20",
25000000,
4.50,
"SOFR",
"RCV_FIXED",
"USD",
),
(
"SWP003",
"2024-06-10",
"2029-06-10",
15000000,
4.10,
"SOFR",
"PAY_FIXED",
"USD",
),
(
"SWP004",
"2024-08-05",
"2027-08-05",
8000000,
3.95,
"SOFR",
"RCV_FIXED",
"USD",
),
]
insert_query = """
INSERT INTO swap_positions
(position_id, trade_date, maturity_date, notional, fixed_rate, float_index, pay_receive, currency)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (position_id) DO NOTHING
"""
for position in positions:
db.execute_query(insert_query, position)
db.close()
print(f"✅ Seeded {len(positions)} swap positions!")
if __name__ == "__main__":
seed_positions()
|