bullishpy 0.4.0__py3-none-any.whl → 0.6.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 +114 -250
- bullish/analysis/filter.py +581 -79
- bullish/analysis/functions.py +344 -0
- bullish/analysis/indicators.py +450 -0
- bullish/analysis/predefined_filters.py +87 -0
- bullish/app/app.py +235 -83
- bullish/cli.py +3 -1
- bullish/database/alembic/versions/037dbd721317_.py +1 -0
- bullish/database/alembic/versions/08ac1116e055_.py +592 -0
- bullish/database/alembic/versions/11d35a452b40_.py +368 -0
- bullish/database/alembic/versions/49c83f9eb5ac_.py +103 -0
- bullish/database/alembic/versions/4b0a2f40b7d3_.py +1 -0
- bullish/database/alembic/versions/73564b60fe24_.py +1 -0
- bullish/database/alembic/versions/ee5baabb35f8_.py +51 -0
- bullish/database/crud.py +14 -2
- bullish/database/schemas.py +13 -0
- bullish/figures/figures.py +52 -12
- bullish/interface/interface.py +16 -27
- bullish/jobs/tasks.py +10 -0
- bullish/utils/__init__.py +0 -0
- bullish/utils/checks.py +64 -0
- {bullishpy-0.4.0.dist-info → bullishpy-0.6.0.dist-info}/METADATA +4 -5
- bullishpy-0.6.0.dist-info/RECORD +43 -0
- bullishpy-0.4.0.dist-info/RECORD +0 -34
- {bullishpy-0.4.0.dist-info → bullishpy-0.6.0.dist-info}/WHEEL +0 -0
- {bullishpy-0.4.0.dist-info → bullishpy-0.6.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Revision ID: 11d35a452b40
|
|
4
|
+
Revises: 73564b60fe24
|
|
5
|
+
Create Date: 2025-06-23 06:02:07.122505
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
from alembic import op
|
|
12
|
+
import sqlalchemy as sa
|
|
13
|
+
|
|
14
|
+
# revision identifiers, used by Alembic.
|
|
15
|
+
revision: str = "11d35a452b40"
|
|
16
|
+
down_revision: Union[str, None] = "73564b60fe24"
|
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
18
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upgrade() -> None:
|
|
22
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
23
|
+
with op.batch_alter_table("analysis", schema=None) as batch_op:
|
|
24
|
+
batch_op.alter_column(
|
|
25
|
+
"quarterly_positive_free_cash_flow",
|
|
26
|
+
existing_type=sa.FLOAT(),
|
|
27
|
+
type_=sa.Boolean(),
|
|
28
|
+
existing_nullable=True,
|
|
29
|
+
)
|
|
30
|
+
batch_op.alter_column(
|
|
31
|
+
"quarterly_growing_operating_cash_flow",
|
|
32
|
+
existing_type=sa.FLOAT(),
|
|
33
|
+
type_=sa.Boolean(),
|
|
34
|
+
existing_nullable=True,
|
|
35
|
+
)
|
|
36
|
+
batch_op.alter_column(
|
|
37
|
+
"quarterly_operating_cash_flow_is_higher_than_net_income",
|
|
38
|
+
existing_type=sa.FLOAT(),
|
|
39
|
+
type_=sa.Boolean(),
|
|
40
|
+
existing_nullable=True,
|
|
41
|
+
)
|
|
42
|
+
batch_op.alter_column(
|
|
43
|
+
"quarterly_positive_net_income",
|
|
44
|
+
existing_type=sa.FLOAT(),
|
|
45
|
+
type_=sa.Boolean(),
|
|
46
|
+
existing_nullable=True,
|
|
47
|
+
)
|
|
48
|
+
batch_op.alter_column(
|
|
49
|
+
"quarterly_positive_operating_income",
|
|
50
|
+
existing_type=sa.FLOAT(),
|
|
51
|
+
type_=sa.Boolean(),
|
|
52
|
+
existing_nullable=True,
|
|
53
|
+
)
|
|
54
|
+
batch_op.alter_column(
|
|
55
|
+
"quarterly_growing_net_income",
|
|
56
|
+
existing_type=sa.FLOAT(),
|
|
57
|
+
type_=sa.Boolean(),
|
|
58
|
+
existing_nullable=True,
|
|
59
|
+
)
|
|
60
|
+
batch_op.alter_column(
|
|
61
|
+
"quarterly_growing_operating_income",
|
|
62
|
+
existing_type=sa.FLOAT(),
|
|
63
|
+
type_=sa.Boolean(),
|
|
64
|
+
existing_nullable=True,
|
|
65
|
+
)
|
|
66
|
+
batch_op.alter_column(
|
|
67
|
+
"quarterly_positive_diluted_eps",
|
|
68
|
+
existing_type=sa.FLOAT(),
|
|
69
|
+
type_=sa.Boolean(),
|
|
70
|
+
existing_nullable=True,
|
|
71
|
+
)
|
|
72
|
+
batch_op.alter_column(
|
|
73
|
+
"quarterly_positive_basic_eps",
|
|
74
|
+
existing_type=sa.FLOAT(),
|
|
75
|
+
type_=sa.Boolean(),
|
|
76
|
+
existing_nullable=True,
|
|
77
|
+
)
|
|
78
|
+
batch_op.alter_column(
|
|
79
|
+
"quarterly_growing_basic_eps",
|
|
80
|
+
existing_type=sa.FLOAT(),
|
|
81
|
+
type_=sa.Boolean(),
|
|
82
|
+
existing_nullable=True,
|
|
83
|
+
)
|
|
84
|
+
batch_op.alter_column(
|
|
85
|
+
"quarterly_growing_diluted_eps",
|
|
86
|
+
existing_type=sa.FLOAT(),
|
|
87
|
+
type_=sa.Boolean(),
|
|
88
|
+
existing_nullable=True,
|
|
89
|
+
)
|
|
90
|
+
batch_op.alter_column(
|
|
91
|
+
"quarterly_positive_debt_to_equity",
|
|
92
|
+
existing_type=sa.FLOAT(),
|
|
93
|
+
type_=sa.Boolean(),
|
|
94
|
+
existing_nullable=True,
|
|
95
|
+
)
|
|
96
|
+
batch_op.alter_column(
|
|
97
|
+
"quarterly_positive_return_on_assets",
|
|
98
|
+
existing_type=sa.FLOAT(),
|
|
99
|
+
type_=sa.Boolean(),
|
|
100
|
+
existing_nullable=True,
|
|
101
|
+
)
|
|
102
|
+
batch_op.alter_column(
|
|
103
|
+
"quarterly_positive_return_on_equity",
|
|
104
|
+
existing_type=sa.FLOAT(),
|
|
105
|
+
type_=sa.Boolean(),
|
|
106
|
+
existing_nullable=True,
|
|
107
|
+
)
|
|
108
|
+
batch_op.alter_column(
|
|
109
|
+
"positive_free_cash_flow",
|
|
110
|
+
existing_type=sa.FLOAT(),
|
|
111
|
+
type_=sa.Boolean(),
|
|
112
|
+
existing_nullable=True,
|
|
113
|
+
)
|
|
114
|
+
batch_op.alter_column(
|
|
115
|
+
"growing_operating_cash_flow",
|
|
116
|
+
existing_type=sa.FLOAT(),
|
|
117
|
+
type_=sa.Boolean(),
|
|
118
|
+
existing_nullable=True,
|
|
119
|
+
)
|
|
120
|
+
batch_op.alter_column(
|
|
121
|
+
"operating_cash_flow_is_higher_than_net_income",
|
|
122
|
+
existing_type=sa.FLOAT(),
|
|
123
|
+
type_=sa.Boolean(),
|
|
124
|
+
existing_nullable=True,
|
|
125
|
+
)
|
|
126
|
+
batch_op.alter_column(
|
|
127
|
+
"positive_net_income",
|
|
128
|
+
existing_type=sa.FLOAT(),
|
|
129
|
+
type_=sa.Boolean(),
|
|
130
|
+
existing_nullable=True,
|
|
131
|
+
)
|
|
132
|
+
batch_op.alter_column(
|
|
133
|
+
"positive_operating_income",
|
|
134
|
+
existing_type=sa.FLOAT(),
|
|
135
|
+
type_=sa.Boolean(),
|
|
136
|
+
existing_nullable=True,
|
|
137
|
+
)
|
|
138
|
+
batch_op.alter_column(
|
|
139
|
+
"growing_net_income",
|
|
140
|
+
existing_type=sa.FLOAT(),
|
|
141
|
+
type_=sa.Boolean(),
|
|
142
|
+
existing_nullable=True,
|
|
143
|
+
)
|
|
144
|
+
batch_op.alter_column(
|
|
145
|
+
"growing_operating_income",
|
|
146
|
+
existing_type=sa.FLOAT(),
|
|
147
|
+
type_=sa.Boolean(),
|
|
148
|
+
existing_nullable=True,
|
|
149
|
+
)
|
|
150
|
+
batch_op.alter_column(
|
|
151
|
+
"positive_diluted_eps",
|
|
152
|
+
existing_type=sa.FLOAT(),
|
|
153
|
+
type_=sa.Boolean(),
|
|
154
|
+
existing_nullable=True,
|
|
155
|
+
)
|
|
156
|
+
batch_op.alter_column(
|
|
157
|
+
"positive_basic_eps",
|
|
158
|
+
existing_type=sa.FLOAT(),
|
|
159
|
+
type_=sa.Boolean(),
|
|
160
|
+
existing_nullable=True,
|
|
161
|
+
)
|
|
162
|
+
batch_op.alter_column(
|
|
163
|
+
"growing_basic_eps",
|
|
164
|
+
existing_type=sa.FLOAT(),
|
|
165
|
+
type_=sa.Boolean(),
|
|
166
|
+
existing_nullable=True,
|
|
167
|
+
)
|
|
168
|
+
batch_op.alter_column(
|
|
169
|
+
"growing_diluted_eps",
|
|
170
|
+
existing_type=sa.FLOAT(),
|
|
171
|
+
type_=sa.Boolean(),
|
|
172
|
+
existing_nullable=True,
|
|
173
|
+
)
|
|
174
|
+
batch_op.alter_column(
|
|
175
|
+
"positive_debt_to_equity",
|
|
176
|
+
existing_type=sa.FLOAT(),
|
|
177
|
+
type_=sa.Boolean(),
|
|
178
|
+
existing_nullable=True,
|
|
179
|
+
)
|
|
180
|
+
batch_op.alter_column(
|
|
181
|
+
"positive_return_on_assets",
|
|
182
|
+
existing_type=sa.FLOAT(),
|
|
183
|
+
type_=sa.Boolean(),
|
|
184
|
+
existing_nullable=True,
|
|
185
|
+
)
|
|
186
|
+
batch_op.alter_column(
|
|
187
|
+
"positive_return_on_equity",
|
|
188
|
+
existing_type=sa.FLOAT(),
|
|
189
|
+
type_=sa.Boolean(),
|
|
190
|
+
existing_nullable=True,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
# ### end Alembic commands ###
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def downgrade() -> None:
|
|
197
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
198
|
+
with op.batch_alter_table("analysis", schema=None) as batch_op:
|
|
199
|
+
batch_op.alter_column(
|
|
200
|
+
"positive_return_on_equity",
|
|
201
|
+
existing_type=sa.Boolean(),
|
|
202
|
+
type_=sa.FLOAT(),
|
|
203
|
+
existing_nullable=True,
|
|
204
|
+
)
|
|
205
|
+
batch_op.alter_column(
|
|
206
|
+
"positive_return_on_assets",
|
|
207
|
+
existing_type=sa.Boolean(),
|
|
208
|
+
type_=sa.FLOAT(),
|
|
209
|
+
existing_nullable=True,
|
|
210
|
+
)
|
|
211
|
+
batch_op.alter_column(
|
|
212
|
+
"positive_debt_to_equity",
|
|
213
|
+
existing_type=sa.Boolean(),
|
|
214
|
+
type_=sa.FLOAT(),
|
|
215
|
+
existing_nullable=True,
|
|
216
|
+
)
|
|
217
|
+
batch_op.alter_column(
|
|
218
|
+
"growing_diluted_eps",
|
|
219
|
+
existing_type=sa.Boolean(),
|
|
220
|
+
type_=sa.FLOAT(),
|
|
221
|
+
existing_nullable=True,
|
|
222
|
+
)
|
|
223
|
+
batch_op.alter_column(
|
|
224
|
+
"growing_basic_eps",
|
|
225
|
+
existing_type=sa.Boolean(),
|
|
226
|
+
type_=sa.FLOAT(),
|
|
227
|
+
existing_nullable=True,
|
|
228
|
+
)
|
|
229
|
+
batch_op.alter_column(
|
|
230
|
+
"positive_basic_eps",
|
|
231
|
+
existing_type=sa.Boolean(),
|
|
232
|
+
type_=sa.FLOAT(),
|
|
233
|
+
existing_nullable=True,
|
|
234
|
+
)
|
|
235
|
+
batch_op.alter_column(
|
|
236
|
+
"positive_diluted_eps",
|
|
237
|
+
existing_type=sa.Boolean(),
|
|
238
|
+
type_=sa.FLOAT(),
|
|
239
|
+
existing_nullable=True,
|
|
240
|
+
)
|
|
241
|
+
batch_op.alter_column(
|
|
242
|
+
"growing_operating_income",
|
|
243
|
+
existing_type=sa.Boolean(),
|
|
244
|
+
type_=sa.FLOAT(),
|
|
245
|
+
existing_nullable=True,
|
|
246
|
+
)
|
|
247
|
+
batch_op.alter_column(
|
|
248
|
+
"growing_net_income",
|
|
249
|
+
existing_type=sa.Boolean(),
|
|
250
|
+
type_=sa.FLOAT(),
|
|
251
|
+
existing_nullable=True,
|
|
252
|
+
)
|
|
253
|
+
batch_op.alter_column(
|
|
254
|
+
"positive_operating_income",
|
|
255
|
+
existing_type=sa.Boolean(),
|
|
256
|
+
type_=sa.FLOAT(),
|
|
257
|
+
existing_nullable=True,
|
|
258
|
+
)
|
|
259
|
+
batch_op.alter_column(
|
|
260
|
+
"positive_net_income",
|
|
261
|
+
existing_type=sa.Boolean(),
|
|
262
|
+
type_=sa.FLOAT(),
|
|
263
|
+
existing_nullable=True,
|
|
264
|
+
)
|
|
265
|
+
batch_op.alter_column(
|
|
266
|
+
"operating_cash_flow_is_higher_than_net_income",
|
|
267
|
+
existing_type=sa.Boolean(),
|
|
268
|
+
type_=sa.FLOAT(),
|
|
269
|
+
existing_nullable=True,
|
|
270
|
+
)
|
|
271
|
+
batch_op.alter_column(
|
|
272
|
+
"growing_operating_cash_flow",
|
|
273
|
+
existing_type=sa.Boolean(),
|
|
274
|
+
type_=sa.FLOAT(),
|
|
275
|
+
existing_nullable=True,
|
|
276
|
+
)
|
|
277
|
+
batch_op.alter_column(
|
|
278
|
+
"positive_free_cash_flow",
|
|
279
|
+
existing_type=sa.Boolean(),
|
|
280
|
+
type_=sa.FLOAT(),
|
|
281
|
+
existing_nullable=True,
|
|
282
|
+
)
|
|
283
|
+
batch_op.alter_column(
|
|
284
|
+
"quarterly_positive_return_on_equity",
|
|
285
|
+
existing_type=sa.Boolean(),
|
|
286
|
+
type_=sa.FLOAT(),
|
|
287
|
+
existing_nullable=True,
|
|
288
|
+
)
|
|
289
|
+
batch_op.alter_column(
|
|
290
|
+
"quarterly_positive_return_on_assets",
|
|
291
|
+
existing_type=sa.Boolean(),
|
|
292
|
+
type_=sa.FLOAT(),
|
|
293
|
+
existing_nullable=True,
|
|
294
|
+
)
|
|
295
|
+
batch_op.alter_column(
|
|
296
|
+
"quarterly_positive_debt_to_equity",
|
|
297
|
+
existing_type=sa.Boolean(),
|
|
298
|
+
type_=sa.FLOAT(),
|
|
299
|
+
existing_nullable=True,
|
|
300
|
+
)
|
|
301
|
+
batch_op.alter_column(
|
|
302
|
+
"quarterly_growing_diluted_eps",
|
|
303
|
+
existing_type=sa.Boolean(),
|
|
304
|
+
type_=sa.FLOAT(),
|
|
305
|
+
existing_nullable=True,
|
|
306
|
+
)
|
|
307
|
+
batch_op.alter_column(
|
|
308
|
+
"quarterly_growing_basic_eps",
|
|
309
|
+
existing_type=sa.Boolean(),
|
|
310
|
+
type_=sa.FLOAT(),
|
|
311
|
+
existing_nullable=True,
|
|
312
|
+
)
|
|
313
|
+
batch_op.alter_column(
|
|
314
|
+
"quarterly_positive_basic_eps",
|
|
315
|
+
existing_type=sa.Boolean(),
|
|
316
|
+
type_=sa.FLOAT(),
|
|
317
|
+
existing_nullable=True,
|
|
318
|
+
)
|
|
319
|
+
batch_op.alter_column(
|
|
320
|
+
"quarterly_positive_diluted_eps",
|
|
321
|
+
existing_type=sa.Boolean(),
|
|
322
|
+
type_=sa.FLOAT(),
|
|
323
|
+
existing_nullable=True,
|
|
324
|
+
)
|
|
325
|
+
batch_op.alter_column(
|
|
326
|
+
"quarterly_growing_operating_income",
|
|
327
|
+
existing_type=sa.Boolean(),
|
|
328
|
+
type_=sa.FLOAT(),
|
|
329
|
+
existing_nullable=True,
|
|
330
|
+
)
|
|
331
|
+
batch_op.alter_column(
|
|
332
|
+
"quarterly_growing_net_income",
|
|
333
|
+
existing_type=sa.Boolean(),
|
|
334
|
+
type_=sa.FLOAT(),
|
|
335
|
+
existing_nullable=True,
|
|
336
|
+
)
|
|
337
|
+
batch_op.alter_column(
|
|
338
|
+
"quarterly_positive_operating_income",
|
|
339
|
+
existing_type=sa.Boolean(),
|
|
340
|
+
type_=sa.FLOAT(),
|
|
341
|
+
existing_nullable=True,
|
|
342
|
+
)
|
|
343
|
+
batch_op.alter_column(
|
|
344
|
+
"quarterly_positive_net_income",
|
|
345
|
+
existing_type=sa.Boolean(),
|
|
346
|
+
type_=sa.FLOAT(),
|
|
347
|
+
existing_nullable=True,
|
|
348
|
+
)
|
|
349
|
+
batch_op.alter_column(
|
|
350
|
+
"quarterly_operating_cash_flow_is_higher_than_net_income",
|
|
351
|
+
existing_type=sa.Boolean(),
|
|
352
|
+
type_=sa.FLOAT(),
|
|
353
|
+
existing_nullable=True,
|
|
354
|
+
)
|
|
355
|
+
batch_op.alter_column(
|
|
356
|
+
"quarterly_growing_operating_cash_flow",
|
|
357
|
+
existing_type=sa.Boolean(),
|
|
358
|
+
type_=sa.FLOAT(),
|
|
359
|
+
existing_nullable=True,
|
|
360
|
+
)
|
|
361
|
+
batch_op.alter_column(
|
|
362
|
+
"quarterly_positive_free_cash_flow",
|
|
363
|
+
existing_type=sa.Boolean(),
|
|
364
|
+
type_=sa.FLOAT(),
|
|
365
|
+
existing_nullable=True,
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
# ### end Alembic commands ###
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Revision ID: 49c83f9eb5ac
|
|
4
|
+
Revises: ee5baabb35f8
|
|
5
|
+
Create Date: 2025-07-06 07:29:51.181393
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
from alembic import op
|
|
12
|
+
import sqlalchemy as sa
|
|
13
|
+
from sqlalchemy.dialects import sqlite
|
|
14
|
+
|
|
15
|
+
# revision identifiers, used by Alembic.
|
|
16
|
+
revision: str = "49c83f9eb5ac"
|
|
17
|
+
down_revision: Union[str, None] = "ee5baabb35f8"
|
|
18
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
19
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def upgrade() -> None:
|
|
23
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
24
|
+
with op.batch_alter_table("analysis", schema=None) as batch_op:
|
|
25
|
+
batch_op.add_column(
|
|
26
|
+
sa.Column("median_rate_of_change_1", sa.Float(), nullable=True)
|
|
27
|
+
)
|
|
28
|
+
batch_op.add_column(
|
|
29
|
+
sa.Column("median_rate_of_change_7_4", sa.Float(), nullable=True)
|
|
30
|
+
)
|
|
31
|
+
batch_op.add_column(
|
|
32
|
+
sa.Column("median_rate_of_change_7_12", sa.Float(), nullable=True)
|
|
33
|
+
)
|
|
34
|
+
batch_op.add_column(
|
|
35
|
+
sa.Column("median_rate_of_change_30", sa.Float(), nullable=True)
|
|
36
|
+
)
|
|
37
|
+
batch_op.add_column(sa.Column("rate_of_change_7", sa.Float(), nullable=True))
|
|
38
|
+
batch_op.drop_index(batch_op.f("ix_analysis_rate_of_change_1"))
|
|
39
|
+
batch_op.drop_index(batch_op.f("ix_analysis_rate_of_change_7_12"))
|
|
40
|
+
batch_op.drop_index(batch_op.f("ix_analysis_rate_of_change_7_4"))
|
|
41
|
+
batch_op.create_index(
|
|
42
|
+
"ix_analysis_median_rate_of_change_1",
|
|
43
|
+
["median_rate_of_change_1"],
|
|
44
|
+
unique=False,
|
|
45
|
+
)
|
|
46
|
+
batch_op.create_index(
|
|
47
|
+
"ix_analysis_median_rate_of_change_30",
|
|
48
|
+
["median_rate_of_change_30"],
|
|
49
|
+
unique=False,
|
|
50
|
+
)
|
|
51
|
+
batch_op.create_index(
|
|
52
|
+
"ix_analysis_median_rate_of_change_7_12",
|
|
53
|
+
["median_rate_of_change_7_12"],
|
|
54
|
+
unique=False,
|
|
55
|
+
)
|
|
56
|
+
batch_op.create_index(
|
|
57
|
+
"ix_analysis_median_rate_of_change_7_4",
|
|
58
|
+
["median_rate_of_change_7_4"],
|
|
59
|
+
unique=False,
|
|
60
|
+
)
|
|
61
|
+
batch_op.create_index(
|
|
62
|
+
"ix_analysis_rate_of_change_7", ["rate_of_change_7"], unique=False
|
|
63
|
+
)
|
|
64
|
+
batch_op.drop_column("rate_of_change_7_4")
|
|
65
|
+
batch_op.drop_column("rate_of_change_7_12")
|
|
66
|
+
batch_op.drop_column("rate_of_change_1")
|
|
67
|
+
|
|
68
|
+
# ### end Alembic commands ###
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def downgrade() -> None:
|
|
72
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
73
|
+
with op.batch_alter_table("analysis", schema=None) as batch_op:
|
|
74
|
+
batch_op.add_column(sa.Column("rate_of_change_1", sa.FLOAT(), nullable=True))
|
|
75
|
+
batch_op.add_column(sa.Column("rate_of_change_7_12", sa.FLOAT(), nullable=True))
|
|
76
|
+
batch_op.add_column(sa.Column("rate_of_change_7_4", sa.FLOAT(), nullable=True))
|
|
77
|
+
batch_op.drop_index("ix_analysis_rate_of_change_7")
|
|
78
|
+
batch_op.drop_index("ix_analysis_median_rate_of_change_7_4")
|
|
79
|
+
batch_op.drop_index("ix_analysis_median_rate_of_change_7_12")
|
|
80
|
+
batch_op.drop_index("ix_analysis_median_rate_of_change_30")
|
|
81
|
+
batch_op.drop_index("ix_analysis_median_rate_of_change_1")
|
|
82
|
+
batch_op.create_index(
|
|
83
|
+
batch_op.f("ix_analysis_rate_of_change_7_4"),
|
|
84
|
+
["rate_of_change_7_4"],
|
|
85
|
+
unique=False,
|
|
86
|
+
)
|
|
87
|
+
batch_op.create_index(
|
|
88
|
+
batch_op.f("ix_analysis_rate_of_change_7_12"),
|
|
89
|
+
["rate_of_change_7_12"],
|
|
90
|
+
unique=False,
|
|
91
|
+
)
|
|
92
|
+
batch_op.create_index(
|
|
93
|
+
batch_op.f("ix_analysis_rate_of_change_1"),
|
|
94
|
+
["rate_of_change_1"],
|
|
95
|
+
unique=False,
|
|
96
|
+
)
|
|
97
|
+
batch_op.drop_column("rate_of_change_7")
|
|
98
|
+
batch_op.drop_column("median_rate_of_change_30")
|
|
99
|
+
batch_op.drop_column("median_rate_of_change_7_12")
|
|
100
|
+
batch_op.drop_column("median_rate_of_change_7_4")
|
|
101
|
+
batch_op.drop_column("median_rate_of_change_1")
|
|
102
|
+
|
|
103
|
+
# ### end Alembic commands ###
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Revision ID: ee5baabb35f8
|
|
4
|
+
Revises: 08ac1116e055
|
|
5
|
+
Create Date: 2025-07-02 05:16:42.862366
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
from alembic import op
|
|
12
|
+
import sqlalchemy as sa
|
|
13
|
+
from sqlalchemy.dialects import sqlite
|
|
14
|
+
|
|
15
|
+
# revision identifiers, used by Alembic.
|
|
16
|
+
revision: str = "ee5baabb35f8"
|
|
17
|
+
down_revision: Union[str, None] = "08ac1116e055"
|
|
18
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
19
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def upgrade() -> None:
|
|
23
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
24
|
+
with op.batch_alter_table("analysis", schema=None) as batch_op:
|
|
25
|
+
batch_op.add_column(
|
|
26
|
+
sa.Column("adosc_crosses_above_0", sa.Date(), nullable=True)
|
|
27
|
+
)
|
|
28
|
+
batch_op.add_column(
|
|
29
|
+
sa.Column("positive_adosc_20_day_breakout", sa.Date(), nullable=True)
|
|
30
|
+
)
|
|
31
|
+
batch_op.create_index(
|
|
32
|
+
"ix_analysis_adosc_crosses_above_0", ["adosc_crosses_above_0"], unique=False
|
|
33
|
+
)
|
|
34
|
+
batch_op.create_index(
|
|
35
|
+
"ix_analysis_positive_adosc_20_day_breakout",
|
|
36
|
+
["positive_adosc_20_day_breakout"],
|
|
37
|
+
unique=False,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# ### end Alembic commands ###
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def downgrade() -> None:
|
|
44
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
45
|
+
with op.batch_alter_table("analysis", schema=None) as batch_op:
|
|
46
|
+
batch_op.drop_index("ix_analysis_positive_adosc_20_day_breakout")
|
|
47
|
+
batch_op.drop_index("ix_analysis_adosc_crosses_above_0")
|
|
48
|
+
batch_op.drop_column("positive_adosc_20_day_breakout")
|
|
49
|
+
batch_op.drop_column("adosc_crosses_above_0")
|
|
50
|
+
|
|
51
|
+
# ### end Alembic commands ###
|
bullish/database/crud.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import logging
|
|
2
3
|
from functools import cached_property
|
|
3
4
|
from pathlib import Path
|
|
@@ -64,6 +65,11 @@ class BullishDb(BearishDb, BullishDbBase): # type: ignore
|
|
|
64
65
|
return None
|
|
65
66
|
return Analysis.model_validate(analysis)
|
|
66
67
|
|
|
68
|
+
def read_symbols(self) -> List[str]:
|
|
69
|
+
query = "SELECT DISTINCT symbol FROM analysis"
|
|
70
|
+
data = pd.read_sql_query(query, self._engine)
|
|
71
|
+
return data["symbol"].tolist()
|
|
72
|
+
|
|
67
73
|
def _read_analysis_data(
|
|
68
74
|
self, columns: List[str], symbols: Optional[List[str]] = None
|
|
69
75
|
) -> pd.DataFrame:
|
|
@@ -140,7 +146,13 @@ class BullishDb(BearishDb, BullishDbBase): # type: ignore
|
|
|
140
146
|
|
|
141
147
|
def write_filtered_results(self, filtered_results: FilteredResults) -> None:
|
|
142
148
|
with Session(self._engine) as session:
|
|
143
|
-
data = filtered_results.
|
|
144
|
-
|
|
149
|
+
data = filtered_results.model_dump_json(
|
|
150
|
+
exclude_unset=True, exclude_defaults=True
|
|
151
|
+
)
|
|
152
|
+
stmt = (
|
|
153
|
+
insert(FilteredResultsORM)
|
|
154
|
+
.prefix_with("OR REPLACE")
|
|
155
|
+
.values(json.loads(data))
|
|
156
|
+
)
|
|
145
157
|
session.exec(stmt) # type: ignore
|
|
146
158
|
session.commit()
|
bullish/database/schemas.py
CHANGED
|
@@ -5,6 +5,7 @@ from sqlalchemy import Column, JSON
|
|
|
5
5
|
from bullish.analysis.analysis import Analysis
|
|
6
6
|
from bullish.analysis.filter import FilteredResults
|
|
7
7
|
from bullish.jobs.models import JobTracker
|
|
8
|
+
from sqlalchemy import Index
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class BaseTable(SQLModel):
|
|
@@ -12,11 +13,23 @@ class BaseTable(SQLModel):
|
|
|
12
13
|
source: str = Field(primary_key=True)
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
dynamic_indexes = tuple(
|
|
17
|
+
Index(f"ix_analysis_{col}", col) for col in Analysis.model_fields
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
15
21
|
class AnalysisORM(BaseTable, Analysis, table=True):
|
|
16
22
|
__tablename__ = "analysis"
|
|
17
23
|
__table_args__ = {"extend_existing": True} # noqa:RUF012
|
|
18
24
|
|
|
19
25
|
|
|
26
|
+
AnalysisORM.__table_args__ = tuple( # type: ignore # noqa: RUF005
|
|
27
|
+
Index(f"ix_{AnalysisORM.__tablename__}_{col.name}", col)
|
|
28
|
+
for col in AnalysisORM.__table__.columns
|
|
29
|
+
if not col.primary_key and not col.index and col.name != "id"
|
|
30
|
+
) + (AnalysisORM.__table_args__,)
|
|
31
|
+
|
|
32
|
+
|
|
20
33
|
class JobTrackerORM(SQLModel, JobTracker, table=True):
|
|
21
34
|
__tablename__ = "jobtracker"
|
|
22
35
|
__table_args__ = {"extend_existing": True} # noqa:RUF012
|