forked from romsey67/faspy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_fixbond.py
executable file
·59 lines (47 loc) · 1.49 KB
/
test_fixbond.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 2 21:02:58 2020
@author: RMS671214
"""
from interestrate.fixincome import fixbond_structures, fixbond_value, \
date_structures, fixbond
import numpy as np
from numpy import datetime64 as dt64
from interestrate import rmp_dates as rd
# %%
mybond = {}
mybond['issue_date'] = np.datetime64('2018-10-22')
mybond['value_date'] = np.datetime64('2021-10-22')
mybond['maturity'] = np.datetime64('2128-10-22')
mybond['day_count'] = 'Actual/365 Fixed'
mybond['frequency'] = 'Semi-Annual'
mybond['business_day'] = 'No Adjustment'
mybond['date_generation'] = rd.date_gen_method[1]
mybond['face_value'] = 1000000
mybond['coupon'] = 10.00
mybond['ytm'] = None #10.00
#mybond['type'] = 'Fixed Rate Bond'
structures = list(fixbond_structures(mybond))
print("STRUCTURES")
print("===============================")
print(structures)
print("================================")
try:
import pandas as pd
pd1 = pd.DataFrame(structures)
except:
pass
# %%
testdata = {"value_date":dt64("2020-05-01"), "maturity": dt64("2025-10-01"),
"day_count": "Actual/Actual", "frequency":"Semi-Annual",
"business_day": "No Adjustment",
"date_generation": "Backward from maturity date",
"face_value": 10000000, "coupon": 2.00, "ytm": 2.00}
val = fixbond(testdata)
#print(val["structure"])
try:
pd3 = pd.DataFrame(val["structure"])
except:
import pandas as pd
pd3 = pd.DataFrame(val["structure"])