I want to close all my position before er earnings to lower the volatility.
My data looks like:
date symbol
2010/1/10 mu
2010/1/12 aapl
....
so, I want to close all position on 2010/1/9 if I have mu, and close all position on 2010/1/11 if I have aapl.
I am trying to shift the dataframe by shift(1,freq='D'), but if 2010/1/9 is Sat. I want to shift to 2010/1/8,which
is a trading day.
Can someone help me on this?
Best