@@ -27,7 +27,6 @@ def theo(self, S, K, V, T, dT):
2727 else :
2828 return K * self .cdf (- self .d2 (S , K , V , T )) - S * self .cdf (- self .d1 (S , K , V , T ))
2929
30-
3130 def delta (self , S , K , V , T , dT ):
3231 if dT == 'C' :
3332 delta = self .cdf (self .d1 (S , K , V , T ))
@@ -226,55 +225,52 @@ def searchDelta(self, fPrice, deep, acc, paramD, params):
226225
227226calc = Calculation ()
228227
229- deep = 2
230-
231- acc = 0.0001
232228
233- exp = 15 / god
229+ '''deep = 2
234230
235- fPrice = 55
231+ exp = 30 / god
236232
237- volaShift = 0 / 100
233+ fPrice = 21000
238234
239- exp2 = 12
240- exp3 = 9
235+ exp2 = 15 / god
236+ exp3 = 5 / god
241237
242238params = []
243239
244240dType = 'F'
245- quant = 4
246- price = 55.36
241+ quant = 1
242+ price = 20000
247243strike = 0
248244vola = 0
249245params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
250246
251247dType = 'C'
252248quant = 10
253249price = 1.31
254- strike = 56
255- vola = 27.25 / 100 + volaShift
250+ strike = 25000
251+ vola = 27.25
256252params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
257253
258254dType = 'P'
259255quant = 8
260256price = 1.24
261257strike = 56
262- vola = 27.25 / 100 + volaShift
258+ vola = 27.25
263259params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
264260
265261dType = 'P'
266262quant = 5
267263price = 0.82
268264strike = 55
269- vola = 27.7 / 100 + volaShift
265+ vola = 27.7
270266params.append({'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp})
271267
272268bePriceS = fPrice - deep
273- bePriceF = fPrice + deep
269+ bePriceF = fPrice + deep'''
274270
275- calc .plotPL (bePriceS , bePriceF , params , exp )
276- calc .plotPL (bePriceS , bePriceF , params , exp2 / god )
277- calc .plotPL (bePriceS , bePriceF , params , exp3 / god )
271+ ''' calc.plotPL(bePriceS, bePriceF, params, exp)
272+ calc.plotPL(bePriceS, bePriceF, params, exp2)
273+ calc.plotPL(bePriceS, bePriceF, params, exp3)
278274plt.ylabel("P/L")
279275plt.xlabel("Price")
280276plt.title("Option")
@@ -283,8 +279,8 @@ def searchDelta(self, fPrice, deep, acc, paramD, params):
283279plt.show()
284280
285281calc.plotDelta(bePriceS, bePriceF, params, exp)
286- calc .plotDelta (bePriceS , bePriceF , params , exp2 / god )
287- calc .plotDelta (bePriceS , bePriceF , params , exp3 / god )
282+ calc.plotDelta(bePriceS, bePriceF, params, exp2)
283+ calc.plotDelta(bePriceS, bePriceF, params, exp3)
288284plt.xlabel("Price")
289285plt.title("Option")
290286plt.grid(True)
@@ -331,9 +327,11 @@ def searchDelta(self, fPrice, deep, acc, paramD, params):
331327
332328print('G:\t ', round(calc.gammaFull(fPrice, params, exp), 2))
333329
334- print ('P/L:\t ' , calc .p_l (fPrice , params , exp ))
330+ print('P/L:\t ', calc.p_l(fPrice, params, exp))'''
331+
335332
336- #Donee
333+ """
334+ acc = 0.0001
337335
338336dType = 'F'
339337strike = 0
@@ -377,20 +375,25 @@ def searchDelta(self, fPrice, deep, acc, paramD, params):
377375vola = 0
378376paramD3 = {'dType': dType, 'price': price, 'quant': quant, 'strike': strike, 'vola': vola, 'exp': exp}
379377
380-
381-
382-
383- '''calc.searchDelta(fPrice, deep, acc, paramD1, params)
378+ calc.searchDelta(fPrice, deep, acc, paramD1, params)
384379calc.searchDelta(fPrice, deep, acc, paramD_1, params)
385380calc.searchDelta(fPrice, deep, acc, paramD2, params)
386381calc.searchDelta(fPrice, deep, acc, paramD_2, params)
387382calc.searchDelta(fPrice, deep, acc, paramD3, params)
388383calc.searchDelta(fPrice, deep, acc, paramD_3, params)
384+ """
385+
386+
387+ #Bitcon example
389388
390- S = 54
391- K = 53
392- V = 0.35
393- T = 3
394- dT = "P"'''
389+ S = 21000 #Underlying (price now)
390+ K = 30000 #Strike
391+ V = 0.75 #Implied Volatility (1 / 100%)
392+ T = 30 / god #Expiration date (days from now / 365)
393+ dT = "C" #Call / Put
395394
396- #print('One: ', round(calc.theo(S, K, V, T/god, dT), 2))
395+ print ('Theo: ' , round (calc .theo (S , K , V , T , dT ), 2 ))
396+ print ('Delta: ' , round (calc .delta (S , K , V , T , dT ), 2 ))
397+ print ('Theta: ' , round (calc .theta (S , K , V , T ), 2 ))
398+ print ('Vega: ' , round (calc .vega (S , K , V , T ), 2 ))
399+ print ('Gamma: ' , round (calc .gamma (S , K , V , T ), 2 ))
0 commit comments