Skip to content

Commit

Permalink
version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hashABCD committed Mar 17, 2021
1 parent 9217475 commit 470a749
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 21 deletions.
20 changes: 3 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var/
.installed.cfg
*.egg

#My Files
myfiles/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand All @@ -49,23 +52,6 @@ coverage.xml
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

Expand Down
62 changes: 59 additions & 3 deletions opstrat/basic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
'''
Code to be uploaded here
'''
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import warnings

warnings.filterwarnings('ignore')

abb={'c': 'Call',
'p': 'Put',
'b': 'Long',
's': 'Short'}

def option_plotter(op_type='c',spot=725, spot_range=5,strike=720,tr_type='b',op_pr=10):


op_type=str.lower(op_type)
tr_type=str.lower(tr_type)


def check_inputs():
"""
Check inputs are proper
"""
if op_type not in ['p','c']:
raise ValueError("Input 'p' for put and 'c' for call!")
if tr_type not in ['b','s']:
raise ValueError("Input 'b' for Buy and 's' for Sell!")

check_inputs()

def payoff_calculator():
x=spot*np.arange(100-spot_range,101+spot_range,0.01)/100

y=[]
if str.lower(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))

if str.lower(tr_type)=='s':
y=-np.array(y)
return x,y

x,y=payoff_calculator()

def plotter(x,y):
sns.lineplot(x=x, y=y)
plt.axhline(color='k', linestyle='--')
plt.axvline(x=spot, color='r', linestyle='--')
title=str(abb[op_type])+' '+str(abb[tr_type])+'\n St price :'+str(strike)
plt.title(title)
plt.tight_layout()
plt.show()

plotter(x,y)

option_plotter()
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
VERSION = '0.0.1'
DESCRIPTION = 'Option stategy visualizer'
LONG_DESCRIPTION = 'Option strategy visualizer'
URL = 'https://github.com/abhijith-git/opstrat'

# Setting up
setup(
Expand All @@ -20,7 +21,8 @@
description=DESCRIPTION,
long_description_content_type="text/markdown",
long_description=long_description,
packages=find_packages(),
url=URL,
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
install_requires=['matplotlib', 'pandas', 'numpy'],
keywords=['python', 'video', 'stream', 'video stream', 'camera stream', 'sockets'],
classifiers=[
Expand Down

0 comments on commit 470a749

Please sign in to comment.