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

Method differences between trading_calendars and pandas_market_calendars #151

Open
gerrymanoim opened this issue Sep 4, 2020 · 0 comments

Comments

@gerrymanoim
Copy link
Collaborator

gerrymanoim commented Sep 4, 2020

re rsheftel/pandas_market_calendars#41

import pandas as pd
import trading_calendars as tc
import pandas_market_calendars as pmc

def method_comparison(tc_methods, pmc_methods):
  # must be an easier way to do this
  tc_col = tc_methods.copy()
  pmc_methods_set = set(pmc_methods)

  pmc_col, pmc_only = [], []

  for method in tc_col:
    if method in pmc_methods_set:
      pmc_col.append(method)
    else:
      pmc_col.append(None)
  
  pmc_only = list(pmc_methods_set - set(pmc_col))
  pmc_col.extend(pmc_only)
  tc_col.extend([None for _ in pmc_only])
  return pd.DataFrame(
    {'trading_calendars': tc_col, 'pandas_market_calendars': pmc_col}
  )

Calendar level differences

nyse_tc = tc.get_calendar("NYSE")
nyse_pmc = pmc.get_calendar("NYSE")
calendar_method_comparison = method_comparison(dir(nyse_tc), dir(nyse_pmc))
trading_calendars pandas_market_calendars
0 abstractmethods abstractmethods
1 class class
2 delattr delattr
3 dict dict
4 dir dir
5 doc doc
6 eq eq
7 format format
8 ge ge
9 getattribute getattribute
10 gt gt
11 hash hash
12 init init
13 init_subclass init_subclass
14 le le
15 lt lt
16 module module
17 ne ne
18 new new
19 reduce reduce
20 reduce_ex reduce_ex
21 repr repr
22 setattr setattr
23 sizeof sizeof
24 str str
25 subclasshook subclasshook
26 weakref weakref
27 _abc_cache _abc_cache
28 _abc_negative_cache _abc_negative_cache
29 _abc_negative_cache_version _abc_negative_cache_version
30 _abc_registry _abc_registry
31 _calculate_special_closes _calculate_special_closes
32 _calculate_special_opens _calculate_special_opens
33 _closes
34 _early_closes
35 _late_opens
36 _minute_to_session_label_cache
37 _minutes_per_session
38 _opens
39 _special_dates _special_dates
40 _trading_minutes_nanos
41 adhoc_holidays adhoc_holidays
42 all_minutes
43 all_sessions
44 close_offset close_offset
45 close_times
46 closes
47 day
48 early_closes early_closes
49 execution_minutes_for_session
50 execution_minutes_for_sessions_in_range
51 execution_time_from_close
52 execution_time_from_open
53 first_session
54 first_trading_session
55 is_open_on_minute
56 is_session
57 last_session
58 last_trading_session
59 late_opens
60 market_closes_nanos
61 market_opens_nanos
62 minute_index_to_session_labels
63 minute_to_session_label
64 minutes_count_for_sessions_in_range
65 minutes_for_session
66 minutes_for_sessions_in_range
67 minutes_in_range
68 minutes_window
69 name name
70 next_close
71 next_minute
72 next_open
73 next_session_label
74 open_and_close_for_session
75 open_offset open_offset
76 open_times
77 opens
78 previous_close
79 previous_minute
80 previous_open
81 previous_session_label
82 regular_early_close regular_early_close
83 regular_holidays regular_holidays
84 schedule schedule
85 session_close
86 session_closes_in_range
87 session_distance
88 session_open
89 session_opens_in_range
90 sessions_in_range
91 sessions_window
92 special_closes special_closes
93 special_closes_adhoc special_closes_adhoc
94 special_opens special_opens
95 special_opens_adhoc special_opens_adhoc
96 tz tz
97 weekmask weekmask
98 holidays
99 open_time
100 factory
101 calendar_names
102 break_end
103 _close_time
104 _regmeta_classes
105 aliases
106 _get_current_time
107 close_time_default
108 break_start
109 valid_days
110 is_open_now
111 open_time_default
112 _regmeta_instance_factory
113 close_time
114 open_at_time
115 _open_time
116 _holidays
117 _regmeta_class_factory
118 _regmeta_class_registry

Module level differences

def clean_methods(l):
  return [m for m in l if "exchange_" not in m]

tc_methods = clean_methods(dir(tc))
pmc_methods = clean_methods(dir(pmc))
module_method_comparison = method_comparison(tc_methods, pmc_methods)
trading_calendars pandas_market_calendars
0 TradingCalendar
1 all all
2 builtins builtins
3 cached cached
4 doc doc
5 file file
6 loader loader
7 name name
8 package package
9 path path
10 spec spec
11 version version
12 _version
13 always_open
14 calendar_helpers
15 calendar_utils calendar_utils
16 clear_calendars
17 common_holidays
18 deregister_calendar
19 errors
20 get_calendar get_calendar
21 precomputed_trading_calendar
22 register_calendar
23 register_calendar_alias
24 register_calendar_type
25 resolve_alias
26 trading_calendar
27 us_futures_calendar
28 us_holidays
29 utils
30 weekday_calendar
31 xbkk_holidays
32 xkls_holidays
33 xtks_holidays
34 calendar_registry
35 holidays_oz
36 MarketCalendar
37 holidays_us
38 holidays_uk
39 convert_freq
40 merge_schedules
41 get_calendar_names get_calendar_names
42 holidays_cn
43 date_range
44 jpx_equinox
45 market_calendar
46 class_registry
47 holidays_jp
48 pkg_resources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant