forked from hashABCD/opstrat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multiple contracts and helper modules
- Loading branch information
Showing
7 changed files
with
100 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "0.1.3" | ||
__version__ = "0.1.4" | ||
__author__ = "Abhijith Chandradas" | ||
|
||
from .basic_multi import * | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import yfinance as yf | ||
import numpy as np | ||
|
||
def check_optype(op_type): | ||
if (op_type not in ['p','c']): | ||
raise ValueError("Input 'p' for put and 'c' for call!") | ||
|
||
def check_trtype(tr_type): | ||
if (tr_type not in ['b','s']): | ||
raise ValueError("Input 'b' for Buy and 's' for Sell!") | ||
|
||
def payoff_calculator(x, op_type, strike, op_pr, tr_type, n): | ||
y=[] | ||
if op_type=='c': | ||
for i in range(len(x)): | ||
y.append(max((x[i]-strike-op_pr),-op_pr)) | ||
else: | ||
for i in range(len(x)): | ||
y.append(max(strike-x[i]-op_pr,-op_pr)) | ||
y=np.array(y) | ||
|
||
if tr_type=='s': | ||
y=-y | ||
return y*n | ||
|
||
def check_ticker(ticker): | ||
""" | ||
Check ticker | ||
""" | ||
try: | ||
return yf.Ticker('msft').info['currentPrice'] | ||
except KeyError: | ||
raise ValueError('Ticker not recognized') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters