Created
August 7, 2021 12:24
-
-
Save addiversitas/eec8c282a270ffb8aad1b777082f42e4 to your computer and use it in GitHub Desktop.
Proportional 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 proportional_adjustment(previous_futures, next_futures, roll_date): | |
roll_proportion = next_futures[roll_date]/previous_futures[roll_date] | |
adjusted_price = pd.concat([previous_futures[:roll_date] * roll_proportion, next_futures[roll_date:]]) | |
adjusted_price = adjusted_price[~adjusted_price.duplicated()] | |
return adjusted_price | |
adjusted_price = proportional_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