-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathhedge.py
More file actions
47 lines (37 loc) · 1.17 KB
/
Copy pathhedge.py
File metadata and controls
47 lines (37 loc) · 1.17 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
# -*- coding: utf-8 -*-
import math
class Hedge:
def __init__(self):
pass
def ratio(self,S,K,u,d,r):
self.S = S # current stock price
self.K = K # strike price
self.u = u # stock up price
self.d = d # stock down price
self.r = r # risk free interest rate
self.c_price_u = self.u - self.K
self.c_price_d = self.d - self.K
if (self.c_price_d < 0):
self.c_price_d = 0
hedge_ratio = (self.c_price_u - self.c_price_d) / (self.u - self.d) # size of exporsure / size of position in the future
return hedge_ratio
# resize proportion
def hedge_ratio_proportion(self,ratio):
multiplier = 1 / ratio
prop_value = multiplier
v_u = self.u - prop_value * self.c_price_u
v_d = self.d - prop_value * self.c_price_d
if v_u!=v_d:
print 'Arbitrage Exist!'
else:
print 'NO Arbitrage Opportunity!'
# work on this a bit more; need to check other documents
c = (self.S- v_u / self.r) / prop_value
# / (risk-free interest rate)
print "Call price is {}".format(c)
if __name__ == "__main__":
h = Hedge()
r = h.ratio(100,30,125,75,.05)
print h.hedge_ratio_proportion(r)
# NO Arbitrage Opportunity!
# Call price is -500.0