-
Notifications
You must be signed in to change notification settings - Fork 45
/
pricing.py
75 lines (69 loc) · 2.34 KB
/
pricing.py
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
from bsm import BSM
class Pricing(BSM):
def deltaFull(self, fPrice, params, exp):
i = 0
n = len(params)
deltaFull = 0
while i < n:
param = params[i]
if exp:
param['exp'] = exp
deltaSingle = self.delta(fPrice, param['strike'], param['vola'], param['exp'], param['dType']) * param['quant']
deltaFull = deltaFull + deltaSingle
i+=1
return deltaFull
def vegaFull(self, fPrice, params, exp):
i = 0
n = len(params)
vegaFull = 0
while i < n:
param = params[i]
if exp:
param['exp'] = exp
if param['dType'] != 'F':
vegaSingle = self.vega(fPrice, param['strike'], param['vola'], param['exp']) * param['quant']
vegaFull = vegaFull + vegaSingle
i+=1
return vegaFull
def thetaFull(self, fPrice, params, exp):
i = 0
n = len(params)
thetaFull = 0
while i < n:
param = params[i]
if exp:
param['exp'] = exp
if param['dType'] != 'F':
thetaSingle = self.theta(fPrice, param['strike'], param['vola'], param['exp']) * param['quant']
thetaFull = thetaFull + thetaSingle
i+=1
return thetaFull
def gammaFull(self, fPrice, params, exp):
i = 0
n = len(params)
gammaFull = 0
while i < n:
param = params[i]
if exp:
param['exp'] = exp
if param['dType'] != 'F':
gammaSingle = self.gamma(fPrice, param['strike'], param['vola'], param['exp']) * param['quant']
gammaFull = gammaFull + gammaSingle
i+=1
return gammaFull
def p_l(self, fPrice, params, exp):
i = 0
n = len(params)
plF = 0
while i < n:
param = params[i]
if exp:
param['exp'] = exp
if param['dType'] == 'F':
plS = (fPrice - param['price']) * param['quant']
else:
theo = round(self.theo(fPrice, param['strike'], param['vola'], param['exp'], param['dType']), 3)
plS = (theo - param['price']) * param['quant']
plF = plF + plS
i+=1
return plF