-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test3.cpp
69 lines (56 loc) · 1.66 KB
/
Test3.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
#include <iostream>
#include <cstring>
#include <stdexcept>
#include "DiffusionGBM.h"
#include "VanillaOption.h"
#include "IRProviderConst.h"
#include "MCOptionPricer1D.hpp"
using namespace SiriusFM;
int main(int argc, char** argv)
{
if(argc != 9)
{
std::cerr << "Params: mu, sigma, S0, Call/Put, K, Tdays, tau_mins, P\n";
return 1;
}
double mu = atof(argv[1]);
double sigma = atof(argv[2]);
double S0 = atof(argv[3]);
const char * OptType = argv[4] ;
double K = atof(argv[5]);
long expirTime = atol(argv[6]);
int tau_mins = atoi(argv[7]);
long P = atol(argv[8]);
assert(sigma > 0 &&
S0 > 0 &&
expirTime > 0 &&
tau_mins > 0 &&
P > 0 &&
K > 0);
CcyE ccyA = CcyE::USD;
CcyE ccyB = CcyE::USD;
char const* ratesFileA = nullptr; //todo
char const* ratesFileB = nullptr; //todo
bool useTimerSeed = true; //to read from file
DiffusionGBM diff(mu, sigma, S0);
//pricer for FX
MCOptionPricer1D <decltype(diff),
IRPConst,
IRPConst,
CcyE,
CcyE>
Pricer (&diff, ratesFileA, ratesFileB, useTimerSeed);
time_t t0 = time(NULL);
time_t T = t0 + SEC_IN_DAY * expirTime;
OptionFX const* opt = nullptr;
if(!strcmp(OptType, "Call"))
opt = new CallOptionFX (ccyA, ccyB, K, T, false);
else if(!strcmp(OptType, "Put"))
opt = new PutOptionFX (ccyA, ccyB, K, T, false);
else
throw std::invalid_argument("Bad OptType");
double px = Pricer.Px(opt, t0, tau_mins, P);
std::cout << px << std::endl;
delete opt;
return 0;
}