-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestACGB.cpp
70 lines (59 loc) · 2.41 KB
/
testACGB.cpp
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
#include <stdlib.h>
#include <iostream>
#include "../final/final.h"
#include "../utils/datetime.h"
using namespace final;
using namespace utils;
TSecurity *sec;
void init() {
std::cout << "init" << std::endl;
try {
sec = GetSecurity(
"ACGB", // ticker
0.0575, // coupon
TDate(15,5,2021).Serial(), // maturity
TDate(15,5,2011).Serial(), // issued
2, // frequency
1, // basis
TDate(15,5,2011).Serial(), // interest accrues from
TDate(15,11,2011).Serial(), // first coupon
100 // redemption
);
}
catch(...) {
sec = NULL;
std::cout << "%TEST_FAILED% time=0 testname=init (testACGB) message=init failed" << std::endl;
}
}
void testAccrued() {
std::cout << "testACGB test accrued interest" << std::endl;
double accruedExpected = 2.844;
TDate settlementDate(13,11,2013);
double accrued = sec->AccruedInterest(settlementDate);
if( CompareDoubles(accrued, accruedExpected)!=0 ) {
std::cout << "%TEST_FAILED% time=0 testname=testAccrued (testACGB) message=testing ACGB5.75 05/21 accrued interest failed, "
<< "settlement " << settlementDate.DateString().c_str()
<< ", expected: " << accruedExpected
<< ", got: " << accrued
<< std::endl;
}
}
void test2() {
std::cout << "testACGB test 2" << std::endl;
std::cout << "%TEST_FAILED% time=0 testname=test2 (testACGB) message=error message sample" << std::endl;
}
int main(int argc, char** argv) {
std::cout << "%SUITE_STARTING% testACGB" << std::endl;
std::cout << "%SUITE_STARTED%" << std::endl;
init();
if( sec != NULL ) {
std::cout << "%TEST_STARTED% testAccrued (testACGB)" << std::endl;
testAccrued();
std::cout << "%TEST_FINISHED% time=0 testAccrued (testACGB)" << std::endl;
std::cout << "%TEST_STARTED% test2 (testACGB)\n" << std::endl;
test2();
std::cout << "%TEST_FINISHED% time=0 test2 (testACGB)" << std::endl;
}
std::cout << "%SUITE_FINISHED% time=0" << std::endl;
return (EXIT_SUCCESS);
}