lecrapaud 0.1.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 lecrapaud might be problematic. Click here for more details.

Files changed (63) hide show
  1. lecrapaud/__init__.py +1 -0
  2. lecrapaud/api.py +271 -0
  3. lecrapaud/config.py +25 -0
  4. lecrapaud/db/__init__.py +1 -0
  5. lecrapaud/db/alembic/README +1 -0
  6. lecrapaud/db/alembic/env.py +78 -0
  7. lecrapaud/db/alembic/script.py.mako +26 -0
  8. lecrapaud/db/alembic/versions/2025_04_06_1738-7390745388e4_initial_setup.py +295 -0
  9. lecrapaud/db/alembic/versions/2025_04_06_1755-40cd8d3e798e_unique_constraint_for_data.py +30 -0
  10. lecrapaud/db/alembic/versions/2025_05_23_1724-2360941fa0bd_longer_string.py +52 -0
  11. lecrapaud/db/alembic/versions/2025_05_27_1159-b96396dcfaff_add_env_to_trading_tables.py +34 -0
  12. lecrapaud/db/alembic/versions/2025_05_27_1337-40cbfc215f7c_fix_nb_character_on_portfolio.py +39 -0
  13. lecrapaud/db/alembic/versions/2025_05_27_1526-3de994115317_to_datetime.py +36 -0
  14. lecrapaud/db/alembic/versions/2025_05_27_2003-25c227c684f8_add_fees_to_transactions.py +30 -0
  15. lecrapaud/db/alembic/versions/2025_05_27_2047-6b6f2d38e9bc_double_instead_of_float.py +132 -0
  16. lecrapaud/db/alembic/versions/2025_05_31_1111-c175e4a36d68_generalise_stock_to_group.py +36 -0
  17. lecrapaud/db/alembic/versions/2025_05_31_1256-5681095bfc27_create_investment_run_and_portfolio_.py +62 -0
  18. lecrapaud/db/alembic/versions/2025_05_31_1806-339927587383_add_investment_run_id.py +107 -0
  19. lecrapaud/db/alembic/versions/2025_05_31_1834-52b809a34371_make_nullablee.py +38 -0
  20. lecrapaud/db/alembic/versions/2025_05_31_1849-3b8550297e8e_change_date_to_datetime.py +44 -0
  21. lecrapaud/db/alembic/versions/2025_05_31_1852-e6b8c95d8243_add_date_to_portfolio_history.py +30 -0
  22. lecrapaud/db/alembic/versions/2025_06_10_1136-db8cdd83563a_addnewsandoptiontodata.py +32 -0
  23. lecrapaud/db/alembic/versions/2025_06_17_1652-c45f5e49fa2c_make_fields_nullable.py +89 -0
  24. lecrapaud/db/models/__init__.py +11 -0
  25. lecrapaud/db/models/base.py +181 -0
  26. lecrapaud/db/models/dataset.py +129 -0
  27. lecrapaud/db/models/feature.py +45 -0
  28. lecrapaud/db/models/feature_selection.py +125 -0
  29. lecrapaud/db/models/feature_selection_rank.py +79 -0
  30. lecrapaud/db/models/model.py +40 -0
  31. lecrapaud/db/models/model_selection.py +63 -0
  32. lecrapaud/db/models/model_training.py +62 -0
  33. lecrapaud/db/models/score.py +65 -0
  34. lecrapaud/db/models/target.py +67 -0
  35. lecrapaud/db/session.py +45 -0
  36. lecrapaud/directory_management.py +28 -0
  37. lecrapaud/experiment.py +64 -0
  38. lecrapaud/feature_engineering.py +846 -0
  39. lecrapaud/feature_selection.py +1167 -0
  40. lecrapaud/integrations/openai_integration.py +225 -0
  41. lecrapaud/jobs/__init__.py +13 -0
  42. lecrapaud/jobs/config.py +17 -0
  43. lecrapaud/jobs/scheduler.py +36 -0
  44. lecrapaud/jobs/tasks.py +57 -0
  45. lecrapaud/model_selection.py +1671 -0
  46. lecrapaud/predictions.py +292 -0
  47. lecrapaud/preprocessing.py +984 -0
  48. lecrapaud/search_space.py +848 -0
  49. lecrapaud/services/__init__.py +0 -0
  50. lecrapaud/services/embedding_categorical.py +71 -0
  51. lecrapaud/services/indicators.py +309 -0
  52. lecrapaud/speed_tests/experiments.py +139 -0
  53. lecrapaud/speed_tests/test-gpu-bilstm.ipynb +261 -0
  54. lecrapaud/speed_tests/test-gpu-resnet.ipynb +166 -0
  55. lecrapaud/speed_tests/test-gpu-transformers.ipynb +254 -0
  56. lecrapaud/speed_tests/tests.ipynb +145 -0
  57. lecrapaud/speed_tests/trash.py +37 -0
  58. lecrapaud/training.py +239 -0
  59. lecrapaud/utils.py +246 -0
  60. lecrapaud-0.1.0.dist-info/LICENSE +201 -0
  61. lecrapaud-0.1.0.dist-info/METADATA +105 -0
  62. lecrapaud-0.1.0.dist-info/RECORD +63 -0
  63. lecrapaud-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,295 @@
