Created
August 7, 2021 12:11
-
-
Save addiversitas/80004f47f781445dd5de2ceb3788378a to your computer and use it in GitHub Desktop.
Panama Adjustment for Futures contracts
This file contains hidden or 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
import pandas as pd | |
#load data from your preferred source | |
data = pd.read_csv("PATH/TO/FILE/futures_rolling.csv", index_col = [0], parse_dates=True) | |
june_21 = data["VX-2021M"] | |
july_21 = data["VX-2021N"] | |
def panama_adjustment(previous_futures, next_futures, roll_date): | |
roll_gap = next_futures[roll_date] - previous_futures[roll_date] | |
adjusted_price = pd.concat([previous_futures[:roll_date] + roll_gap, next_futures[roll_date:]]) | |
adjusted_price = adjusted_price[~adjusted_price.duplicated()] | |
return adjusted_price | |
adjusted_price = panama_adjustment(june_21, july_21, "2021-06-16") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment