|
3 | 3 | """ |
4 | 4 | .. moduleauthor:: Kevin Johnson |
5 | 5 | """ |
6 | | -from importlib.util import find_spec |
7 | | -from pathlib import Path |
8 | | -from pandas_ta_classic.core import * |
9 | | - |
10 | | -try: |
11 | | - from pkg_resources import get_distribution, DistributionNotFound |
| 6 | +# Import metadata from _meta module to avoid circular imports |
| 7 | +from pandas_ta_classic._meta import ( |
| 8 | + Category, |
| 9 | + Imports, |
| 10 | + version, |
| 11 | + CANGLE_AGG, |
| 12 | + EXCHANGE_TZ, |
| 13 | + RATE, |
| 14 | +) |
12 | 15 |
|
13 | | - try: |
14 | | - _dist = get_distribution("pandas-ta-classic") |
15 | | - try: |
16 | | - # Normalize case for Windows systems |
17 | | - here = Path(_dist.location) / __file__ |
18 | | - if not here.exists(): |
19 | | - # not installed, but there is another version that *is* |
20 | | - raise DistributionNotFound |
21 | | - except DistributionNotFound: |
22 | | - __version__ = "0.3.14b1" |
23 | | - else: |
24 | | - __version__ = _dist.version |
25 | | - except DistributionNotFound: |
26 | | - __version__ = "0.3.14b1" |
27 | | -except ImportError: |
28 | | - # Fallback for when pkg_resources is not available |
29 | | - __version__ = "0.3.14b1" |
| 16 | +# Import core functionality |
| 17 | +from pandas_ta_classic.core import * |
30 | 18 |
|
31 | | -version = __version__ |
| 19 | +__version__ = version |
32 | 20 | __description__ = ( |
33 | 21 | "An easy to use Python 3 Pandas Extension with 130+ Technical Analysis Indicators. " |
34 | 22 | "Can be called from a Pandas DataFrame or standalone like TA-Lib. Correlation tested with TA-Lib. " |
35 | 23 | "This is the classic/community maintained version." |
36 | 24 | ) |
37 | | - |
38 | | -Imports = { |
39 | | - "alphaVantage-api": find_spec("alphaVantageAPI") is not None, |
40 | | - "matplotlib": find_spec("matplotlib") is not None, |
41 | | - "mplfinance": find_spec("mplfinance") is not None, |
42 | | - "numba": find_spec("numba") is not None, |
43 | | - "yaml": find_spec("yaml") is not None, |
44 | | - "scipy": find_spec("scipy") is not None, |
45 | | - "sklearn": find_spec("sklearn") is not None, |
46 | | - "statsmodels": find_spec("statsmodels") is not None, |
47 | | - "stochastic": find_spec("stochastic") is not None, |
48 | | - "talib": find_spec("talib") is not None, |
49 | | - "tqdm": find_spec("tqdm") is not None, |
50 | | - "vectorbt": find_spec("vectorbt") is not None, |
51 | | - "yfinance": find_spec("yfinance") is not None, |
52 | | -} |
53 | | - |
54 | | -# Not ideal and not dynamic but it works. |
55 | | -# Will find a dynamic solution later. |
56 | | -Category = { |
57 | | - # Candles |
58 | | - "candles": ["cdl_pattern", "cdl_z", "ha"], |
59 | | - # Cycles |
60 | | - "cycles": ["ebsw"], |
61 | | - # Momentum |
62 | | - "momentum": [ |
63 | | - "ao", |
64 | | - "apo", |
65 | | - "bias", |
66 | | - "bop", |
67 | | - "brar", |
68 | | - "cci", |
69 | | - "cfo", |
70 | | - "cg", |
71 | | - "cmo", |
72 | | - "coppock", |
73 | | - "cti", |
74 | | - "er", |
75 | | - "eri", |
76 | | - "fisher", |
77 | | - "inertia", |
78 | | - "kdj", |
79 | | - "kst", |
80 | | - "macd", |
81 | | - "mom", |
82 | | - "pgo", |
83 | | - "ppo", |
84 | | - "psl", |
85 | | - "pvo", |
86 | | - "qqe", |
87 | | - "roc", |
88 | | - "rsi", |
89 | | - "rsx", |
90 | | - "rvgi", |
91 | | - "slope", |
92 | | - "smi", |
93 | | - "squeeze", |
94 | | - "squeeze_pro", |
95 | | - "stc", |
96 | | - "stoch", |
97 | | - "stochrsi", |
98 | | - "td_seq", |
99 | | - "trix", |
100 | | - "tsi", |
101 | | - "uo", |
102 | | - "willr", |
103 | | - ], |
104 | | - # Overlap |
105 | | - "overlap": [ |
106 | | - "alma", |
107 | | - "dema", |
108 | | - "ema", |
109 | | - "fwma", |
110 | | - "hilo", |
111 | | - "hl2", |
112 | | - "hlc3", |
113 | | - "hma", |
114 | | - "ichimoku", |
115 | | - "jma", |
116 | | - "kama", |
117 | | - "linreg", |
118 | | - "mcgd", |
119 | | - "midpoint", |
120 | | - "midprice", |
121 | | - "ohlc4", |
122 | | - "pwma", |
123 | | - "rma", |
124 | | - "sinwma", |
125 | | - "sma", |
126 | | - "ssf", |
127 | | - "supertrend", |
128 | | - "swma", |
129 | | - "t3", |
130 | | - "tema", |
131 | | - "trima", |
132 | | - "vidya", |
133 | | - "vwap", |
134 | | - "vwma", |
135 | | - "wcp", |
136 | | - "wma", |
137 | | - "zlma", |
138 | | - ], |
139 | | - # Performance |
140 | | - "performance": ["log_return", "percent_return"], |
141 | | - # Statistics |
142 | | - "statistics": [ |
143 | | - "entropy", |
144 | | - "kurtosis", |
145 | | - "mad", |
146 | | - "median", |
147 | | - "quantile", |
148 | | - "skew", |
149 | | - "stdev", |
150 | | - "tos_stdevall", |
151 | | - "variance", |
152 | | - "zscore", |
153 | | - ], |
154 | | - # Trend |
155 | | - "trend": [ |
156 | | - "adx", |
157 | | - "amat", |
158 | | - "aroon", |
159 | | - "chop", |
160 | | - "cksp", |
161 | | - "decay", |
162 | | - "decreasing", |
163 | | - "dpo", |
164 | | - "increasing", |
165 | | - "long_run", |
166 | | - "psar", |
167 | | - "qstick", |
168 | | - "short_run", |
169 | | - "tsignals", |
170 | | - "ttm_trend", |
171 | | - "vhf", |
172 | | - "vortex", |
173 | | - "xsignals", |
174 | | - ], |
175 | | - # Volatility |
176 | | - "volatility": [ |
177 | | - "aberration", |
178 | | - "accbands", |
179 | | - "atr", |
180 | | - "bbands", |
181 | | - "donchian", |
182 | | - "hwc", |
183 | | - "kc", |
184 | | - "massi", |
185 | | - "natr", |
186 | | - "pdist", |
187 | | - "rvi", |
188 | | - "thermo", |
189 | | - "true_range", |
190 | | - "ui", |
191 | | - ], |
192 | | - # Volume, "vp" or "Volume Profile" is unique |
193 | | - "volume": [ |
194 | | - "ad", |
195 | | - "adosc", |
196 | | - "aobv", |
197 | | - "cmf", |
198 | | - "efi", |
199 | | - "eom", |
200 | | - "kvo", |
201 | | - "mfi", |
202 | | - "nvi", |
203 | | - "obv", |
204 | | - "pvi", |
205 | | - "pvol", |
206 | | - "pvr", |
207 | | - "pvt", |
208 | | - ], |
209 | | -} |
210 | | - |
211 | | -CANGLE_AGG = { |
212 | | - "open": "first", |
213 | | - "high": "max", |
214 | | - "low": "min", |
215 | | - "close": "last", |
216 | | - "volume": "sum", |
217 | | -} |
218 | | - |
219 | | -# https://www.worldtimezone.com/markets24.php |
220 | | -EXCHANGE_TZ = { |
221 | | - "NZSX": 12, |
222 | | - "ASX": 11, |
223 | | - "TSE": 9, |
224 | | - "HKE": 8, |
225 | | - "SSE": 8, |
226 | | - "SGX": 8, |
227 | | - "NSE": 5.5, |
228 | | - "DIFX": 4, |
229 | | - "RTS": 3, |
230 | | - "JSE": 2, |
231 | | - "FWB": 1, |
232 | | - "LSE": 1, |
233 | | - "BMF": -2, |
234 | | - "NYSE": -4, |
235 | | - "TSX": -4, |
236 | | -} |
237 | | - |
238 | | -RATE = { |
239 | | - "DAYS_PER_MONTH": 21, |
240 | | - "MINUTES_PER_HOUR": 60, |
241 | | - "MONTHS_PER_YEAR": 12, |
242 | | - "QUARTERS_PER_YEAR": 4, |
243 | | - "TRADING_DAYS_PER_YEAR": 252, # Keep even |
244 | | - "TRADING_HOURS_PER_DAY": 6.5, |
245 | | - "WEEKS_PER_YEAR": 52, |
246 | | - "YEARLY": 1, |
247 | | -} |
0 commit comments