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.

@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  import time
3
- from itertools import batched
3
+ from itertools import batched, chain
4
4
  from pathlib import Path
5
5
  from typing import (
6
6
  Annotated,
@@ -42,9 +42,11 @@ from bearish.models.query.query import AssetQuery, Symbols # type: ignore
42
42
  from bearish.types import TickerOnlySources # type: ignore
43
43
  from pydantic import BaseModel, BeforeValidator, Field, create_model
44
44
 
45
- from bullish.analysis.indicators import Indicators, IndicatorModels
45
+ from bullish.analysis.indicators import Indicators, IndicatorModels, SignalSeries
46
46
  from joblib import Parallel, delayed # type: ignore
47
47
 
48
+ from bullish.analysis.industry_views import compute_industry_view
49
+
48
50
  if TYPE_CHECKING:
49
51
  from bullish.database.crud import BullishDb
50
52
 
@@ -128,7 +130,7 @@ class TechnicalAnalysis(*TechnicalAnalysisModels): # type: ignore
128
130
  )
129
131
  return cls()
130
132
  try:
131
- res = Indicators().to_dict(prices)
133
+ res = Indicators().compute(prices)
132
134
  return cls(last_price=prices.close.iloc[-1], **res)
133
135
  except Exception as e:
134
136
  logger.error(
@@ -493,7 +495,37 @@ def compute_analysis(database_path: Path, ticker: Ticker) -> Analysis:
493
495
  return Analysis.from_ticker(bullish_db, ticker)
494
496
 
495
497
 
498
+ def compute_signal_series(database_path: Path, ticker: Ticker) -> List[SignalSeries]:
499
+ from bullish.database.crud import BullishDb
500
+
501
+ bullish_db = BullishDb(database_path=database_path)
502
+ indicators = Indicators()
503
+ prices = Prices.from_ticker(bullish_db, ticker)
504
+ signal_series = indicators.compute_series(prices.to_dataframe(), ticker.symbol)
505
+ return signal_series
506
+
507
+
508
+ def run_signal_series_analysis(bullish_db: "BullishDb") -> None:
509
+ price_trackers = set(bullish_db._read_tracker(TrackerQuery(), PriceTracker))
510
+ finance_trackers = set(bullish_db._read_tracker(TrackerQuery(), FinancialsTracker))
511
+ tickers = list(price_trackers.intersection(finance_trackers))
512
+ parallel = Parallel(n_jobs=-1)
513
+
514
+ for batch_ticker in batched(tickers, 100):
515
+ start = time.perf_counter()
516
+ many_signal_series = parallel(
517
+ delayed(compute_signal_series)(bullish_db.database_path, ticker)
518
+ for ticker in batch_ticker
519
+ )
520
+ bullish_db.write_signal_series(list(chain.from_iterable(many_signal_series)))
521
+ elapsed_time = time.perf_counter() - start
522
+ print(
523
+ f"Computed signal series for {len(batch_ticker)} tickers in {elapsed_time:.2f} seconds."
524
+ )
525
+
526
+
496
527
  def run_analysis(bullish_db: "BullishDb") -> None:
528
+ compute_industry_view(bullish_db)
497
529
  price_trackers = set(bullish_db._read_tracker(TrackerQuery(), PriceTracker))
498
530
  finance_trackers = set(bullish_db._read_tracker(TrackerQuery(), FinancialsTracker))
499
531
  tickers = list(price_trackers.intersection(finance_trackers))
@@ -0,0 +1,403 @@
1
+ from typing import Literal
2
+
3
+ Industry = Literal[
4
+ "Publishing",
5
+ "Internet Retail",
6
+ "Scientific & Technical Instruments",
7
+ "Engineering & Construction",
8
+ "Diagnostics & Research",
9
+ "Software - Infrastructure",
10
+ "Thermal Coal",
11
+ "Software - Application",
12
+ "Auto Manufacturers",
13
+ "Farm Products",
14
+ "Medical Devices",
15
+ "Education & Training Services",
16
+ "Auto Parts",
17
+ "Specialty Chemicals",
18
+ "Marine Shipping",
19
+ "Biotechnology",
20
+ "Real Estate Services",
21
+ "Gold",
22
+ "Entertainment",
23
+ "Specialty Retail",
24
+ "Utilities - Independent Power Producers",
25
+ "Steel",
26
+ "Mortgage Finance",
27
+ "Communication Equipment",
28
+ "Drug Manufacturers - Specialty & Generic",
29
+ "Electronic Gaming & Multimedia",
30
+ "Banks - Regional",
31
+ "Oil & Gas E&P",
32
+ "Travel Services",
33
+ "Real Estate - Diversified",
34
+ "Telecom Services",
35
+ "Uranium",
36
+ "Consulting Services",
37
+ "Waste Management",
38
+ "Agricultural Inputs",
39
+ "Utilities - Diversified",
40
+ "Auto & Truck Dealerships",
41
+ "Confectioners",
42
+ "Other Industrial Metals & Mining",
43
+ "Beverages - Wineries & Distilleries",
44
+ "Oil & Gas Midstream",
45
+ "Recreational Vehicles",
46
+ "Electrical Equipment & Parts",
47
+ "Household & Personal Products",
48
+ "Packaging & Containers",
49
+ "REIT - Specialty",
50
+ "Home Improvement Retail",
51
+ "Electronic Components",
52
+ "Asset Management",
53
+ "Consumer Electronics",
54
+ "Conglomerates",
55
+ "Health Information Services",
56
+ "Medical Instruments & Supplies",
57
+ "Building Products & Equipment",
58
+ "Information Technology Services",
59
+ "Specialty Industrial Machinery",
60
+ "Food Distribution",
61
+ "Packaged Foods",
62
+ "Rental & Leasing Services",
63
+ "Medical Distribution",
64
+ "Grocery Stores",
65
+ "Advertising Agencies",
66
+ "Beverages - Non - Alcoholic",
67
+ "Apparel Manufacturing",
68
+ "Oil & Gas Equipment & Services",
69
+ "Coking Coal",
70
+ "Industrial Distribution",
71
+ "Restaurants",
72
+ "Beverages - Brewers",
73
+ "Chemicals",
74
+ "Real Estate - Development",
75
+ "Credit Services",
76
+ "Tobacco",
77
+ "Metal Fabrication",
78
+ "Building Materials",
79
+ "Residential Construction",
80
+ "Specialty Business Services",
81
+ "REIT - Hotel & Motel",
82
+ "Internet Content & Information",
83
+ "Lodging",
84
+ "Furnishings, Fixtures & Appliances",
85
+ "Airlines",
86
+ "Computer Hardware",
87
+ "Integrated Freight & Logistics",
88
+ "Solar",
89
+ "Capital Markets",
90
+ "Leisure",
91
+ "Airports & Air Services",
92
+ "Aluminum",
93
+ "Insurance Brokers",
94
+ "Semiconductors",
95
+ "REIT - Retail",
96
+ "Luxury Goods",
97
+ "Lumber & Wood Production",
98
+ "REIT - Mortgage",
99
+ "Semiconductor Equipment & Materials",
100
+ "Aerospace & Defense",
101
+ "Security & Protection Services",
102
+ "Utilities - Renewable",
103
+ "Utilities - Regulated Gas",
104
+ "Apparel Retail",
105
+ "Pollution & Treatment Controls",
106
+ "Broadcasting",
107
+ "Resorts & Casinos",
108
+ "Other Precious Metals & Mining",
109
+ "Financial Data & Stock Exchanges",
110
+ "Footwear & Accessories",
111
+ "Medical Care Facilities",
112
+ "Electronics & Computer Distribution",
113
+ "Gambling",
114
+ "Tools & Accessories",
115
+ "Insurance - Property & Casualty",
116
+ "Utilities - Regulated Water",
117
+ "Insurance - Specialty",
118
+ "Personal Services",
119
+ "Pharmaceutical Retailers",
120
+ "Farm & Heavy Construction Machinery",
121
+ "Utilities - Regulated Electric",
122
+ "Department Stores",
123
+ "Staffing & Employment Services",
124
+ "Textile Manufacturing",
125
+ "Silver",
126
+ "REIT - Industrial",
127
+ "REIT - Diversified",
128
+ "Copper",
129
+ "Business Equipment & Supplies",
130
+ "Infrastructure Operations",
131
+ "Trucking",
132
+ "Insurance - Reinsurance",
133
+ "Insurance - Diversified",
134
+ "Drug Manufacturers - General",
135
+ "Oil & Gas Drilling",
136
+ "Banks - Diversified",
137
+ "REIT - Residential",
138
+ "Oil & Gas Refining & Marketing",
139
+ "Shell Companies",
140
+ "Financial Conglomerates",
141
+ "Paper & Paper Products",
142
+ "Insurance - Life",
143
+ "REIT - Office",
144
+ "Railroads",
145
+ "Oil & Gas Integrated",
146
+ "Healthcare Plans",
147
+ "REIT - Healthcare Facilities",
148
+ "Discount Stores",
149
+ ]
150
+ IndustryGroup = Literal[
151
+ "publishing",
152
+ "internet-retail",
153
+ "scientific-technical-instruments",
154
+ "engineering-construction",
155
+ "diagnostics-research",
156
+ "software-infrastructure",
157
+ "thermal-coal",
158
+ "software-application",
159
+ "auto-manufacturers",
160
+ "farm-products",
161
+ "medical-devices",
162
+ "education-training-services",
163
+ "auto-parts",
164
+ "specialty-chemicals",
165
+ "marine-shipping",
166
+ "biotechnology",
167
+ "real-estate-services",
168
+ "gold",
169
+ "entertainment",
170
+ "specialty-retail",
171
+ "utilities-independent-power-producers",
172
+ "steel",
173
+ "mortgage-finance",
174
+ "communication-equipment",
175
+ "drug-manufacturers-specialty-generic",
176
+ "electronic-gaming-multimedia",
177
+ "banks-regional",
178
+ "oil-gas-e-p",
179
+ "travel-services",
180
+ "real-estate-diversified",
181
+ "telecom-services",
182
+ "uranium",
183
+ "consulting-services",
184
+ "waste-management",
185
+ "agricultural-inputs",
186
+ "utilities-diversified",
187
+ "auto-truck-dealerships",
188
+ "confectioners",
189
+ "other-industrial-metals-mining",
190
+ "beverages-wineries-distilleries",
191
+ "oil-gas-midstream",
192
+ "recreational-vehicles",
193
+ "electrical-equipment-parts",
194
+ "household-personal-products",
195
+ "packaging-containers",
196
+ "reit-specialty",
197
+ "home-improvement-retail",
198
+ "electronic-components",
199
+ "asset-management",
200
+ "consumer-electronics",
201
+ "conglomerates",
202
+ "health-information-services",
203
+ "medical-instruments-supplies",
204
+ "building-products-equipment",
205
+ "information-technology-services",
206
+ "specialty-industrial-machinery",
207
+ "food-distribution",
208
+ "packaged-foods",
209
+ "rental-leasing-services",
210
+ "medical-distribution",
211
+ "grocery-stores",
212
+ "advertising-agencies",
213
+ "beverages-non-alcoholic",
214
+ "apparel-manufacturing",
215
+ "oil-gas-equipment-services",
216
+ "coking-coal",
217
+ "industrial-distribution",
218
+ "restaurants",
219
+ "beverages-brewers",
220
+ "chemicals",
221
+ "real-estate-development",
222
+ "credit-services",
223
+ "tobacco",
224
+ "metal-fabrication",
225
+ "building-materials",
226
+ "residential-construction",
227
+ "specialty-business-services",
228
+ "reit-hotel-motel",
229
+ "internet-content-information",
230
+ "lodging",
231
+ "furnishings-fixtures-appliances",
232
+ "airlines",
233
+ "computer-hardware",
234
+ "integrated-freight-logistics",
235
+ "solar",
236
+ "capital-markets",
237
+ "leisure",
238
+ "airports-air-services",
239
+ "aluminum",
240
+ "insurance-brokers",
241
+ "semiconductors",
242
+ "reit-retail",
243
+ "luxury-goods",
244
+ "lumber-wood-production",
245
+ "reit-mortgage",
246
+ "semiconductor-equipment-materials",
247
+ "aerospace-defense",
248
+ "security-protection-services",
249
+ "utilities-renewable",
250
+ "utilities-regulated-gas",
251
+ "apparel-retail",
252
+ "pollution-treatment-controls",
253
+ "broadcasting",
254
+ "resorts-casinos",
255
+ "other-precious-metals-mining",
256
+ "financial-data-stock-exchanges",
257
+ "footwear-accessories",
258
+ "medical-care-facilities",
259
+ "electronics-computer-distribution",
260
+ "gambling",
261
+ "tools-accessories",
262
+ "insurance-property-casualty",
263
+ "utilities-regulated-water",
264
+ "insurance-specialty",
265
+ "personal-services",
266
+ "pharmaceutical-retailers",
267
+ "farm-heavy-construction-machinery",
268
+ "utilities-regulated-electric",
269
+ "department-stores",
270
+ "staffing-employment-services",
271
+ "textile-manufacturing",
272
+ "silver",
273
+ "reit-industrial",
274
+ "reit-diversified",
275
+ "copper",
276
+ "business-equipment-supplies",
277
+ "infrastructure-operations",
278
+ "trucking",
279
+ "insurance-reinsurance",
280
+ "insurance-diversified",
281
+ "drug-manufacturers-general",
282
+ "oil-gas-drilling",
283
+ "banks-diversified",
284
+ "reit-residential",
285
+ "oil-gas-refining-marketing",
286
+ "shell-companies",
287
+ "financial-conglomerates",
288
+ "paper-paper-products",
289
+ "insurance-life",
290
+ "reit-office",
291
+ "railroads",
292
+ "oil-gas-integrated",
293
+ "healthcare-plans",
294
+ "reit-healthcare-facilities",
295
+ "discount-stores",
296
+ ]
297
+ Sector = Literal[
298
+ "Communication Services",
299
+ "Consumer Cyclical",
300
+ "Technology",
301
+ "Industrials",
302
+ "Healthcare",
303
+ "Energy",
304
+ "Consumer Defensive",
305
+ "Basic Materials",
306
+ "Real Estate",
307
+ "Utilities",
308
+ "Financial Services",
309
+ "Conglomerates",
310
+ ]
311
+ Country = Literal[
312
+ "Australia",
313
+ "China",
314
+ "Japan",
315
+ "United kingdom",
316
+ "United states",
317
+ "Poland",
318
+ "Switzerland",
319
+ "Canada",
320
+ "Greece",
321
+ "Spain",
322
+ "Germany",
323
+ "Indonesia",
324
+ "Belgium",
325
+ "France",
326
+ "Netherlands",
327
+ "British virgin islands",
328
+ "Italy",
329
+ "Hungary",
330
+ "Austria",
331
+ "Finland",
332
+ "Sweden",
333
+ "Bermuda",
334
+ "Taiwan",
335
+ "Israel",
336
+ "Ukraine",
337
+ "Singapore",
338
+ "Jersey",
339
+ "Ireland",
340
+ "Luxembourg",
341
+ "Cyprus",
342
+ "Cayman islands",
343
+ "Norway",
344
+ "Denmark",
345
+ "Hong kong",
346
+ "New zealand",
347
+ "Kazakhstan",
348
+ "Nigeria",
349
+ "Argentina",
350
+ "Brazil",
351
+ "Czech republic",
352
+ "Mauritius",
353
+ "South africa",
354
+ "India",
355
+ "Mexico",
356
+ "Mongolia",
357
+ "Slovenia",
358
+ "Thailand",
359
+ "Malaysia",
360
+ "Costa rica",
361
+ "Isle of man",
362
+ "Egypt",
363
+ "Turkey",
364
+ "United arab emirates",
365
+ "Colombia",
366
+ "Gibraltar",
367
+ "Malta",
368
+ "Liechtenstein",
369
+ "Guernsey",
370
+ "Peru",
371
+ "Estonia",
372
+ "French guiana",
373
+ "Portugal",
374
+ "Uruguay",
375
+ "Chile",
376
+ "Martinique",
377
+ "Monaco",
378
+ "Panama",
379
+ "Papua new guinea",
380
+ "South korea",
381
+ "Macau",
382
+ "Gabon",
383
+ "Romania",
384
+ "Senegal",
385
+ "Morocco",
386
+ "Jordan",
387
+ "Lithuania",
388
+ "Dominican republic",
389
+ "Reunion",
390
+ "Zambia",
391
+ "Cambodia",
392
+ "Myanmar",
393
+ "Bahamas",
394
+ "Philippines",
395
+ "Bangladesh",
396
+ "Latvia",
397
+ "Vietnam",
398
+ "Iceland",
399
+ "Azerbaijan",
400
+ "Georgia",
401
+ "Liberia",
402
+ "Kenya",
403
+ ]