bullishpy 0.13.0__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bullishpy might be problematic. Click here for more details.
- bullish/analysis/analysis.py +35 -3
- bullish/analysis/constants.py +403 -0
- bullish/analysis/filter.py +2 -405
- bullish/analysis/functions.py +18 -28
- bullish/analysis/indicators.py +160 -85
- bullish/analysis/industry_views.py +201 -0
- bullish/analysis/predefined_filters.py +81 -248
- bullish/app/app.py +5 -1
- bullish/database/alembic/versions/040b15fba458_.py +61 -0
- bullish/database/alembic/versions/3e1a14c41916_.py +51 -0
- bullish/database/alembic/versions/5b10ee7604c1_.py +44 -0
- bullish/database/alembic/versions/ec25c8fa449f_.py +63 -0
- bullish/database/crud.py +95 -4
- bullish/database/schemas.py +26 -0
- bullish/figures/figures.py +28 -5
- bullish/interface/interface.py +38 -0
- {bullishpy-0.13.0.dist-info → bullishpy-0.15.0.dist-info}/METADATA +3 -2
- {bullishpy-0.13.0.dist-info → bullishpy-0.15.0.dist-info}/RECORD +20 -14
- {bullishpy-0.13.0.dist-info → bullishpy-0.15.0.dist-info}/WHEEL +0 -0
- {bullishpy-0.13.0.dist-info → bullishpy-0.15.0.dist-info}/entry_points.txt +0 -0
bullish/analysis/filter.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
from datetime import date
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import get_args, Any, Optional, List, Tuple, Type, Dict
|
|
4
4
|
|
|
5
5
|
from bearish.types import SeriesLength # type: ignore
|
|
6
6
|
from pydantic import BaseModel, Field, ConfigDict
|
|
@@ -14,411 +14,8 @@ from bullish.analysis.analysis import (
|
|
|
14
14
|
TechnicalAnalysis,
|
|
15
15
|
AnalysisView,
|
|
16
16
|
)
|
|
17
|
+
from bullish.analysis.constants import Industry, IndustryGroup, Sector, Country
|
|
17
18
|
|
|
18
|
-
Industry = Literal[
|
|
19
|
-
"Publishing",
|
|
20
|
-
"Internet Retail",
|
|
21
|
-
"Scientific & Technical Instruments",
|
|
22
|
-
"Engineering & Construction",
|
|
23
|
-
"Diagnostics & Research",
|
|
24
|
-
"Software - Infrastructure",
|
|
25
|
-
"Thermal Coal",
|
|
26
|
-
"Software - Application",
|
|
27
|
-
"Auto Manufacturers",
|
|
28
|
-
"Farm Products",
|
|
29
|
-
"Medical Devices",
|
|
30
|
-
"Education & Training Services",
|
|
31
|
-
"Auto Parts",
|
|
32
|
-
"Specialty Chemicals",
|
|
33
|
-
"Marine Shipping",
|
|
34
|
-
"Biotechnology",
|
|
35
|
-
"Real Estate Services",
|
|
36
|
-
"Gold",
|
|
37
|
-
"Entertainment",
|
|
38
|
-
"Specialty Retail",
|
|
39
|
-
"Utilities - Independent Power Producers",
|
|
40
|
-
"Steel",
|
|
41
|
-
"Mortgage Finance",
|
|
42
|
-
"Communication Equipment",
|
|
43
|
-
"Drug Manufacturers - Specialty & Generic",
|
|
44
|
-
"Electronic Gaming & Multimedia",
|
|
45
|
-
"Banks - Regional",
|
|
46
|
-
"Oil & Gas E&P",
|
|
47
|
-
"Travel Services",
|
|
48
|
-
"Real Estate - Diversified",
|
|
49
|
-
"Telecom Services",
|
|
50
|
-
"Uranium",
|
|
51
|
-
"Consulting Services",
|
|
52
|
-
"Waste Management",
|
|
53
|
-
"Agricultural Inputs",
|
|
54
|
-
"Utilities - Diversified",
|
|
55
|
-
"Auto & Truck Dealerships",
|
|
56
|
-
"Confectioners",
|
|
57
|
-
"Other Industrial Metals & Mining",
|
|
58
|
-
"Beverages - Wineries & Distilleries",
|
|
59
|
-
"Oil & Gas Midstream",
|
|
60
|
-
"Recreational Vehicles",
|
|
61
|
-
"Electrical Equipment & Parts",
|
|
62
|
-
"Household & Personal Products",
|
|
63
|
-
"Packaging & Containers",
|
|
64
|
-
"REIT - Specialty",
|
|
65
|
-
"Home Improvement Retail",
|
|
66
|
-
"Electronic Components",
|
|
67
|
-
"Asset Management",
|
|
68
|
-
"Consumer Electronics",
|
|
69
|
-
"Conglomerates",
|
|
70
|
-
"Health Information Services",
|
|
71
|
-
"Medical Instruments & Supplies",
|
|
72
|
-
"Building Products & Equipment",
|
|
73
|
-
"Information Technology Services",
|
|
74
|
-
"Specialty Industrial Machinery",
|
|
75
|
-
"Food Distribution",
|
|
76
|
-
"Packaged Foods",
|
|
77
|
-
"Rental & Leasing Services",
|
|
78
|
-
"Medical Distribution",
|
|
79
|
-
"Grocery Stores",
|
|
80
|
-
"Advertising Agencies",
|
|
81
|
-
"Beverages - Non - Alcoholic",
|
|
82
|
-
"Apparel Manufacturing",
|
|
83
|
-
"Oil & Gas Equipment & Services",
|
|
84
|
-
"Coking Coal",
|
|
85
|
-
"Industrial Distribution",
|
|
86
|
-
"Restaurants",
|
|
87
|
-
"Beverages - Brewers",
|
|
88
|
-
"Chemicals",
|
|
89
|
-
"Real Estate - Development",
|
|
90
|
-
"Credit Services",
|
|
91
|
-
"Tobacco",
|
|
92
|
-
"Metal Fabrication",
|
|
93
|
-
"Building Materials",
|
|
94
|
-
"Residential Construction",
|
|
95
|
-
"Specialty Business Services",
|
|
96
|
-
"REIT - Hotel & Motel",
|
|
97
|
-
"Internet Content & Information",
|
|
98
|
-
"Lodging",
|
|
99
|
-
"Furnishings, Fixtures & Appliances",
|
|
100
|
-
"Airlines",
|
|
101
|
-
"Computer Hardware",
|
|
102
|
-
"Integrated Freight & Logistics",
|
|
103
|
-
"Solar",
|
|
104
|
-
"Capital Markets",
|
|
105
|
-
"Leisure",
|
|
106
|
-
"Airports & Air Services",
|
|
107
|
-
"Aluminum",
|
|
108
|
-
"Insurance Brokers",
|
|
109
|
-
"Semiconductors",
|
|
110
|
-
"REIT - Retail",
|
|
111
|
-
"Luxury Goods",
|
|
112
|
-
"Lumber & Wood Production",
|
|
113
|
-
"REIT - Mortgage",
|
|
114
|
-
"Semiconductor Equipment & Materials",
|
|
115
|
-
"Aerospace & Defense",
|
|
116
|
-
"Security & Protection Services",
|
|
117
|
-
"Utilities - Renewable",
|
|
118
|
-
"Utilities - Regulated Gas",
|
|
119
|
-
"Apparel Retail",
|
|
120
|
-
"Pollution & Treatment Controls",
|
|
121
|
-
"Broadcasting",
|
|
122
|
-
"Resorts & Casinos",
|
|
123
|
-
"Other Precious Metals & Mining",
|
|
124
|
-
"Financial Data & Stock Exchanges",
|
|
125
|
-
"Footwear & Accessories",
|
|
126
|
-
"Medical Care Facilities",
|
|
127
|
-
"Electronics & Computer Distribution",
|
|
128
|
-
"Gambling",
|
|
129
|
-
"Tools & Accessories",
|
|
130
|
-
"Insurance - Property & Casualty",
|
|
131
|
-
"Utilities - Regulated Water",
|
|
132
|
-
"Insurance - Specialty",
|
|
133
|
-
"Personal Services",
|
|
134
|
-
"Pharmaceutical Retailers",
|
|
135
|
-
"Farm & Heavy Construction Machinery",
|
|
136
|
-
"Utilities - Regulated Electric",
|
|
137
|
-
"Department Stores",
|
|
138
|
-
"Staffing & Employment Services",
|
|
139
|
-
"Textile Manufacturing",
|
|
140
|
-
"Silver",
|
|
141
|
-
"REIT - Industrial",
|
|
142
|
-
"REIT - Diversified",
|
|
143
|
-
"Copper",
|
|
144
|
-
"Business Equipment & Supplies",
|
|
145
|
-
"Infrastructure Operations",
|
|
146
|
-
"Trucking",
|
|
147
|
-
"Insurance - Reinsurance",
|
|
148
|
-
"Insurance - Diversified",
|
|
149
|
-
"Drug Manufacturers - General",
|
|
150
|
-
"Oil & Gas Drilling",
|
|
151
|
-
"Banks - Diversified",
|
|
152
|
-
"REIT - Residential",
|
|
153
|
-
"Oil & Gas Refining & Marketing",
|
|
154
|
-
"Shell Companies",
|
|
155
|
-
"Financial Conglomerates",
|
|
156
|
-
"Paper & Paper Products",
|
|
157
|
-
"Insurance - Life",
|
|
158
|
-
"REIT - Office",
|
|
159
|
-
"Railroads",
|
|
160
|
-
"Oil & Gas Integrated",
|
|
161
|
-
"Healthcare Plans",
|
|
162
|
-
"REIT - Healthcare Facilities",
|
|
163
|
-
"Discount Stores",
|
|
164
|
-
]
|
|
165
|
-
|
|
166
|
-
IndustryGroup = Literal[
|
|
167
|
-
"publishing",
|
|
168
|
-
"internet-retail",
|
|
169
|
-
"scientific-technical-instruments",
|
|
170
|
-
"engineering-construction",
|
|
171
|
-
"diagnostics-research",
|
|
172
|
-
"software-infrastructure",
|
|
173
|
-
"thermal-coal",
|
|
174
|
-
"software-application",
|
|
175
|
-
"auto-manufacturers",
|
|
176
|
-
"farm-products",
|
|
177
|
-
"medical-devices",
|
|
178
|
-
"education-training-services",
|
|
179
|
-
"auto-parts",
|
|
180
|
-
"specialty-chemicals",
|
|
181
|
-
"marine-shipping",
|
|
182
|
-
"biotechnology",
|
|
183
|
-
"real-estate-services",
|
|
184
|
-
"gold",
|
|
185
|
-
"entertainment",
|
|
186
|
-
"specialty-retail",
|
|
187
|
-
"utilities-independent-power-producers",
|
|
188
|
-
"steel",
|
|
189
|
-
"mortgage-finance",
|
|
190
|
-
"communication-equipment",
|
|
191
|
-
"drug-manufacturers-specialty-generic",
|
|
192
|
-
"electronic-gaming-multimedia",
|
|
193
|
-
"banks-regional",
|
|
194
|
-
"oil-gas-e-p",
|
|
195
|
-
"travel-services",
|
|
196
|
-
"real-estate-diversified",
|
|
197
|
-
"telecom-services",
|
|
198
|
-
"uranium",
|
|
199
|
-
"consulting-services",
|
|
200
|
-
"waste-management",
|
|
201
|
-
"agricultural-inputs",
|
|
202
|
-
"utilities-diversified",
|
|
203
|
-
"auto-truck-dealerships",
|
|
204
|
-
"confectioners",
|
|
205
|
-
"other-industrial-metals-mining",
|
|
206
|
-
"beverages-wineries-distilleries",
|
|
207
|
-
"oil-gas-midstream",
|
|
208
|
-
"recreational-vehicles",
|
|
209
|
-
"electrical-equipment-parts",
|
|
210
|
-
"household-personal-products",
|
|
211
|
-
"packaging-containers",
|
|
212
|
-
"reit-specialty",
|
|
213
|
-
"home-improvement-retail",
|
|
214
|
-
"electronic-components",
|
|
215
|
-
"asset-management",
|
|
216
|
-
"consumer-electronics",
|
|
217
|
-
"conglomerates",
|
|
218
|
-
"health-information-services",
|
|
219
|
-
"medical-instruments-supplies",
|
|
220
|
-
"building-products-equipment",
|
|
221
|
-
"information-technology-services",
|
|
222
|
-
"specialty-industrial-machinery",
|
|
223
|
-
"food-distribution",
|
|
224
|
-
"packaged-foods",
|
|
225
|
-
"rental-leasing-services",
|
|
226
|
-
"medical-distribution",
|
|
227
|
-
"grocery-stores",
|
|
228
|
-
"advertising-agencies",
|
|
229
|
-
"beverages-non-alcoholic",
|
|
230
|
-
"apparel-manufacturing",
|
|
231
|
-
"oil-gas-equipment-services",
|
|
232
|
-
"coking-coal",
|
|
233
|
-
"industrial-distribution",
|
|
234
|
-
"restaurants",
|
|
235
|
-
"beverages-brewers",
|
|
236
|
-
"chemicals",
|
|
237
|
-
"real-estate-development",
|
|
238
|
-
"credit-services",
|
|
239
|
-
"tobacco",
|
|
240
|
-
"metal-fabrication",
|
|
241
|
-
"building-materials",
|
|
242
|
-
"residential-construction",
|
|
243
|
-
"specialty-business-services",
|
|
244
|
-
"reit-hotel-motel",
|
|
245
|
-
"internet-content-information",
|
|
246
|
-
"lodging",
|
|
247
|
-
"furnishings-fixtures-appliances",
|
|
248
|
-
"airlines",
|
|
249
|
-
"computer-hardware",
|
|
250
|
-
"integrated-freight-logistics",
|
|
251
|
-
"solar",
|
|
252
|
-
"capital-markets",
|
|
253
|
-
"leisure",
|
|
254
|
-
"airports-air-services",
|
|
255
|
-
"aluminum",
|
|
256
|
-
"insurance-brokers",
|
|
257
|
-
"semiconductors",
|
|
258
|
-
"reit-retail",
|
|
259
|
-
"luxury-goods",
|
|
260
|
-
"lumber-wood-production",
|
|
261
|
-
"reit-mortgage",
|
|
262
|
-
"semiconductor-equipment-materials",
|
|
263
|
-
"aerospace-defense",
|
|
264
|
-
"security-protection-services",
|
|
265
|
-
"utilities-renewable",
|
|
266
|
-
"utilities-regulated-gas",
|
|
267
|
-
"apparel-retail",
|
|
268
|
-
"pollution-treatment-controls",
|
|
269
|
-
"broadcasting",
|
|
270
|
-
"resorts-casinos",
|
|
271
|
-
"other-precious-metals-mining",
|
|
272
|
-
"financial-data-stock-exchanges",
|
|
273
|
-
"footwear-accessories",
|
|
274
|
-
"medical-care-facilities",
|
|
275
|
-
"electronics-computer-distribution",
|
|
276
|
-
"gambling",
|
|
277
|
-
"tools-accessories",
|
|
278
|
-
"insurance-property-casualty",
|
|
279
|
-
"utilities-regulated-water",
|
|
280
|
-
"insurance-specialty",
|
|
281
|
-
"personal-services",
|
|
282
|
-
"pharmaceutical-retailers",
|
|
283
|
-
"farm-heavy-construction-machinery",
|
|
284
|
-
"utilities-regulated-electric",
|
|
285
|
-
"department-stores",
|
|
286
|
-
"staffing-employment-services",
|
|
287
|
-
"textile-manufacturing",
|
|
288
|
-
"silver",
|
|
289
|
-
"reit-industrial",
|
|
290
|
-
"reit-diversified",
|
|
291
|
-
"copper",
|
|
292
|
-
"business-equipment-supplies",
|
|
293
|
-
"infrastructure-operations",
|
|
294
|
-
"trucking",
|
|
295
|
-
"insurance-reinsurance",
|
|
296
|
-
"insurance-diversified",
|
|
297
|
-
"drug-manufacturers-general",
|
|
298
|
-
"oil-gas-drilling",
|
|
299
|
-
"banks-diversified",
|
|
300
|
-
"reit-residential",
|
|
301
|
-
"oil-gas-refining-marketing",
|
|
302
|
-
"shell-companies",
|
|
303
|
-
"financial-conglomerates",
|
|
304
|
-
"paper-paper-products",
|
|
305
|
-
"insurance-life",
|
|
306
|
-
"reit-office",
|
|
307
|
-
"railroads",
|
|
308
|
-
"oil-gas-integrated",
|
|
309
|
-
"healthcare-plans",
|
|
310
|
-
"reit-healthcare-facilities",
|
|
311
|
-
"discount-stores",
|
|
312
|
-
]
|
|
313
|
-
|
|
314
|
-
Sector = Literal[
|
|
315
|
-
"Communication Services",
|
|
316
|
-
"Consumer Cyclical",
|
|
317
|
-
"Technology",
|
|
318
|
-
"Industrials",
|
|
319
|
-
"Healthcare",
|
|
320
|
-
"Energy",
|
|
321
|
-
"Consumer Defensive",
|
|
322
|
-
"Basic Materials",
|
|
323
|
-
"Real Estate",
|
|
324
|
-
"Utilities",
|
|
325
|
-
"Financial Services",
|
|
326
|
-
"Conglomerates",
|
|
327
|
-
]
|
|
328
|
-
|
|
329
|
-
Country = Literal[
|
|
330
|
-
"Australia",
|
|
331
|
-
"China",
|
|
332
|
-
"Japan",
|
|
333
|
-
"United kingdom",
|
|
334
|
-
"United states",
|
|
335
|
-
"Poland",
|
|
336
|
-
"Switzerland",
|
|
337
|
-
"Canada",
|
|
338
|
-
"Greece",
|
|
339
|
-
"Spain",
|
|
340
|
-
"Germany",
|
|
341
|
-
"Indonesia",
|
|
342
|
-
"Belgium",
|
|
343
|
-
"France",
|
|
344
|
-
"Netherlands",
|
|
345
|
-
"British virgin islands",
|
|
346
|
-
"Italy",
|
|
347
|
-
"Hungary",
|
|
348
|
-
"Austria",
|
|
349
|
-
"Finland",
|
|
350
|
-
"Sweden",
|
|
351
|
-
"Bermuda",
|
|
352
|
-
"Taiwan",
|
|
353
|
-
"Israel",
|
|
354
|
-
"Ukraine",
|
|
355
|
-
"Singapore",
|
|
356
|
-
"Jersey",
|
|
357
|
-
"Ireland",
|
|
358
|
-
"Luxembourg",
|
|
359
|
-
"Cyprus",
|
|
360
|
-
"Cayman islands",
|
|
361
|
-
"Norway",
|
|
362
|
-
"Denmark",
|
|
363
|
-
"Hong kong",
|
|
364
|
-
"New zealand",
|
|
365
|
-
"Kazakhstan",
|
|
366
|
-
"Nigeria",
|
|
367
|
-
"Argentina",
|
|
368
|
-
"Brazil",
|
|
369
|
-
"Czech republic",
|
|
370
|
-
"Mauritius",
|
|
371
|
-
"South africa",
|
|
372
|
-
"India",
|
|
373
|
-
"Mexico",
|
|
374
|
-
"Mongolia",
|
|
375
|
-
"Slovenia",
|
|
376
|
-
"Thailand",
|
|
377
|
-
"Malaysia",
|
|
378
|
-
"Costa rica",
|
|
379
|
-
"Isle of man",
|
|
380
|
-
"Egypt",
|
|
381
|
-
"Turkey",
|
|
382
|
-
"United arab emirates",
|
|
383
|
-
"Colombia",
|
|
384
|
-
"Gibraltar",
|
|
385
|
-
"Malta",
|
|
386
|
-
"Liechtenstein",
|
|
387
|
-
"Guernsey",
|
|
388
|
-
"Peru",
|
|
389
|
-
"Estonia",
|
|
390
|
-
"French guiana",
|
|
391
|
-
"Portugal",
|
|
392
|
-
"Uruguay",
|
|
393
|
-
"Chile",
|
|
394
|
-
"Martinique",
|
|
395
|
-
"Monaco",
|
|
396
|
-
"Panama",
|
|
397
|
-
"Papua new guinea",
|
|
398
|
-
"South korea",
|
|
399
|
-
"Macau",
|
|
400
|
-
"Gabon",
|
|
401
|
-
"Romania",
|
|
402
|
-
"Senegal",
|
|
403
|
-
"Morocco",
|
|
404
|
-
"Jordan",
|
|
405
|
-
"Lithuania",
|
|
406
|
-
"Dominican republic",
|
|
407
|
-
"Reunion",
|
|
408
|
-
"Zambia",
|
|
409
|
-
"Cambodia",
|
|
410
|
-
"Myanmar",
|
|
411
|
-
"Bahamas",
|
|
412
|
-
"Philippines",
|
|
413
|
-
"Bangladesh",
|
|
414
|
-
"Latvia",
|
|
415
|
-
"Vietnam",
|
|
416
|
-
"Iceland",
|
|
417
|
-
"Azerbaijan",
|
|
418
|
-
"Georgia",
|
|
419
|
-
"Liberia",
|
|
420
|
-
"Kenya",
|
|
421
|
-
]
|
|
422
19
|
SIZE_RANGE = 2
|
|
423
20
|
|
|
424
21
|
|
bullish/analysis/functions.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import datetime
|
|
2
1
|
import logging
|
|
3
2
|
from datetime import date
|
|
4
3
|
from typing import Optional, Callable, cast
|
|
@@ -16,10 +15,17 @@ except Exception:
|
|
|
16
15
|
logger.warning("Talib is not installed, skipping analysis")
|
|
17
16
|
|
|
18
17
|
|
|
18
|
+
def cross_simple(
|
|
19
|
+
series_a: pd.Series, series_b: pd.Series, above: bool = True
|
|
20
|
+
) -> pd.Series:
|
|
21
|
+
crossing = ta.cross(series_a=series_a, series_b=series_b, above=above)
|
|
22
|
+
return crossing # type: ignore
|
|
23
|
+
|
|
24
|
+
|
|
19
25
|
def cross(
|
|
20
26
|
series_a: pd.Series, series_b: pd.Series, above: bool = True
|
|
21
27
|
) -> Optional[date]:
|
|
22
|
-
crossing =
|
|
28
|
+
crossing = cross_simple(series_a=series_a, series_b=series_b, above=above)
|
|
23
29
|
if not crossing[crossing == 1].index.empty:
|
|
24
30
|
return crossing[crossing == 1].last_valid_index().date() # type: ignore
|
|
25
31
|
return None
|
|
@@ -32,10 +38,10 @@ def cross_value(series: pd.Series, number: int, above: bool = True) -> Optional[
|
|
|
32
38
|
def cross_value_series(
|
|
33
39
|
series_a: pd.Series, number: int, above: bool = True
|
|
34
40
|
) -> pd.Series:
|
|
35
|
-
crossing =
|
|
36
|
-
series_a
|
|
41
|
+
crossing = cross_simple(
|
|
42
|
+
series_a, pd.Series(number, index=series_a.index), above=above
|
|
37
43
|
)
|
|
38
|
-
return crossing
|
|
44
|
+
return crossing
|
|
39
45
|
|
|
40
46
|
|
|
41
47
|
def compute_adx(data: pd.DataFrame) -> pd.DataFrame:
|
|
@@ -282,24 +288,6 @@ def compute_price(data: pd.DataFrame) -> pd.DataFrame:
|
|
|
282
288
|
return results
|
|
283
289
|
|
|
284
290
|
|
|
285
|
-
def compute_percentile_return_after_rsi_crossover(
|
|
286
|
-
data: pd.DataFrame, rsi_threshold: int = 45, period: int = 90
|
|
287
|
-
) -> float:
|
|
288
|
-
data_ = cross_value_series(data.RSI, rsi_threshold)
|
|
289
|
-
values = []
|
|
290
|
-
for crossing_date in data_[data_ == 1].index:
|
|
291
|
-
data_crossed = data[
|
|
292
|
-
(data.index >= crossing_date)
|
|
293
|
-
& (data.index <= crossing_date + datetime.timedelta(days=period))
|
|
294
|
-
]
|
|
295
|
-
v = (
|
|
296
|
-
data_crossed.CLOSE.pct_change(periods=len(data_crossed.CLOSE) - 1).iloc[-1]
|
|
297
|
-
* 100
|
|
298
|
-
)
|
|
299
|
-
values.append(v)
|
|
300
|
-
return float(np.percentile(values, 30))
|
|
301
|
-
|
|
302
|
-
|
|
303
291
|
def find_last_true_run_start(series: pd.Series) -> Optional[date]:
|
|
304
292
|
if not series.iloc[-1]:
|
|
305
293
|
return None
|
|
@@ -311,12 +299,14 @@ def find_last_true_run_start(series: pd.Series) -> Optional[date]:
|
|
|
311
299
|
return series.index[last_true_run_start].date() # type: ignore
|
|
312
300
|
|
|
313
301
|
|
|
314
|
-
def
|
|
302
|
+
def sma_50_above_sma_200(data: pd.DataFrame) -> Optional[date]:
|
|
303
|
+
date_1 = find_last_true_run_start(data.SMA_50 > data.SMA_200)
|
|
304
|
+
return date_1
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def price_above_sma50(data: pd.DataFrame) -> Optional[date]:
|
|
315
308
|
date_1 = find_last_true_run_start(data.SMA_50 < data.CLOSE)
|
|
316
|
-
|
|
317
|
-
if date_1 is None or date_2 is None:
|
|
318
|
-
return None
|
|
319
|
-
return max(date_1, date_2)
|
|
309
|
+
return date_1
|
|
320
310
|
|
|
321
311
|
|
|
322
312
|
class IndicatorFunction(BaseModel):
|