Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit f4b95dd

Browse files
committed
Completed CPU part
1 parent bb9e7b3 commit f4b95dd

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/nmc.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,47 @@ void NMC::run(XVA xva, double factor, const std::map<ExternalPaths, std::vector<
152152
EPE[i] -= factor;
153153
DPE[i] = factor - DPE[i];
154154
}
155+
156+
double loss_given_default = 0.4;
157+
double funding_cost = 0.05;
158+
double capital_cost = 0.1;
155159

156160
switch (xva)
157161
{
158162
case CVA:
159-
/* code */
163+
for (size_t i = 0; i < nb_points; i++)
164+
{
165+
final_path[i] = EPE[i] * (1 - loss_given_default) * 0.01;
166+
}
160167
break;
161168

162169
case DVA:
163-
/* code */
170+
for (size_t i = 0; i < nb_points; i++)
171+
{
172+
final_path[i] = DPE[i] * (1 - loss_given_default) * 0.01;
173+
}
164174
break;
165175

166176
case FVA:
167-
/* code */
177+
for (size_t i = 0; i < nb_points; i++)
178+
{
179+
final_path[i] = std::max(EPE[i] - DPE[i], 0.0) * funding_cost * exp(-0.03 * i * T / nb_points);
180+
}
181+
168182
break;
169183

170184
case MVA:
171-
/* code */
185+
for (size_t i = 0; i < nb_points; i++)
186+
{
187+
final_path[i] = EPE[i] * funding_cost * exp(-0.03 * i * T / nb_points);
188+
}
172189
break;
173190

174191
case KVA:
175-
/* code */
192+
for (size_t i = 0; i < nb_points; i++)
193+
{
194+
final_path[i] = EPE[i] * capital_cost * exp(-0.03 * i * T / nb_points);
195+
}
176196
break;
177197

178198
default:

0 commit comments

Comments
 (0)