-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFOUnit.cpp
More file actions
55 lines (53 loc) · 1.42 KB
/
Copy pathFOUnit.cpp
File metadata and controls
55 lines (53 loc) · 1.42 KB
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
/*
* FOUnit.cpp
*
* Created on: 26-Sep-2016
* Author: ashish
*/
#include "FOUnit.h"
FOUnit::FOUnit(std::shared_ptr<spdlog::logger> logger) { this->vollogger = logger; }
FOUnit::FOUnit(const FOUnit* f) { this->vollogger = f->vollogger; }
FOUnit::FOUnit(const FOUnit* f, std::shared_ptr<spdlog::logger> logger) {
this->call = f->call;
this->future = f->future;
this->put = f->put;
this->spot = f->spot;
this->vollogger = logger;
}
FOUnit::FOUnit(const FOUnit& f, std::shared_ptr<spdlog::logger> logger) {
this->call = f.call;
this->future = f.future;
this->put = f.put;
this->spot = f.spot;
this->vollogger = logger;
}
void FOUnit::calculate() {
// Do sense Check and then calculate the IV value
for (auto& e : future) {
std::cout << "Calculating for index" << e.first;
auto fut = e.second;
auto it = call.find(e.first);
std::vector<std::shared_ptr<Underlying::Option>> c, p;
if (it != call.end()) {
c = it->second;
}
it = put.find(e.first);
if (it != put.end()) {
p = it->second;
}
if (!c.empty() && !p.empty()) {
// Carry on the calculations
using namespace Underlying;
for (auto a : c) {
a->calculateIV(fut.get());
vollogger->info("{}", *a);
}
for (auto a : p) {
a->calculateIV(fut.get());
vollogger->info("{}", *a);
}
}
}
}
double FOUnit::atmIV() { return _atmiv; }
void FOUnit::setAtmIV() {}