-
Notifications
You must be signed in to change notification settings - Fork 45
/
example_plot.py
108 lines (87 loc) · 2.44 KB
/
example_plot.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from plot import Plot
import matplotlib.pyplot as plt
plot = Plot()
god = 365
step = 10
deep = 7500
exp = 30 / god
exp2 = 15 / god
exp3 = 5 / god
fPrice = 21000
params = []
dType = 'F'
quant = 1
price = 20000
strike = 0
vola = 0
params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
dType = 'C'
quant = 1
price = 500
strike = 25000
vola = 0.75
params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
dType = 'P'
quant = 1
price = 100
strike = 15000
vola = 0.75
params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
dType = 'P'
quant = -1
price = 25
strike = 10000
vola = 1.5
params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
bePriceS = fPrice - deep
bePriceF = fPrice + deep
plot.plotPL(bePriceS, bePriceF, params, exp, step)
plot.plotPL(bePriceS, bePriceF, params, exp2, step)
plot.plotPL(bePriceS, bePriceF, params, exp3, step)
plt.ylabel("P/L")
plt.xlabel("Price")
plt.title("Option")
plt.grid(True)
plt.legend()
plt.show()
plot.plotDelta(bePriceS, bePriceF, params, exp, step)
plot.plotDelta(bePriceS, bePriceF, params, exp2, step)
plot.plotDelta(bePriceS, bePriceF, params, exp3, step)
plt.xlabel("Price")
plt.title("Option")
plt.grid(True)
plt.legend()
plt.ylabel("Delta")
plt.show()
plot.plotTheta(bePriceS, bePriceF, params, exp, step)
plot.plotTheta(bePriceS, bePriceF, params, exp2, step)
plot.plotTheta(bePriceS, bePriceF, params, exp3, step)
plt.xlabel("Price")
plt.title("Option")
plt.grid(True)
plt.legend()
plt.ylabel("Theta")
plt.show()
plot.plotVega(bePriceS, bePriceF, params, exp, step)
plot.plotVega(bePriceS, bePriceF, params, exp2, step)
plot.plotVega(bePriceS, bePriceF, params, exp3, step)
plt.xlabel("Price")
plt.title("Option")
plt.grid(True)
plt.legend()
plt.ylabel("Vega")
plt.show()
plot.plotGamma(bePriceS, bePriceF, params, exp, step)
plot.plotGamma(bePriceS, bePriceF, params, exp2, step)
plot.plotGamma(bePriceS, bePriceF, params, exp3, step)
plt.xlabel("Price")
plt.title("Option")
plt.grid(True)
plt.legend()
plt.ylabel("Gamma")
plt.show()
print('D:\t', round(plot.deltaFull(fPrice, params, exp), 2))
print('V:\t', round(plot.vegaFull(fPrice, params, exp), 2))
print('T:\t', round(plot.thetaFull(fPrice, params, exp), 2))
print('G:\t', round(plot.gammaFull(fPrice, params, exp), 2))
print('P/L:\t', plot.p_l(fPrice, params, exp))