1
+ """initial setup
2
+
3
+ Revision ID: 7390745388e4
4
+ Revises:
5
+ Create Date: 2025-04-06 17:38:29.297967
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '7390745388e4'
16
+ down_revision: Union[str, None] = None
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
+ op.create_table('datas',
24
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
25
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
26
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
27
+ sa.Column('date', sa.DateTime(), nullable=True),
28
+ sa.Column('open', sa.Float(), nullable=True),
29
+ sa.Column('high', sa.Float(), nullable=True),
30
+ sa.Column('low', sa.Float(), nullable=True),
31
+ sa.Column('close', sa.Float(), nullable=True),
32
+ sa.Column('adjclose', sa.Float(), nullable=True),
33
+ sa.Column('volume', sa.BigInteger(), nullable=True),
34
+ sa.Column('stock', sa.String(length=50), nullable=True),
35
+ sa.Column('isin', sa.String(length=50), nullable=True),
36
+ sa.Column('security', sa.String(length=50), nullable=True),
37
+ sa.Column('sector', sa.String(length=255), nullable=True),
38
+ sa.Column('subindustry', sa.String(length=255), nullable=True),
39
+ sa.Column('location', sa.String(length=255), nullable=True),
40
+ sa.Column('vix_close', sa.Float(), nullable=True),
41
+ sa.PrimaryKeyConstraint('id')
42
+ )
43
+ op.create_index(op.f('ix_datas_date'), 'datas', ['date'], unique=False)
44
+ op.create_index(op.f('ix_datas_id'), 'datas', ['id'], unique=False)
45
+ op.create_index(op.f('ix_datas_stock'), 'datas', ['stock'], unique=False)
46
+ op.create_table('datasets',
47
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
48
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
49
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
50
+ sa.Column('name', sa.String(length=50), nullable=False),
51
+ sa.Column('path', sa.String(length=255), nullable=True),
52
+ sa.Column('type', sa.String(length=50), nullable=False),
53
+ sa.Column('size', sa.Integer(), nullable=False),
54
+ sa.Column('train_size', sa.Integer(), nullable=False),
55
+ sa.Column('val_size', sa.Integer(), nullable=True),
56
+ sa.Column('test_size', sa.Integer(), nullable=False),
57
+ sa.Column('number_of_stocks', sa.Integer(), nullable=False),
58
+ sa.Column('list_of_companies', sa.JSON(), nullable=False),
59
+ sa.Column('corr_threshold', sa.Float(), nullable=False),
60
+ sa.Column('max_features', sa.Integer(), nullable=False),
61
+ sa.Column('percentile', sa.Float(), nullable=False),
62
+ sa.Column('start_date', sa.DateTime(), nullable=False),
63
+ sa.Column('end_date', sa.DateTime(), nullable=False),
64
+ sa.Column('train_start_date', sa.DateTime(), nullable=False),
65
+ sa.Column('train_end_date', sa.DateTime(), nullable=False),
66
+ sa.Column('val_start_date', sa.DateTime(), nullable=True),
67
+ sa.Column('val_end_date', sa.DateTime(), nullable=True),
68
+ sa.Column('test_start_date', sa.DateTime(), nullable=False),
69
+ sa.Column('test_end_date', sa.DateTime(), nullable=False),
70
+ sa.PrimaryKeyConstraint('id'),
71
+ sa.UniqueConstraint('name', name='uq_datasets_composite')
72
+ )
73
+ op.create_index(op.f('ix_datasets_id'), 'datasets', ['id'], unique=False)
74
+ op.create_table('features',
75
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
76
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
77
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
78
+ sa.Column('name', sa.String(length=50), nullable=False),
79
+ sa.Column('type', sa.String(length=50), nullable=True),
80
+ sa.PrimaryKeyConstraint('id'),
81
+ sa.UniqueConstraint('name')
82
+ )
83
+ op.create_index(op.f('ix_features_id'), 'features', ['id'], unique=False)
84
+ op.create_table('models',
85
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
86
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
87
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
88
+ sa.Column('name', sa.String(length=50), nullable=False),
89
+ sa.Column('type', sa.String(length=50), nullable=False),
90
+ sa.PrimaryKeyConstraint('id'),
91
+ sa.UniqueConstraint('name', 'type', name='uq_model_composite')
92
+ )
93
+ op.create_index(op.f('ix_models_id'), 'models', ['id'], unique=False)
94
+ op.create_table('operations',
95
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
96
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
97
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
98
+ sa.Column('stock', sa.String(length=50), nullable=False),
99
+ sa.Column('price_in', sa.Float(), nullable=False),
100
+ sa.Column('date_in', sa.Date(), nullable=False),
101
+ sa.Column('why_buy', sa.String(length=50), nullable=True),
102
+ sa.Column('price_out', sa.Float(), nullable=False),
103
+ sa.Column('date_out', sa.Date(), nullable=False),
104
+ sa.Column('why_sell', sa.String(length=50), nullable=True),
105
+ sa.Column('pl', sa.Float(), nullable=False),
106
+ sa.Column('cash', sa.Float(), nullable=False),
107
+ sa.Column('portfolio_value', sa.Float(), nullable=False),
108
+ sa.Column('total_value', sa.Float(), nullable=False),
109
+ sa.Column('roi', sa.Float(), nullable=False),
110
+ sa.Column('cumulated_roi', sa.Float(), nullable=False),
111
+ sa.Column('cagr', sa.Float(), nullable=False),
112
+ sa.PrimaryKeyConstraint('id')
113
+ )
114
+ op.create_index(op.f('ix_operations_id'), 'operations', ['id'], unique=False)
115
+ op.create_table('portfolios',
116
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
117
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
118
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
119
+ sa.Column('stock', sa.String(length=50), nullable=False),
120
+ sa.Column('position', sa.Integer(), nullable=False),
121
+ sa.Column('price_in', sa.Float(), nullable=False),
122
+ sa.Column('value', sa.Float(), nullable=False),
123
+ sa.Column('date_in', sa.Date(), nullable=False),
124
+ sa.Column('why_buy', sa.String(length=50), nullable=True),
125
+ sa.PrimaryKeyConstraint('id')
126
+ )
127
+ op.create_index(op.f('ix_portfolios_id'), 'portfolios', ['id'], unique=False)
128
+ op.create_table('targets',
129
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
130
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
131
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
132
+ sa.Column('name', sa.String(length=50), nullable=False),
133
+ sa.Column('type', sa.String(length=50), nullable=False),
134
+ sa.Column('description', sa.String(length=255), nullable=True),
135
+ sa.PrimaryKeyConstraint('id'),
136
+ sa.UniqueConstraint('name', 'type', name='uq_target_composite')
137
+ )
138
+ op.create_index(op.f('ix_targets_id'), 'targets', ['id'], unique=False)
139
+ op.create_table('transactions',
140
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
141
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
142
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
143
+ sa.Column('buy_sell', sa.String(length=50), nullable=False),
144
+ sa.Column('stock', sa.String(length=50), nullable=False),
145
+ sa.Column('price', sa.Float(), nullable=False),
146
+ sa.Column('position', sa.Integer(), nullable=False),
147
+ sa.Column('value', sa.Float(), nullable=False),
148
+ sa.Column('date', sa.Date(), nullable=False),
149
+ sa.Column('why', sa.String(length=50), nullable=True),
150
+ sa.PrimaryKeyConstraint('id')
151
+ )
152
+ op.create_index(op.f('ix_transactions_id'), 'transactions', ['id'], unique=False)
153
+ op.create_table('dataset_target_association',
154
+ sa.Column('dataset_id', sa.BigInteger(), nullable=False),
155
+ sa.Column('target_id', sa.BigInteger(), nullable=False),
156
+ sa.ForeignKeyConstraint(['dataset_id'], ['datasets.id'], ondelete='CASCADE'),
157
+ sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ondelete='CASCADE'),
158
+ sa.PrimaryKeyConstraint('dataset_id', 'target_id')
159
+ )
160
+ op.create_table('feature_selections',
161
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
162
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
163
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
164
+ sa.Column('training_time', sa.Integer(), nullable=True),
165
+ sa.Column('best_features_path', sa.String(length=255), nullable=True),
166
+ sa.Column('dataset_id', sa.BigInteger(), nullable=False),
167
+ sa.Column('target_id', sa.BigInteger(), nullable=False),
168
+ sa.ForeignKeyConstraint(['dataset_id'], ['datasets.id'], ondelete='CASCADE'),
169
+ sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ondelete='CASCADE'),
170
+ sa.PrimaryKeyConstraint('id'),
171
+ sa.UniqueConstraint('dataset_id', 'target_id', name='uq_feature_selection_composite')
172
+ )
173
+ op.create_index(op.f('ix_feature_selections_id'), 'feature_selections', ['id'], unique=False)
174
+ op.create_table('model_selections',
175
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
176
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
177
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
178
+ sa.Column('best_model_params', sa.JSON(), nullable=True),
179
+ sa.Column('best_model_path', sa.String(length=255), nullable=True),
180
+ sa.Column('best_model_id', sa.BigInteger(), nullable=True),
181
+ sa.Column('target_id', sa.BigInteger(), nullable=False),
182
+ sa.Column('dataset_id', sa.BigInteger(), nullable=False),
183
+ sa.ForeignKeyConstraint(['best_model_id'], ['models.id'], ondelete='CASCADE'),
184
+ sa.ForeignKeyConstraint(['dataset_id'], ['datasets.id'], ondelete='CASCADE'),
185
+ sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ondelete='CASCADE'),
186
+ sa.PrimaryKeyConstraint('id'),
187
+ sa.UniqueConstraint('target_id', 'dataset_id', name='uq_model_selection_composite')
188
+ )
189
+ op.create_index(op.f('ix_model_selections_id'), 'model_selections', ['id'], unique=False)
190
+ op.create_table('feature_selection_association',
191
+ sa.Column('feature_selection_id', sa.BigInteger(), nullable=False),
192
+ sa.Column('feature_id', sa.BigInteger(), nullable=False),
193
+ sa.ForeignKeyConstraint(['feature_id'], ['features.id'], ondelete='CASCADE'),
194
+ sa.ForeignKeyConstraint(['feature_selection_id'], ['feature_selections.id'], ondelete='CASCADE'),
195
+ sa.PrimaryKeyConstraint('feature_selection_id', 'feature_id')
196
+ )
197
+ op.create_table('feature_selection_ranks',
198
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
199
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
200
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
201
+ sa.Column('score', sa.Float(), nullable=True),
202
+ sa.Column('pvalue', sa.Float(), nullable=True),
203
+ sa.Column('support', sa.Integer(), nullable=True),
204
+ sa.Column('rank', sa.Integer(), nullable=True),
205
+ sa.Column('method', sa.String(length=50), nullable=True),
206
+ sa.Column('training_time', sa.Integer(), nullable=True),
207
+ sa.Column('feature_id', sa.BigInteger(), nullable=True),
208
+ sa.Column('feature_selection_id', sa.BigInteger(), nullable=True),
209
+ sa.ForeignKeyConstraint(['feature_id'], ['features.id'], ondelete='CASCADE'),
210
+ sa.ForeignKeyConstraint(['feature_selection_id'], ['feature_selections.id'], ondelete='CASCADE'),
211
+ sa.PrimaryKeyConstraint('id'),
212
+ sa.UniqueConstraint('feature_id', 'feature_selection_id', 'method', name='uq_feature_selection_rank_composite')
213
+ )
214
+ op.create_index(op.f('ix_feature_selection_ranks_id'), 'feature_selection_ranks', ['id'], unique=False)
215
+ op.create_table('model_trainings',
216
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
217
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
218
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
219
+ sa.Column('best_params', sa.JSON(), nullable=True),
220
+ sa.Column('model_path', sa.String(length=255), nullable=True),
221
+ sa.Column('training_time', sa.Integer(), nullable=True),
222
+ sa.Column('model_id', sa.BigInteger(), nullable=False),
223
+ sa.Column('model_selection_id', sa.BigInteger(), nullable=False),
224
+ sa.ForeignKeyConstraint(['model_id'], ['models.id'], ),
225
+ sa.ForeignKeyConstraint(['model_selection_id'], ['model_selections.id'], ondelete='CASCADE'),
226
+ sa.PrimaryKeyConstraint('id'),
227
+ sa.UniqueConstraint('model_id', 'model_selection_id', name='uq_model_training_composite')
228
+ )
229
+ op.create_index(op.f('ix_model_trainings_id'), 'model_trainings', ['id'], unique=False)
230
+ op.create_table('scores',
231
+ sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
232
+ sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
233
+ sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
234
+ sa.Column('type', sa.String(length=50), nullable=False),
235
+ sa.Column('training_time', sa.Integer(), nullable=True),
236
+ sa.Column('eval_data_std', sa.Float(), nullable=True),
237
+ sa.Column('rmse', sa.Float(), nullable=True),
238
+ sa.Column('rmse_std_ratio', sa.Float(), nullable=True),
239
+ sa.Column('mae', sa.Float(), nullable=True),
240
+ sa.Column('mape', sa.Float(), nullable=True),
241
+ sa.Column('mam', sa.Float(), nullable=True),
242
+ sa.Column('mad', sa.Float(), nullable=True),
243
+ sa.Column('mae_mam_ratio', sa.Float(), nullable=True),
244
+ sa.Column('mae_mad_ratio', sa.Float(), nullable=True),
245
+ sa.Column('r2', sa.Float(), nullable=True),
246
+ sa.Column('logloss', sa.Float(), nullable=True),
247
+ sa.Column('accuracy', sa.Float(), nullable=True),
248
+ sa.Column('precision', sa.Float(), nullable=True),
249
+ sa.Column('recall', sa.Float(), nullable=True),
250
+ sa.Column('f1', sa.Float(), nullable=True),
251
+ sa.Column('roc_auc', sa.Float(), nullable=True),
252
+ sa.Column('threshold', sa.Float(), nullable=True),
253
+ sa.Column('precision_at_threshold', sa.Float(), nullable=True),
254
+ sa.Column('recall_at_threshold', sa.Float(), nullable=True),
255
+ sa.Column('model_training_id', sa.BigInteger(), nullable=False),
256
+ sa.ForeignKeyConstraint(['model_training_id'], ['model_trainings.id'], ondelete='CASCADE'),
257
+ sa.PrimaryKeyConstraint('id')
258
+ )
259
+ op.create_index(op.f('ix_scores_id'), 'scores', ['id'], unique=False)
260
+ # ### end Alembic commands ###
261
+
262
+
263
+ def downgrade() -> None:
264
+ # ### commands auto generated by Alembic - please adjust! ###
265
+ op.drop_index(op.f('ix_scores_id'), table_name='scores')
266
+ op.drop_table('scores')
267
+ op.drop_index(op.f('ix_model_trainings_id'), table_name='model_trainings')
268
+ op.drop_table('model_trainings')
269
+ op.drop_index(op.f('ix_feature_selection_ranks_id'), table_name='feature_selection_ranks')
270
+ op.drop_table('feature_selection_ranks')
271
+ op.drop_table('feature_selection_association')
272
+ op.drop_index(op.f('ix_model_selections_id'), table_name='model_selections')
273
+ op.drop_table('model_selections')
274
+ op.drop_index(op.f('ix_feature_selections_id'), table_name='feature_selections')
275
+ op.drop_table('feature_selections')
276
+ op.drop_table('dataset_target_association')
277
+ op.drop_index(op.f('ix_transactions_id'), table_name='transactions')
278
+ op.drop_table('transactions')
279
+ op.drop_index(op.f('ix_targets_id'), table_name='targets')
280
+ op.drop_table('targets')
281
+ op.drop_index(op.f('ix_portfolios_id'), table_name='portfolios')
282
+ op.drop_table('portfolios')
283
+ op.drop_index(op.f('ix_operations_id'), table_name='operations')
284
+ op.drop_table('operations')
285
+ op.drop_index(op.f('ix_models_id'), table_name='models')
286
+ op.drop_table('models')
287
+ op.drop_index(op.f('ix_features_id'), table_name='features')
288
+ op.drop_table('features')
289
+ op.drop_index(op.f('ix_datasets_id'), table_name='datasets')
290
+ op.drop_table('datasets')
291
+ op.drop_index(op.f('ix_datas_stock'), table_name='datas')
292
+ op.drop_index(op.f('ix_datas_id'), table_name='datas')
293
+ op.drop_index(op.f('ix_datas_date'), table_name='datas')
294
+ op.drop_table('datas')
295
+ # ### end Alembic commands ###
@@ -0,0 +1,30 @@
1
+ """unique constraint for data
2
+
3
+ Revision ID: 40cd8d3e798e
4
+ Revises: 7390745388e4
5
+ Create Date: 2025-04-06 17:55:47.709956
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '40cd8d3e798e'
16
+ down_revision: Union[str, None] = '7390745388e4'
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
+ op.create_unique_constraint('uq_datas_composite', 'datas', ['date', 'stock'])
24
+ # ### end Alembic commands ###
25
+
26
+
27
+ def downgrade() -> None:
28
+ # ### commands auto generated by Alembic - please adjust! ###
29
+ op.drop_constraint('uq_datas_composite', 'datas', type_='unique')
30
+ # ### end Alembic commands ###
@@ -0,0 +1,52 @@
1
+ """longer_string
2
+
3
+ Revision ID: 2360941fa0bd
4
+ Revises: 40cd8d3e798e
5
+ Create Date: 2025-05-23 17:24:07.750472
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+ from sqlalchemy.dialects import mysql
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '2360941fa0bd'
16
+ down_revision: Union[str, None] = '40cd8d3e798e'
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
+ op.alter_column('operations', 'why_buy',
24
+ existing_type=mysql.VARCHAR(length=50),
25
+ type_=sa.String(length=255),
26
+ existing_nullable=True)
27
+ op.alter_column('operations', 'why_sell',
28
+ existing_type=mysql.VARCHAR(length=50),
29
+ type_=sa.String(length=255),
30
+ existing_nullable=True)
31
+ op.alter_column('transactions', 'why',
32
+ existing_type=mysql.VARCHAR(length=50),
33
+ type_=sa.String(length=255),
34
+ existing_nullable=True)
35
+ # ### end Alembic commands ###
36
+
37
+
38
+ def downgrade() -> None:
39
+ # ### commands auto generated by Alembic - please adjust! ###
40
+ op.alter_column('transactions', 'why',
41
+ existing_type=sa.String(length=255),
42
+ type_=mysql.VARCHAR(length=50),
43
+ existing_nullable=True)
44
+ op.alter_column('operations', 'why_sell',
45
+ existing_type=sa.String(length=255),
46
+ type_=mysql.VARCHAR(length=50),
47
+ existing_nullable=True)
48
+ op.alter_column('operations', 'why_buy',
49
+ existing_type=sa.String(length=255),
50
+ type_=mysql.VARCHAR(length=50),
51
+ existing_nullable=True)
52
+ # ### end Alembic commands ###
@@ -0,0 +1,34 @@
1
+ """add_env_to_trading_tables
2
+
3
+ Revision ID: b96396dcfaff
4
+ Revises: 2360941fa0bd
5
+ Create Date: 2025-05-27 11:59:55.405410
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = 'b96396dcfaff'
16
+ down_revision: Union[str, None] = '2360941fa0bd'
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
+ op.add_column('operations', sa.Column('env', sa.String(length=50), nullable=False))
24
+ op.add_column('portfolios', sa.Column('env', sa.String(length=50), nullable=False))
25
+ op.add_column('transactions', sa.Column('env', sa.String(length=50), nullable=False))
26
+ # ### end Alembic commands ###
27
+
28
+
29
+ def downgrade() -> None:
30
+ # ### commands auto generated by Alembic - please adjust! ###
31
+ op.drop_column('transactions', 'env')
32
+ op.drop_column('portfolios', 'env')
33
+ op.drop_column('operations', 'env')
34
+ # ### end Alembic commands ###
@@ -0,0 +1,39 @@
1
+ """fix_nb_character_on_portfolio
2
+
3
+
4
+ Revision ID: 40cbfc215f7c
5
+ Revises: b96396dcfaff
6
+ Create Date: 2025-05-27 13:37:18.291145
7
+
8
+ """
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+ from sqlalchemy.dialects import mysql
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = '40cbfc215f7c'
17
+ down_revision: Union[str, None] = 'b96396dcfaff'
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
+ op.alter_column('portfolios', 'why_buy',
25
+ existing_type=mysql.VARCHAR(length=50),
26
+ type_=sa.String(length=255),
27
+ existing_nullable=True)
28
+ op.create_unique_constraint('uq_portfolio_composite', 'portfolios', ['stock', 'env'])
29
+ # ### end Alembic commands ###
30
+
31
+
32
+ def downgrade() -> None:
33
+ # ### commands auto generated by Alembic - please adjust! ###
34
+ op.drop_constraint('uq_portfolio_composite', 'portfolios', type_='unique')
35
+ op.alter_column('portfolios', 'why_buy',
36
+ existing_type=sa.String(length=255),
37
+ type_=mysql.VARCHAR(length=50),
38
+ existing_nullable=True)
39
+ # ### end Alembic commands ###
@@ -0,0 +1,36 @@
1
+ """to_datetime
2
+
3
+ Revision ID: 3de994115317
4
+ Revises: 40cbfc215f7c
5
+ Create Date: 2025-05-27 15:26:01.669012
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '3de994115317'
16
+ down_revision: Union[str, None] = '40cbfc215f7c'
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
+ op.alter_column('transactions', 'date',
24
+ existing_type=sa.DATE(),
25
+ type_=sa.DateTime(),
26
+ existing_nullable=False)
27
+ # ### end Alembic commands ###
28
+
29
+
30
+ def downgrade() -> None:
31
+ # ### commands auto generated by Alembic - please adjust! ###
32
+ op.alter_column('transactions', 'date',
33
+ existing_type=sa.DateTime(),
34
+ type_=sa.DATE(),
35
+ existing_nullable=False)
36
+ # ### end Alembic commands ###
@@ -0,0 +1,30 @@
1
+ """add_fees_to_transactions
2
+
3
+ Revision ID: 25c227c684f8
4
+ Revises: 3de994115317
5
+ Create Date: 2025-05-27 20:03:08.193307
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '25c227c684f8'
16
+ down_revision: Union[str, None] = '3de994115317'
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
+ op.add_column('transactions', sa.Column('fees', sa.Float(), nullable=False))
24
+ # ### end Alembic commands ###
25
+
26
+
27
+ def downgrade() -> None:
28
+ # ### commands auto generated by Alembic - please adjust! ###
29
+ op.drop_column('transactions', 'fees')
30
+ # ### end Alembic commands ###
@@ -0,0 +1,132 @@
1
+ """double_instead_of_float
2
+
3
+ Revision ID: 6b6f2d38e9bc
4
+ Revises: 25c227c684f8
5
+ Create Date: 2025-05-27 20:47:45.303669
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+ from sqlalchemy.dialects import mysql
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = '6b6f2d38e9bc'
16
+ down_revision: Union[str, None] = '25c227c684f8'
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
+ op.alter_column('operations', 'price_in',
24
+ existing_type=mysql.FLOAT(),
25
+ type_=sa.Double(),
26
+ existing_nullable=False)
27
+ op.alter_column('operations', 'price_out',
28
+ existing_type=mysql.FLOAT(),
29
+ type_=sa.Double(),
30
+ existing_nullable=False)
31
+ op.alter_column('operations', 'pl',
32
+ existing_type=mysql.FLOAT(),
33
+ type_=sa.Double(),
34
+ existing_nullable=False)
35
+ op.alter_column('operations', 'cash',
36
+ existing_type=mysql.FLOAT(),
37
+ type_=sa.Double(),
38
+ existing_nullable=False)
39
+ op.alter_column('operations', 'portfolio_value',
40
+ existing_type=mysql.FLOAT(),
41
+ type_=sa.Double(),
42
+ existing_nullable=False)
43
+ op.alter_column('operations', 'total_value',
44
+ existing_type=mysql.FLOAT(),
45
+ type_=sa.Double(),
46
+ existing_nullable=False)
47
+ op.alter_column('operations', 'roi',
48
+ existing_type=mysql.FLOAT(),
49
+ type_=sa.Double(),
50
+ existing_nullable=False)
51
+ op.alter_column('operations', 'cumulated_roi',
52
+ existing_type=mysql.FLOAT(),
53
+ type_=sa.Double(),
54
+ existing_nullable=False)
55
+ op.alter_column('operations', 'cagr',
56
+ existing_type=mysql.FLOAT(),
57
+ type_=sa.Double(),
58
+ existing_nullable=False)
59
+ op.alter_column('portfolios', 'price_in',
60
+ existing_type=mysql.FLOAT(),
61
+ type_=sa.Double(),
62
+ existing_nullable=False)
63
+ op.alter_column('portfolios', 'value',
64
+ existing_type=mysql.FLOAT(),
65
+ type_=sa.Double(),
66
+ existing_nullable=False)
67
+ op.alter_column('transactions', 'price',
68
+ existing_type=mysql.FLOAT(),
69
+ type_=sa.Double(),
70
+ existing_nullable=False)
71
+ op.alter_column('transactions', 'value',
72
+ existing_type=mysql.FLOAT(),
73
+ type_=sa.Double(),
74
+ existing_nullable=False)
75
+ # ### end Alembic commands ###
76
+
77
+
78
+ def downgrade() -> None:
79
+ # ### commands auto generated by Alembic - please adjust! ###
80
+ op.alter_column('transactions', 'value',
81
+ existing_type=sa.Double(),
82
+ type_=mysql.FLOAT(),
83
+ existing_nullable=False)
84
+ op.alter_column('transactions', 'price',
85
+ existing_type=sa.Double(),
86
+ type_=mysql.FLOAT(),
87
+ existing_nullable=False)
88
+ op.alter_column('portfolios', 'value',
89
+ existing_type=sa.Double(),
90
+ type_=mysql.FLOAT(),
91
+ existing_nullable=False)
92
+ op.alter_column('portfolios', 'price_in',
93
+ existing_type=sa.Double(),
94
+ type_=mysql.FLOAT(),
95
+ existing_nullable=False)
96
+ op.alter_column('operations', 'cagr',
97
+ existing_type=sa.Double(),
98
+ type_=mysql.FLOAT(),
99
+ existing_nullable=False)
100
+ op.alter_column('operations', 'cumulated_roi',
101
+ existing_type=sa.Double(),
102
+ type_=mysql.FLOAT(),
103
+ existing_nullable=False)
104
+ op.alter_column('operations', 'roi',
105
+ existing_type=sa.Double(),
106
+ type_=mysql.FLOAT(),
107
+ existing_nullable=False)
108
+ op.alter_column('operations', 'total_value',
109
+ existing_type=sa.Double(),
110
+ type_=mysql.FLOAT(),
111
+ existing_nullable=False)
112
+ op.alter_column('operations', 'portfolio_value',
113
+ existing_type=sa.Double(),
114
+ type_=mysql.FLOAT(),
115
+ existing_nullable=False)
116
+ op.alter_column('operations', 'cash',
117
+ existing_type=sa.Double(),
118
+ type_=mysql.FLOAT(),
119
+ existing_nullable=False)
120
+ op.alter_column('operations', 'pl',
121
+ existing_type=sa.Double(),
122
+ type_=mysql.FLOAT(),
123
+ existing_nullable=False)
124
+ op.alter_column('operations', 'price_out',
125
+ existing_type=sa.Double(),
126
+ type_=mysql.FLOAT(),
127
+ existing_nullable=False)
128
+ op.alter_column('operations', 'price_in',
129
+ existing_type=sa.Double(),
130
+ type_=mysql.FLOAT(),
131
+ existing_nullable=False)
132
+ # ### end Alembic commands ###