GithubHelp home page GithubHelp logo

xeu's Introduction

Align trade strategy with the expected market conditions based on historical patterns and observed volatility dynamics.

Vol Parameters and option trade Strategies:

Implied Volatility (IV): Increase in IV: Straddle and Strangle, benefit from larger price movements in either direction. Decrease in IV: Butterfly and Iron Condor, profit from stable or decreasing volatility

Realized Volatility (RV): Higher than IV: Long Straddles or Strangles Lower than IV: Short Iron Condors

IV Term Structure: Steepening (ST IV > LT IV): Calendar Spreads: Short short-term and long long-term options Flattening (ST IV < LT IV): Reverse Calendar Spreads: Long short-term and short long-term options.

Skew (Up Skew / Down Skew): Increased Up Skew: Long Call Increased Down Skew: Long Put

Option Convexity: High Convexity (significant curvature): Long Straddles or Long Strangles: benefit from large price movements. Low Convexity (less curvature): Short Iron Condors: where small price movements are favorable.

Expectations

Screenshot 2024-01-03 at 00 14 34

Modelling

Setting thresholds for each parameter. For instance:

  • If IV increases by X%: Opt for a Straddle/Strangle.
  • If RV is consistently higher than IV by Y%: Consider Long Volatility strategies.
  • If Short-term IV exceeds Long-term IV by Z%: Look into Calendar Spreads.

xeu's People

Contributors

aurelie-dubost avatar

Stargazers

 avatar

Watchers

 avatar

xeu's Issues

Plot multi ts

Adjust the plot_ts function to format y-axes with different units

def plot_ts(list_ts, dict_colors, y_axis_left, y_axis_right, time_frame, grid, start_date, end_date, recession_dates=None):
fig, ax1 = plt.subplots()

# Plot each time series and assign it to the primary y-axis
for ts, color in zip(list_ts, dict_colors.values()):
    ax1.plot(ts.index, ts.values, color=color)

# Shade the areas for recessions
if recession_dates:
    for start, end in recession_dates:
        ax1.axvspan(pd.to_datetime(start), pd.to_datetime(end), color='grey', alpha=0.5)

# Set the date format on the x-axis based on time_frame
if time_frame == 'mm_yy':
    ax1.xaxis.set_major_formatter(DateFormatter('%m_%y'))
elif time_frame == 'yyyy':
    ax1.xaxis.set_major_formatter(DateFormatter('%Y'))

# Format primary y-axis with '%' and set label
ax1.set_ylabel(y_axis_left)
ax1.yaxis.set_major_formatter(plt.FuncFormatter(lambda y, _: '{:.0%}'.format(y)))

# Set x-axis and grid
ax1.set_xlim(pd.to_datetime(start_date), pd.to_datetime(end_date))
ax1.grid(grid)

# Make x-axis labels horizontal
ax1.tick_params(axis='x', rotation=0)

# Secondary y-axis (on the right)
ax2 = ax1.twinx()
secondary_data = np.random.rand(len(date_range)) * 1000  # Example secondary data scaled for $
ax2.plot(date_range, secondary_data, color='red')  # Plot secondary data
ax2.set_ylabel(y_axis_right, color='red')

# Format secondary y-axis with '$' and set label color
ax2.yaxis.set_major_formatter(plt.FuncFormatter(lambda y, _: '${:.2f}'.format(y)))
ax2.tick_params(axis='y', labelcolor='red')

plt.tight_layout()
plt.show()

Call the function with fake data

plot_ts(list_ts, dict_colors, y_axis_left='GDP Growth Rate (%)', y_axis_right='Currency Value ($)',
time_frame='yyyy', grid=True, start_date='1995-01-01', end_date='2023-01-01',
recession_dates=recession_dates)

A

import ipywidgets as widgets
from IPython.display import display, clear_output
import matplotlib.pyplot as plt
from pptx import Presentation
from pptx.util import Inches
import tempfile
import os

Function to generate a matplotlib chart based on a type

def create_chart(chart_type='Line'):
fig, ax = plt.subplots()
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
if chart_type == 'Line':
ax.plot(x, y)
elif chart_type == 'Bar':
ax.bar(x, y)
# Add more chart types as needed
plt.close(fig)
return fig

Function to save a matplotlib figure to an image file and return the path

def save_fig_to_image(fig):
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as tmpfile:
fig.savefig(tmpfile.name, format='png')
return tmpfile.name

Function to add a chart slide to the presentation

def add_chart_slide(prs, chart_type):
slide_layout = prs.slide_layouts[5] # Using a blank layout
slide = prs.slides.add_slide(slide_layout)
title = slide.shapes.title
title.text = "Chart: " + chart_type

fig = create_chart(chart_type)
img_path = save_fig_to_image(fig)

left = Inches(1)
top = Inches(1.5)
height = Inches(4.5)

slide.shapes.add_picture(img_path, left, top, height=height)
os.remove(img_path)

Widgets for user input

template_select = widgets.Dropdown(options=['Portrait', 'Landscape'], description='Template:')
graph_type_select = widgets.Dropdown(options=['Line', 'Bar', 'Scatter', 'Pie'], description='Graph Type:')
slide_number_select = widgets.BoundedIntText(value=1, min=1, max=10, step=1, description='Number of Slides:')
refresh_button = widgets.Button(description='Display Graph')
print_button = widgets.Button(description='Print PPT')
output = widgets.Output()

Display function for the graph

def on_refresh_clicked(b):
with output:
clear_output(wait=True)
display(create_chart(graph_type_select.value))

Function to generate and display the PowerPoint presentation

def on_print_clicked(b):
with output:
clear_output(wait=True)
num_slides = slide_number_select.value
for _ in range(num_slides):
display(create_chart(graph_type_select.value))

refresh_button.on_click(on_refresh_clicked)
print_button.on_click(on_print_clicked)

Layout adjustments

dropdowns_and_slide_number = widgets.HBox([template_select, graph_type_select, slide_number_select])
buttons = widgets.HBox([refresh_button, print_button])
app_layout = widgets.VBox([dropdowns_and_slide_number, buttons, output])

Display the updated app layout

display(app_layout)

Annotate

Importing libraries

import matplotlib.pyplot as plt

Preparing dataset

x = [x for x in range(10)]

y = [5, 2, 4, 8, 5, 6, 8, 7, 1, 3]

text = ["first", "second", "third", "fourth", "fifth",

    "sixth", "seventh", "eighth", "ninth", "tenth"] 

plotting scatter plot

plt.scatter(x, y)

Loop for annotation of all points

for i in range(len(x)):

plt.annotate(text[i], (x[i], y[i] + 0.2)) 

adjusting the scale of the axes

plt.xlim((-1, 10))

plt.ylim((0, 10))
plt.show()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.