Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect dates? #2

Open
carstenf opened this issue Jan 30, 2022 · 1 comment
Open

incorrect dates? #2

carstenf opened this issue Jan 30, 2022 · 1 comment

Comments

@carstenf
Copy link

Beautiful pice of code!

I'm downloading the vix data from https://www.cboe.com/us/futures/market_statistics/historical_data/
and one needs to know the expiring date to be able to get the file:

urlStr = 'https://www.cboe.com/us/futures/market_statistics/historical_data/products/csv/VX/2014-03-18'
urllib.request.urlretrieve(urlStr)

I found only three issues between 2014 and today:
2014-03-19 -> should be 2014-03-18
2019-03-20 -> should be 2020-03-18
2022-03-16 -> should be 2022-03-15

I check regarding valid business days and all days are valid.

end = start = '2014-03-18'
len(nyse.valid_days(start_date=start, end_date=end))

some idea how to fix it?

@carstenf
Copy link
Author

carstenf commented Jan 30, 2022

looks like I found a solution, you might try this:

import pandas_market_calendars as mcal

nyse = mcal.get_calendar('NYSE')
def check_if_business_day(day):
    end =  start = day
    return len(nyse.valid_days(start_date=start, end_date=end))>0

than inside:
def get_expiry_date_for_month(curr_date):

........

    # TODO: Incorporate check that it's a trading day, if so move the 3rd
    # Friday back by one day before subtracting

    if check_if_business_day(third_friday_next_month) == False:
        third_friday_next_month = third_friday_next_month - one_day   

    return third_friday_next_month - thirty_days

Repository owner deleted a comment from chenwynn Mar 19, 2024
Repository owner deleted a comment from jalamari2018 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@carstenf and others