You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how to do a drop-in replacement of "trading-calendars" with "exchange_calendars" in dependent packages to get around bug "TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType' " ?
#233
Closed
richlysakowski opened this issue
Sep 17, 2022
· 1 comment
I have a package that is dependent on trading-calendars, but trading-calendars has a bug that was fixed in exchange_calendars.
I don't have any idea how to fix the bug: NP_NAT = np.array([pd.NaT], dtype=np.int64)[0] TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
The trading-calendars bug is as follows:
File "C:\ProgramData\Anaconda3\envs\topss\lib\site-packages\trading_calendars\calendar_helpers.py", line 6, in
NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
The exchange_calendars package is a MAJOR overhaul of trading-calendars. The package exchange_calendars has 100s of code changes.
Below is the ONLY place where the trading-calendars` package is used in the dependent package that I am using.
Can anyone tell me what changes how to use exchange_calendars instead for the calculation done by the function get_market_year_fraction() below?
def get_market_year_fraction(start_date, end_date, adjustment):
"""Calculate the year fraction until the expiry date of an option in trading minutes.
Parameters
----------
start_date : string
Inclusive start date for the time remaining [MM-DD-YYYY] ie: ('10-18-2020')
end_date : string
Inclusive end date for the time remaining [MM-DD-YYYY] ie: ('10-20-2020')
adjustment : float
[mins] An adjustment factor for handling intraday calculations
"""
mins = 390*len(get_calendar('XNYS').sessions_in_range(start_date, end_date)) + adjustment
return mins/(252*390)
The text was updated successfully, but these errors were encountered:
I have a package that is dependent on
trading-calendars
, buttrading-calendars
has a bug that was fixed inexchange_calendars
.I don't have any idea how to fix the bug: NP_NAT = np.array([pd.NaT], dtype=np.int64)[0] TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
The
trading-calendars
bug is as follows:File "C:\ProgramData\Anaconda3\envs\topss\lib\site-packages\trading_calendars\calendar_helpers.py", line 6, in
NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
The
exchange_calendars
package is a MAJOR overhaul oftrading-calendars
. The packageexchange_calendars
has 100s of code changes.Below is the ONLY place where the trading-calendars` package is used in the dependent package that I am using.
Can anyone tell me what changes how to use
exchange_calendars
instead for the calculation done by the functionget_market_year_fraction()
below?The text was updated successfully, but these errors were encountered: