-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHedgingSimulator.h
84 lines (75 loc) · 2.34 KB
/
HedgingSimulator.h
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include "stdafx.h"
// #include "StockPriceModel.h"
#include "BlackScholesModel.h"
#include "ContinuousTimeOptionBase.h"
#include "Strategy.h"
/**
* This class can be used to see the results of the delta
* hedging strategy
*/
class HedgingSimulator {
public:
/* Runs a number of simulations and returns
a vector of the profit and loss */
std::vector<double> runSimulations(
int nSimulations ) const;
double meanAbsolutePnL( int nSimulations) const;
void setToHedge(
std::shared_ptr<ContinuousTimeOptionBase> toHedge) {
this->toHedge = toHedge;
}
void setSimulationModel(
std::shared_ptr<BlackScholesModel> model) {
this->simulationModel = model;
}
void setNSteps(int nSteps) {
this->nSteps = nSteps;
}
void setBidProportion(double p) {
this->bidProportion = p;
}
void setHedgingStrategy(
std::shared_ptr<Strategy> strategy) {
this->hedgingStrategy = strategy;
}
/* Another constructor */
HedgingSimulator(std::shared_ptr<ContinuousTimeOptionBase> option,
std::shared_ptr<BlackScholesModel> model,
std::shared_ptr<Strategy> strategy);
HedgingSimulator(std::shared_ptr<ContinuousTimeOptionBase> option,
std::shared_ptr<BlackScholesModel> model);
/* Default constructor */
HedgingSimulator(std::shared_ptr<ContinuousTimeOptionBase> option);
private:
/* The option that has been written */
std::shared_ptr<ContinuousTimeOptionBase> toHedge;
/* The model used to simulate stock prices */
std::shared_ptr<BlackScholesModel>
simulationModel;
/* The model used to compute prices and deltas */
// std::shared_ptr<StockPriceModel> pricingModel;
/* Hedging strategy */
std::shared_ptr<Strategy> hedgingStrategy;
/* The number of steps to use */
int nSteps;
/* bidProportion accounts for constant bid-ask spread */
double bidProportion;
/* Run a simulation and compute
the profit and loss */
double runSimulation() const;
/* How much should we charge the customer */
// double chooseCharge( double stockPrice ) const;
/* Hoe much stock should we hold */
// double selectStockQuantity(
// double date,
// double stockPrice ) const;
/* Accounts price difference in bid ask spread */
Matrix computePrice( Matrix buyBool, Matrix stockPrice) const;
};
//
//
// Tests
//
//
void testHedgingSimulator();