forked from Glikstein/SuperMC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexotics.cpp
More file actions
33 lines (26 loc) · 964 Bytes
/
Copy pathexotics.cpp
File metadata and controls
33 lines (26 loc) · 964 Bytes
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
// Copyright (c) 2014 Ezequiel Dan Glikstein
#include "exotics.h"
#include <cmath>
#include <iostream>
namespace Exotics{
void ArithmeticAvg(StepData& step)
{
step.step_num++;
step.state[0] = (step.state[0] * (step.step_num-1) + step.S)/step.step_num;
//std::cout<<"step["<<step.step_num<<"]: price = "<<step.S<<" vol = "<<step.vol<<" state = "<<step.state[0]<<'\n';
}
void Vanilla(StepData& step)
{
step.state[0] = step.S;
step.step_num++;
//std::cout<<"step["<<step.step_num<<"]: price = "<<step.S<<" vol = "<<step.vol<<" state = "<<step.state[0]<<'\n';
}
void GeometricAvg(StepData& step)
{
step.step_num++;
step.state[0] = exp( (log(step.state[0]) * (step.step_num-1) + log(step.S) )/step.step_num );
// pow( pow(step.state[0], step.step_num-1)*step.S, 1.0/step.step_num) overflows easily
//std::cout<<"step["<<step.step_num<<"]: price = "<<step.S<<" vol = "<<step.vol<<" state = "<<step.state[0]<<'\n';
}
// etc
}