Skip to content

Instantly share code, notes, and snippets.

@2torus
Created September 3, 2020 07:23
Show Gist options
  • Save 2torus/0f6c34cd402f7052c4a9060df719504d to your computer and use it in GitHub Desktop.
Save 2torus/0f6c34cd402f7052c4a9060df719504d to your computer and use it in GitHub Desktop.
Compares pandas_market_calendars versions
from python
RUN pip install pandas > /dev/null
ARG NEW="false"
RUN if [ ${NEW} = "true" ]; then pip install git+https://github.com/2torus/pandas_market_calendars.git@cache-holidays > /dev/null; else pip install pandas_market_calendars==1.4.2 > /dev/null; fi
RUN echo "import pandas as pd \n\
from random import sample, seed \n\
import time \n\
random_dates = pd.date_range('2000-1-1', '2019-1-1', freq='D') \n\
seed(0xDEED) \n\
random_dates = sample(random_dates.to_list(), 101) \n\
import pandas_market_calendars as mcal \n\
trade_calendar = mcal.get_calendar('NYSE') \n\
start = time.time() \n\
for begin, end in zip(random_dates, random_dates[1:]): \n\
_ = trade_calendar.valid_days(begin, end) \n\
print(f'{time.time()-start:.2f}') \n\
" > sample.py
CMD ["python", "sample.py"]
@2torus
Copy link
Author

2torus commented Sep 3, 2020

run it with

docker build . -t mcal_old >/dev/null && docker run -it mcal_old
docker build --build-arg NEW="true" . -t mcal_new >/dev/null && docker run -it mcal_new 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment