Skip to content

Commit

Permalink
Fixed Issues with Stock
Browse files Browse the repository at this point in the history
Corrected some references to stock. Updated the payoff function for stocks. Corrected the payoff function to use contract equivalent amount for stocks to align with calls and puts.
  • Loading branch information
sgttux committed Sep 7, 2023
1 parent d83576e commit 1ec92c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions opstrat/basic_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ def multi_plotter(spot_range, spot, op_list,

# Calculate Payoff Prices for each x Underlying Price Value with Days to Expiration
y_list.append(payoff_calculator(x, row['op_type'], row['strike'], row['op_pr'], row['tr_type']
, row['contracts'], row['days_to_expiration'], r, v ))
, row['contract_equiv'], row['days_to_expiration'], r, v ))

# Calculate Payoff Prices with Adjusted Days to Expiration
if exp_adjust > 0:
y_exp_list.append(payoff_calculator(x, row['op_type'], row['strike'], row['op_pr'], row['tr_type']
, row['contracts'], row['days_to_expiration_adjusted'], r, v ))
, row['contract_equiv'], row['days_to_expiration_adjusted'], r, v ))

def plotter():

Expand Down Expand Up @@ -228,5 +228,4 @@ def plotter():
print('You have selected to not show individual option legs, combined transaction legs, or combined graph. No graph will be generated.')
return
else:
plotter()

plotter()
8 changes: 4 additions & 4 deletions opstrat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from .blackscholes import black_scholes

def check_optype(op_type):
if (op_type not in ['p','c','s']):
raise ValueError("Input 'p' for put, 'c' for call, 's' for stock!")
if (op_type not in ['p','c','st']):
raise ValueError("Input 'p' for put, 'c' for call, 'st' for stock!")

def check_trtype(tr_type):
if (tr_type not in ['b','s']):
Expand All @@ -30,9 +30,9 @@ def payoff_calculator(x, op_type, strike, op_pr, tr_type, n, days_to_expiration,
y=[]

# If Leg is a Stock - calculate payoff graph for a stock position
if op_type=='s':
if op_type=='st':
for i in range(len(x)):
y.append(x[i]-strike-op_pr)
y.append(x[i]-strike)

# If Leg is an Option and Future Expiration, - calculate value of option using Black Scholes Pricing Model
elif days_to_expiration > 0:
Expand Down

0 comments on commit 1ec92c3

Please sign in to comment.