-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsuringShortPositions.py
More file actions
42 lines (31 loc) · 1.46 KB
/
InsuringShortPositions.py
File metadata and controls
42 lines (31 loc) · 1.46 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
# Created by: Ryan Vickramasinghe
# This code will calculate payoff and profit for an insured short position
# using a short position on an asset insured by a call option on that same
# asset.
# Get initial information from user:
initAssetValue = int(input('Enter asset value: '))
callStrikePrice = int(input('Enter strike price of call option: '))
callCost = int(input('Enter call option cost: '))
riskFreeIR = int(input('Enter risk-free interest rate (%): '))
# convert percentage to decimal:
riskFreeIR = riskFreeIR/100
while True:
# get current asset price
currAssetPrice = int(input('\nEnter current asset price: '))
# if current price is less than call strike, don't exercise
if((currAssetPrice - callStrikePrice) <= 0):
# payoff is simply the current price since we don't exercise
# (although negative since we must sell for that price)
payoff = -1*currAssetPrice
# calculate profit, factoring in intial invcestment and put cost future value
profit = payoff - (-1*callStrikePrice + callCost)*(1 + riskFreeIR)
# if current price is LESS than initial price, we exercise the put
else:
# payoff is the put strike price
payoff = -1*callStrikePrice
# profit
profit = payoff - (-1*initAssetValue + callCost)*(1 + riskFreeIR)
print('Payoff: ' + str(payoff) + ' Profit: ' + str(profit))
if(input('\nTry another price? (y/n): ') == 'n'):
break
print('\nClosed program.')