crypto-trader-analysis 0.1.2__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.
Files changed (81) hide show
  1. crypto_trader_analysis-0.1.2.dist-info/METADATA +143 -0
  2. crypto_trader_analysis-0.1.2.dist-info/RECORD +81 -0
  3. crypto_trader_analysis-0.1.2.dist-info/WHEEL +5 -0
  4. crypto_trader_analysis-0.1.2.dist-info/entry_points.txt +3 -0
  5. crypto_trader_analysis-0.1.2.dist-info/top_level.txt +1 -0
  6. src/__init__.py +0 -0
  7. src/crypto_trader_analysis/__init__.py +2 -0
  8. src/crypto_trader_analysis/api/__init__.py +0 -0
  9. src/crypto_trader_analysis/api/asgi.py +16 -0
  10. src/crypto_trader_analysis/api/settings.py +139 -0
  11. src/crypto_trader_analysis/api/urls.py +23 -0
  12. src/crypto_trader_analysis/api/wsgi.py +16 -0
  13. src/crypto_trader_analysis/apps/__init__.py +0 -0
  14. src/crypto_trader_analysis/apps/learning/__init__.py +0 -0
  15. src/crypto_trader_analysis/apps/learning/models/__init__.py +0 -0
  16. src/crypto_trader_analysis/apps/learning/models/ai/__init__.py +0 -0
  17. src/crypto_trader_analysis/apps/learning/models/ai/lstm/__init__.py +0 -0
  18. src/crypto_trader_analysis/apps/learning/models/ai/lstm/base_model.py +50 -0
  19. src/crypto_trader_analysis/apps/learning/models/ai/lstm/complex_lstm_model.py +123 -0
  20. src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/__init__.py +0 -0
  21. src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/complex_multi_layer_lstm_model.py +146 -0
  22. src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/multi_layer_base_model.py +18 -0
  23. src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/multi_layer_lstm_model.py +133 -0
  24. src/crypto_trader_analysis/apps/learning/models/ai/lstm/lstm_model.py +112 -0
  25. src/crypto_trader_analysis/apps/learning/models/ai/model_retriever.py +143 -0
  26. src/crypto_trader_analysis/apps/learning/models/ai/model_type.py +53 -0
  27. src/crypto_trader_analysis/apps/learning/models/currency_json_generator.py +60 -0
  28. src/crypto_trader_analysis/apps/learning/models/data/__init__.py +0 -0
  29. src/crypto_trader_analysis/apps/learning/models/data/preprocessor.py +352 -0
  30. src/crypto_trader_analysis/apps/learning/models/database/__init__.py +0 -0
  31. src/crypto_trader_analysis/apps/learning/models/database/database.py +282 -0
  32. src/crypto_trader_analysis/apps/learning/models/database/query_load.py +6 -0
  33. src/crypto_trader_analysis/apps/learning/models/database/query_type.py +7 -0
  34. src/crypto_trader_analysis/apps/learning/models/prediction/__init__.py +0 -0
  35. src/crypto_trader_analysis/apps/learning/models/prediction/prediction.py +31 -0
  36. src/crypto_trader_analysis/apps/learning/models/prediction/predictions.py +165 -0
  37. src/crypto_trader_analysis/apps/learning/models/training/__init__.py +0 -0
  38. src/crypto_trader_analysis/apps/learning/models/training/correlations/__init__.py +0 -0
  39. src/crypto_trader_analysis/apps/learning/models/training/correlations/colrelations_analyzer.py +81 -0
  40. src/crypto_trader_analysis/apps/learning/models/training/multi_layer_training_model.py +23 -0
  41. src/crypto_trader_analysis/apps/learning/models/training/multi_layer_training_model_builder.py +29 -0
  42. src/crypto_trader_analysis/apps/learning/models/training/specs/__init__.py +0 -0
  43. src/crypto_trader_analysis/apps/learning/models/training/specs/batch_size_evaluations.py +8 -0
  44. src/crypto_trader_analysis/apps/learning/models/training/specs/dataset_size.py +13 -0
  45. src/crypto_trader_analysis/apps/learning/models/training/specs/epoch_focus.py +14 -0
  46. src/crypto_trader_analysis/apps/learning/models/training/specs/sequence_length_sentiment.py +26 -0
  47. src/crypto_trader_analysis/apps/learning/models/training/train_model.py +446 -0
  48. src/crypto_trader_analysis/apps/learning/models/training/training_model.py +23 -0
  49. src/crypto_trader_analysis/apps/learning/models/training/training_model_builder.py +61 -0
  50. src/crypto_trader_analysis/apps/learning/models/training/training_session.py +378 -0
  51. src/crypto_trader_analysis/apps/learning/models/training/training_type.py +170 -0
  52. src/crypto_trader_analysis/apps/news/__init__.py +0 -0
  53. src/crypto_trader_analysis/apps/news/models/__init__.py +0 -0
  54. src/crypto_trader_analysis/apps/news/models/analysis/__init__.py +0 -0
  55. src/crypto_trader_analysis/apps/news/models/analysis/crypto_regex.py +22 -0
  56. src/crypto_trader_analysis/apps/news/models/analysis/parse_sentiment.py +89 -0
  57. src/crypto_trader_analysis/apps/news/models/analysis/sentiment/__init__.py +0 -0
  58. src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_analyzer.py +12 -0
  59. src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_label.py +7 -0
  60. src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_model.py +134 -0
  61. src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_result.py +28 -0
  62. src/crypto_trader_analysis/apps/news/models/article/__init__.py +0 -0
  63. src/crypto_trader_analysis/apps/news/models/article/article.py +23 -0
  64. src/crypto_trader_analysis/apps/news/models/article/scored_article.py +51 -0
  65. src/crypto_trader_analysis/apps/news/models/fetch_articles.py +166 -0
  66. src/crypto_trader_analysis/apps/news/models/sources/__init__.py +0 -0
  67. src/crypto_trader_analysis/apps/news/models/sources/author_regex.py +214 -0
  68. src/crypto_trader_analysis/apps/news/models/sources/news_source.py +8 -0
  69. src/crypto_trader_analysis/apps/news/models/sources/news_sources.json +25 -0
  70. src/crypto_trader_analysis/apps/news/models/sources/news_sources.py +36 -0
  71. src/crypto_trader_analysis/apps/news/views/__init__.py +0 -0
  72. src/crypto_trader_analysis/apps/news/views/sentiment/__init__.py +0 -0
  73. src/crypto_trader_analysis/apps/news/views/sentiment/sentiment_harvest_view.py +31 -0
  74. src/crypto_trader_analysis/apps/news/views/sentiment/targeted/__init__.py +0 -0
  75. src/crypto_trader_analysis/apps/news/views/sentiment/targeted/date_targeted_sentiment_harvest_view.py +31 -0
  76. src/crypto_trader_analysis/apps/news/views/sentiment/targeted/urls.py +8 -0
  77. src/crypto_trader_analysis/apps/news/views/sentiment/urls.py +9 -0
  78. src/crypto_trader_analysis/apps/news/views/urls.py +5 -0
  79. src/crypto_trader_analysis/gpu/__init__.py +0 -0
  80. src/crypto_trader_analysis/gpu/run_gpu_one.py +44 -0
  81. src/crypto_trader_analysis/gpu/run_gpu_zero.py +39 -0
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: crypto-trader-analysis
3
+ Version: 0.1.2
4
+ Summary: Analysis and ML components for the Crypto Trader platform (news sentiment, training, utilities).
5
+ Author-email: Oliver Lear Sigwarth <sigwarthsoftware@gmail.com>
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Homepage, https://github.com/theoliverlear/Crypto-Trader
8
+ Project-URL: Repository, https://github.com/theoliverlear/Crypto-Trader
9
+ Project-URL: Issues, https://github.com/theoliverlear/Crypto-Trader/issues
10
+ Keywords: crypto,trading,machine-learning,tensorflow,django,analysis,sentiment
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
+ Classifier: Topic :: Office/Business :: Financial :: Investment
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Operating System :: OS Independent
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: attrs>=23.0.0
23
+ Requires-Dist: requests>=2.31.0
24
+ Requires-Dist: beautifulsoup4>=4.12.0
25
+ Provides-Extra: web
26
+ Requires-Dist: Django>=5.1; extra == "web"
27
+ Provides-Extra: data
28
+ Requires-Dist: numpy>=1.23; extra == "data"
29
+ Requires-Dist: pandas>=2.0; extra == "data"
30
+ Provides-Extra: ml
31
+ Requires-Dist: numpy>=1.23; extra == "ml"
32
+ Requires-Dist: pandas>=2.0; extra == "ml"
33
+ Requires-Dist: tensorflow>=2.14; extra == "ml"
34
+ Provides-Extra: all
35
+ Requires-Dist: Django>=5.1; extra == "all"
36
+ Requires-Dist: numpy>=1.23; extra == "all"
37
+ Requires-Dist: pandas>=2.0; extra == "all"
38
+ Requires-Dist: tensorflow>=2.14; extra == "all"
39
+
40
+ # Crypto Trader — Analysis Module
41
+ ## Machine learning and market analytics engine
42
+
43
+ ---
44
+
45
+ The Analysis module powers Crypto Trader’s price prediction and model
46
+ training. It ingests market data from PostgreSQL, engineers features, trains
47
+ LSTM‑based models (including multi‑layer variants), generates predictions, and
48
+ reports results back to the platform.
49
+
50
+ Important: Past results and backtests do not guarantee future performance.
51
+ Always start in paper mode. Liability is your own.
52
+
53
+ ## ⭐️ What this module is
54
+ - A Python analytics service used by Crypto Trader’s core platform.
55
+ - Strategic ML engine: LSTM, complex LSTM, and multi‑layer LSTM variants.
56
+ - Feature engineering pipeline with robust scaling and time‑windowed sequences.
57
+ - Training, prediction, and reporting utilities that integrate with the Django
58
+ API.
59
+
60
+ ## 🧭 Key capabilities
61
+ - Data access
62
+ - Pulls market snapshots from PostgreSQL via SQLAlchemy; bulk `COPY` for
63
+ speed.
64
+ - Supports multiple query modes: `current_price`, `historical`,
65
+ `historical_spaced`.
66
+ - Feature engineering
67
+ - Sliding time windows (configurable `sequence_length`).
68
+ - Engineered channels: past trends, key timestamps, correlation with target
69
+ returns.
70
+ - Multi‑scale preprocessing for multi‑layer models (short/medium/long
71
+ horizons).
72
+ - Models and training
73
+ - LSTM models with Keras/TensorFlow; early stopping, LR scheduling,
74
+ checkpoints.
75
+ - Multi‑layer models combine short, medium, and long sequences.
76
+ - GPU execution when available; CPU fallback supported.
77
+ - Predictions and reporting
78
+ - Generates next‑step price predictions for a target currency.
79
+ - Posts predictions and training session summaries to the platform API.
80
+ - TensorBoard logs for model inspection.
81
+
82
+ ## 🔗 How it fits into Crypto Trader
83
+ - Input: Market snapshot data from the platform database (PostgreSQL).
84
+ - Output: Trained model artifacts under `models/...`, predicted prices,
85
+ metrics.
86
+ - Integration: Sends structured payloads to the Django API.
87
+
88
+ ## 🧰 Operation
89
+ This module is operated by project owners alongside the Django API and two
90
+ GPUs for training.
91
+
92
+ - Environment and data
93
+ - Database: PostgreSQL
94
+ - Market snapshots table must be populated; `currencies.json` is used for
95
+ price column discovery.
96
+ - GPU setup
97
+ - Two‑GPU operation is supported. Utilities in the codebase and the scripts
98
+ under `gpu/` demonstrate splitting currency workloads across devices.
99
+ - Example GPU launcher scripts live under `gpu/` (e.g.,
100
+ `gpu/run_gpu_zero.py`).
101
+ - Common operator actions
102
+ - Train a single‑currency LSTM model
103
+ - Entry: `src/apps/learning/models/training/training_session.py`
104
+ - Train a multi‑layer model (short/medium/long sequences)
105
+ - Entry: `src/apps/learning/models/training/training_session.py`
106
+ - Make a one‑off prediction for a currency
107
+ - Entry: `src/apps/learning/models/training/training_session.py`
108
+ - Prediction and reporting lifecycle
109
+ - Entry: `src/apps/learning/models/training/training_session.py`
110
+ - Note: `TrainingSession.train()` will compute a prediction after training
111
+ and report it via the platform integration.
112
+ - Standalone utilities for sending predictions also exist under
113
+ `apps/learning/models/prediction/predictions.py` if needed.
114
+ - Run a GPU‑oriented launcher
115
+ - Scripts under `gpu/` (e.g., `gpu/run_gpu_zero.py`,
116
+ `gpu/run_gpu_one.py`).
117
+
118
+ Notes:
119
+ - Training hyperparameters can be chosen via `TrainingType`
120
+ (`src/apps/learning/models/training/training_type.py`) or by building a
121
+ `TrainingModel`.
122
+ - Multi‑layer models live under `src/apps/learning/models/ai/lstm/layered/...`.
123
+
124
+ ## 🔒 Safety, privacy, and control
125
+ - This module does not manage exchange API keys directly; it trains/predicts
126
+ from database data.
127
+ - Start with small datasets and paper trading.
128
+ - Guardrails (e.g., position sizing, stop loss) are enforced by the trading
129
+ engine, not this module.
130
+
131
+ ## 🛠️ Technology in this module
132
+ - Python 3
133
+ - TensorFlow + Keras
134
+ - NumPy, Pandas, scikit‑learn
135
+ - SQLAlchemy (COPY to CSV optimization)
136
+ - Requests (HTTP)
137
+ - `attrs` / `typing_extensions`
138
+
139
+ ## ❓ Questions or help
140
+ Email Oliver Lear Sigwarth (@theoliverlear): sigwarthsoftware@gmail.com
141
+
142
+ ## 📄 License
143
+ See `LICENSE.md` in the repository root.
@@ -0,0 +1,81 @@
1
+ src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ src/crypto_trader_analysis/__init__.py,sha256=ZEvklu_X70kYE0ETdFNaQ-U6WOzEn29FV_MQM7q53ZA,35
3
+ src/crypto_trader_analysis/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ src/crypto_trader_analysis/api/asgi.py,sha256=qEYabQUw4wsVlangU4Ung-FwbYjDmgFzAxsLRERyH1A,383
5
+ src/crypto_trader_analysis/api/settings.py,sha256=eLbodAJtsNgugji8XWfHJP5ozViUlZtnzaGLGOK8i_A,3561
6
+ src/crypto_trader_analysis/api/urls.py,sha256=ff2tt-H9NOLjMgIUVmgNeXBlRkj0YvnRl2Z-Vs3IdXk,823
7
+ src/crypto_trader_analysis/api/wsgi.py,sha256=uiQjxOHShAToF8O0B_ywbcf6F9svQWBNsOrKKtE_gu0,383
8
+ src/crypto_trader_analysis/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ src/crypto_trader_analysis/apps/learning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ src/crypto_trader_analysis/apps/learning/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ src/crypto_trader_analysis/apps/learning/models/currency_json_generator.py,sha256=TUFq-Nohbvn9RH1QdHJMNzUjEAjqSd4Pxo4dEEuzqTY,2241
12
+ src/crypto_trader_analysis/apps/learning/models/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ src/crypto_trader_analysis/apps/learning/models/ai/model_retriever.py,sha256=R7ZhYDjLlqOJigYJyZUgqfKvGje0u7bgicGm2VXlR3E,8033
14
+ src/crypto_trader_analysis/apps/learning/models/ai/model_type.py,sha256=_FsM3HlYBQWkKhMfIOo6c-cVpV02OOWS6RKvONMyymE,2187
15
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/base_model.py,sha256=r2ESu8pYJgDaZyPHSHInS7Gcs_8TMG-KUoqyS-8QxEY,1202
17
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/complex_lstm_model.py,sha256=pBomvFNCi9U3HWK08eAM_bhA4mj9uotcOr78pe-LDhk,4937
18
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/lstm_model.py,sha256=kT3SrFAlK6qbNgtIWFtCCNAK5o1ddqQ3T4hhIDkTSFY,4315
19
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/complex_multi_layer_lstm_model.py,sha256=e_nxIq391WeIyOFlCo123urCJ3dzPeL-ymUITlk9FQY,6321
21
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/multi_layer_base_model.py,sha256=83i4Cu0HWHe4fJYmBlAPK_WtWvEfH7peHGtUL0raVP4,441
22
+ src/crypto_trader_analysis/apps/learning/models/ai/lstm/layered/multi_layer_lstm_model.py,sha256=tkaZHbdu07BDvkfq3Oys5_2LoRAE_J0ltvtkc-WTs30,5352
23
+ src/crypto_trader_analysis/apps/learning/models/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ src/crypto_trader_analysis/apps/learning/models/data/preprocessor.py,sha256=pWNM3i9uVTf4sWV7Yw_XoWCpyqfdc-3fiKxK0veORPo,15651
25
+ src/crypto_trader_analysis/apps/learning/models/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ src/crypto_trader_analysis/apps/learning/models/database/database.py,sha256=m-wc__53tePxeRab7O67NDVKyClCLCtOISGsqOThjrs,11902
27
+ src/crypto_trader_analysis/apps/learning/models/database/query_load.py,sha256=Dt_F2-L4cckQUZUqIFuylK3aEEi9IxqjBa18hJzzn8c,89
28
+ src/crypto_trader_analysis/apps/learning/models/database/query_type.py,sha256=ubXrpIqgWUdvXrHuYQbwvUlUgMf5ScPQRieeFslvpEg,180
29
+ src/crypto_trader_analysis/apps/learning/models/prediction/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ src/crypto_trader_analysis/apps/learning/models/prediction/prediction.py,sha256=E9ytizZVRC1znaZKqqvj9mCTtSA-ih6JdZET_FovTbo,1050
31
+ src/crypto_trader_analysis/apps/learning/models/prediction/predictions.py,sha256=bjxUYwsmIeiAqPFYBs669wxNrZTac2-ZMmzenXy0dyM,7665
32
+ src/crypto_trader_analysis/apps/learning/models/training/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ src/crypto_trader_analysis/apps/learning/models/training/multi_layer_training_model.py,sha256=YG0dE_riGq2PEOaJAgpx_iiMd2QQqNyHYChUHOlfuW8,814
34
+ src/crypto_trader_analysis/apps/learning/models/training/multi_layer_training_model_builder.py,sha256=IsqWz7jiG1UUYDC4XW4GdkQCKt_VZ0CnZ-icSO4_jlw,1078
35
+ src/crypto_trader_analysis/apps/learning/models/training/train_model.py,sha256=kYRGMqAfZ6K-D_WReqipp-nZmFarf3Ubl6ww163iqoQ,23120
36
+ src/crypto_trader_analysis/apps/learning/models/training/training_model.py,sha256=vBz8ewvFNnoMgqsUN-SpTMjuzdn1iu8aD82tJSWMQuk,855
37
+ src/crypto_trader_analysis/apps/learning/models/training/training_model_builder.py,sha256=7ULxL9npn_VoOw5eWKePVKsyNWm4DNZ7pRWY0uyt2QU,2565
38
+ src/crypto_trader_analysis/apps/learning/models/training/training_session.py,sha256=QcKAFVQTaIBwsnawlRnTgvUh9xX7TWvwLoT6SsxUyKQ,19849
39
+ src/crypto_trader_analysis/apps/learning/models/training/training_type.py,sha256=DVfzuTjciyOyUFXIPw37170rERZDAE6mmzopHgLbcb0,8489
40
+ src/crypto_trader_analysis/apps/learning/models/training/correlations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
+ src/crypto_trader_analysis/apps/learning/models/training/correlations/colrelations_analyzer.py,sha256=iBMtEZJYrBuLSjbFhHbr0QOt7lAuBPUlrS1adIW_x14,2652
42
+ src/crypto_trader_analysis/apps/learning/models/training/specs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ src/crypto_trader_analysis/apps/learning/models/training/specs/batch_size_evaluations.py,sha256=56xitzozJgV5YMNtnrMlvpiaIzMO-EKVHEAUlWxtQ3w,138
44
+ src/crypto_trader_analysis/apps/learning/models/training/specs/dataset_size.py,sha256=9_1Gu9HFkHXTM3TcV9FfCoECHvJ7gVfr4DUi9PIFvsU,237
45
+ src/crypto_trader_analysis/apps/learning/models/training/specs/epoch_focus.py,sha256=DX6GbQigBissSejRox8QEENmcXHEdM2FiYppsK61NVM,298
46
+ src/crypto_trader_analysis/apps/learning/models/training/specs/sequence_length_sentiment.py,sha256=TShdU0uRc8faIq1V47NShMWovMINapzOI_7UEKqSb_U,811
47
+ src/crypto_trader_analysis/apps/news/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
+ src/crypto_trader_analysis/apps/news/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ src/crypto_trader_analysis/apps/news/models/fetch_articles.py,sha256=P4OqCtrHQW_XnX4o_NPbDlYy0hjcApxpma93R54P94A,7164
50
+ src/crypto_trader_analysis/apps/news/models/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
+ src/crypto_trader_analysis/apps/news/models/analysis/crypto_regex.py,sha256=I8nHsxOQZ7BkrKe4bVZ_1_gKOhsz3pXSAZhEY39n3Xo,696
52
+ src/crypto_trader_analysis/apps/news/models/analysis/parse_sentiment.py,sha256=BDBSEXFEMD-C2YccZ0s8axzbnDhZMXjAE291_NWXjlk,3387
53
+ src/crypto_trader_analysis/apps/news/models/analysis/sentiment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_analyzer.py,sha256=NA_SuYiQDnwSHwhK4nye4MPZCm2sTPhwmV60JIyp29A,331
55
+ src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_label.py,sha256=Gy62tErJYkZ5C50XRD4drwp3bkYUDIM2-2hZUW1uGwI,132
56
+ src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_model.py,sha256=0FNA0_v6tfKmCclL2Wh8XtTqcGfLXQ2n7j_u-KqRnus,5640
57
+ src/crypto_trader_analysis/apps/news/models/analysis/sentiment/sentiment_result.py,sha256=N5cKZXtl5ueCnLxjQJWN1wk3OR7oru3-lLqhdXgxRdg,903
58
+ src/crypto_trader_analysis/apps/news/models/article/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
+ src/crypto_trader_analysis/apps/news/models/article/article.py,sha256=XuDggSUfYf1DbLnljkvfaZQL5Ibx34tFrm5NBvVF_AE,611
60
+ src/crypto_trader_analysis/apps/news/models/article/scored_article.py,sha256=l9Yg3LAqg9-wBzVN7ikKqAnmjx7w3byd6O3ldCuzkcY,2122
61
+ src/crypto_trader_analysis/apps/news/models/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ src/crypto_trader_analysis/apps/news/models/sources/author_regex.py,sha256=JUn_xEQzT9EuT2C_qz_sviRYeR7Gg22DEP7loyA7J1c,8843
63
+ src/crypto_trader_analysis/apps/news/models/sources/news_source.py,sha256=-VOSAI7sDUvOyZMdxTkrbKAODDGs3p2G0eyVzPehCAM,139
64
+ src/crypto_trader_analysis/apps/news/models/sources/news_sources.json,sha256=n0kxUpA_MwfmjdxjvfSNif6a6lmQooYOE2AZhmuJV7k,1055
65
+ src/crypto_trader_analysis/apps/news/models/sources/news_sources.py,sha256=WiS9JcvF6lwjuwEeVSiiRkFsLe_s5Mk7UKfC-d5B7xw,1334
66
+ src/crypto_trader_analysis/apps/news/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
+ src/crypto_trader_analysis/apps/news/views/urls.py,sha256=NkoKaz0LkNYmLpXFUnzCAaMhtHg5F1Wab6eWqtIsXvU,122
68
+ src/crypto_trader_analysis/apps/news/views/sentiment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
+ src/crypto_trader_analysis/apps/news/views/sentiment/sentiment_harvest_view.py,sha256=3KYRxMr3NAUj4jw1v3XDw9wPKTJfM5xz9DVAeB_TPh4,1221
70
+ src/crypto_trader_analysis/apps/news/views/sentiment/urls.py,sha256=BEkmW9DK0MN7EtRsyri026pthyLTBOZWEGhGVWdysw4,330
71
+ src/crypto_trader_analysis/apps/news/views/sentiment/targeted/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
+ src/crypto_trader_analysis/apps/news/views/sentiment/targeted/date_targeted_sentiment_harvest_view.py,sha256=MMWq0X5xv_kusSELFTR1iAjM2jREcazt-RGBYOX2L8c,1341
73
+ src/crypto_trader_analysis/apps/news/views/sentiment/targeted/urls.py,sha256=-tMjOGfpzJ9HGqctFGrS_iVj5UhvqmYRaCwavQoAC5c,270
74
+ src/crypto_trader_analysis/gpu/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
+ src/crypto_trader_analysis/gpu/run_gpu_one.py,sha256=Ib8N3MXRzCDl-42lmVLLVQrfOwijy4zuvU19XTYTFEk,2282
76
+ src/crypto_trader_analysis/gpu/run_gpu_zero.py,sha256=y1cTMqfTzCL9NNoYD2yZzCZZrDJA4G5mi_F2GNN2KhA,2275
77
+ crypto_trader_analysis-0.1.2.dist-info/METADATA,sha256=bHueAGQqKaUVmgbOme7WW7GBzfWXE38sQtSrEIGitW8,6015
78
+ crypto_trader_analysis-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
79
+ crypto_trader_analysis-0.1.2.dist-info/entry_points.txt,sha256=3chqX6loViYQz8PqTlMTAnJJJ-Vbzc9fwktNqZ1CwO0,164
80
+ crypto_trader_analysis-0.1.2.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
81
+ crypto_trader_analysis-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ crypto-trader-gpu-one = src.crypto_trader_analysis.gpu.run_gpu_one:main
3
+ crypto-trader-gpu-zero = src.crypto_trader_analysis.gpu.run_gpu_zero:main
src/__init__.py ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ __all__ = []
2
+ __version__ = "0.1.2"
File without changes
@@ -0,0 +1,16 @@
1
+ """
2
+ ASGI config for api project.
3
+
4
+ It exposes the ASGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.asgi import get_asgi_application
13
+
14
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
15
+
16
+ application = get_asgi_application()
@@ -0,0 +1,139 @@
1
+ """
2
+ Django settings for api project.
3
+
4
+ Generated by 'django-admin startproject' using Django 5.1.7.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.1/topics/settings/
8
+
9
+ For the full list of settings and their values, see
10
+ https://docs.djangoproject.com/en/5.1/ref/settings/
11
+ """
12
+ import os
13
+ from os import getenv
14
+ from pathlib import Path
15
+
16
+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
17
+ BASE_DIR = Path(__file__).resolve().parent.parent
18
+
19
+
20
+ # Quick-start development settings - unsuitable for production
21
+ # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
22
+
23
+ # SECURITY WARNING: keep the secret key used in production secret!
24
+ SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
25
+
26
+ # SECURITY WARNING: don't run with debug turned on in production!
27
+ DEBUG = True
28
+
29
+ ALLOWED_HOSTS = []
30
+
31
+
32
+ # Application definition
33
+
34
+ INSTALLED_APPS = [
35
+ 'django.contrib.admin',
36
+ 'django.contrib.auth',
37
+ 'django.contrib.contenttypes',
38
+ 'django.contrib.sessions',
39
+ 'django.contrib.messages',
40
+ 'django.contrib.staticfiles',
41
+ ]
42
+
43
+ MIDDLEWARE = [
44
+ 'django.middleware.security.SecurityMiddleware',
45
+ 'django.contrib.sessions.middleware.SessionMiddleware',
46
+ 'django.middleware.common.CommonMiddleware',
47
+ 'django.middleware.csrf.CsrfViewMiddleware',
48
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
49
+ 'django.contrib.messages.middleware.MessageMiddleware',
50
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51
+ ]
52
+
53
+ ROOT_URLCONF = 'api.urls'
54
+
55
+ TEMPLATES = [
56
+ {
57
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58
+ 'DIRS': [],
59
+ 'APP_DIRS': True,
60
+ 'OPTIONS': {
61
+ 'context_processors': [
62
+ 'django.template.context_processors.debug',
63
+ 'django.template.context_processors.request',
64
+ 'django.contrib.auth.context_processors.auth',
65
+ 'django.contrib.messages.context_processors.messages',
66
+ ],
67
+ },
68
+ },
69
+ ]
70
+
71
+ WSGI_APPLICATION = 'api.wsgi.application'
72
+
73
+
74
+ # Database
75
+ # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
76
+
77
+ DATABASES = {
78
+ 'default': {
79
+ 'ENGINE': 'django.db.backends.postgresql',
80
+ 'NAME': 'crypto_trader',
81
+ 'USER': getenv('PSQL_USER'),
82
+ 'PASSWORD': getenv('PSQL_PW'),
83
+ 'HOST': getenv('PSQL_HOST'),
84
+ 'PORT': 5432
85
+ }
86
+ }
87
+
88
+
89
+ # Password validation
90
+ # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
91
+
92
+ AUTH_PASSWORD_VALIDATORS = [
93
+ {
94
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
95
+ },
96
+ {
97
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
98
+ },
99
+ {
100
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
101
+ },
102
+ {
103
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
104
+ },
105
+ ]
106
+
107
+ CSRF_TRUSTED_ORIGINS = [
108
+ 'http://localhost:8080',
109
+ 'http://127.0.0.1:8080',
110
+ 'http://localhost:8081',
111
+ 'http://127.0.0.1:8081'
112
+ ]
113
+
114
+ CORS_ALLOWED_ORIGINS = [
115
+ "http://localhost:8081",
116
+ "http://localhost:8080"
117
+ ]
118
+
119
+ # Internationalization
120
+ # https://docs.djangoproject.com/en/5.1/topics/i18n/
121
+
122
+ LANGUAGE_CODE = 'en-us'
123
+
124
+ TIME_ZONE = 'UTC'
125
+
126
+ USE_I18N = True
127
+
128
+ USE_TZ = True
129
+
130
+
131
+ # Static files (CSS, JavaScript, Images)
132
+ # https://docs.djangoproject.com/en/5.1/howto/static-files/
133
+
134
+ STATIC_URL = 'static/'
135
+
136
+ # Default primary key field type
137
+ # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
138
+
139
+ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
@@ -0,0 +1,23 @@
1
+ """
2
+ URL configuration for api project.
3
+
4
+ The `urlpatterns` list routes URLs to views. For more information please see:
5
+ https://docs.djangoproject.com/en/5.1/topics/http/urls/
6
+ Examples:
7
+ Function views
8
+ 1. Add an import: from my_app import views
9
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
10
+ Class-based views
11
+ 1. Add an import: from other_app.views import Home
12
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13
+ Including another URLconf
14
+ 1. Import the include() function: from django.urls import include, path
15
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16
+ """
17
+ from django.contrib import admin
18
+ from django.urls import path, include
19
+
20
+ urlpatterns = [
21
+ path('admin/', admin.site.urls),
22
+ path('api/news/', include('apps.news.views.urls'))
23
+ ]
@@ -0,0 +1,16 @@
1
+ """
2
+ WSGI config for api project.
3
+
4
+ It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.wsgi import get_wsgi_application
13
+
14
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
15
+
16
+ application = get_wsgi_application()
File without changes
File without changes
@@ -0,0 +1,50 @@
1
+ import logging
2
+ from abc import ABC, abstractmethod
3
+
4
+ from attr import attr
5
+ from attrs import define
6
+ from keras import Sequential, Model
7
+ from sklearn.preprocessing import MinMaxScaler
8
+ import tensorflow as tf
9
+
10
+
11
+ @define
12
+ class BaseModel(ABC):
13
+ dimension = attr(default=None)
14
+ model: Model = attr(factory=Sequential)
15
+ sequence_length: int = attr(default=10)
16
+ target_currency: str = attr(default='BTC')
17
+
18
+ @abstractmethod
19
+ def train(self,
20
+ dataset: tf.data.Dataset,
21
+ epochs: int = 20,
22
+ batch_size: int = 32):
23
+ pass
24
+
25
+ @abstractmethod
26
+ def predict(self,
27
+ training_data,
28
+ scaler: MinMaxScaler):
29
+ pass
30
+
31
+ @abstractmethod
32
+ def save_model(self, path: str):
33
+ pass
34
+
35
+ @abstractmethod
36
+ def load_model(self, path: str):
37
+ pass
38
+
39
+ @staticmethod
40
+ @abstractmethod
41
+ def get_model_path(target_currency: str) -> str:
42
+ pass
43
+
44
+ @staticmethod
45
+ def get_tensorboard_callback(self):
46
+ pass
47
+
48
+ def log_model_summary(self):
49
+ logging.info("\n" + "=" * 40 + "\nModel Summary:\n" + "=" * 40)
50
+ self.model.summary(print_fn=lambda print_func: logging.info(print_func))
@@ -0,0 +1,123 @@
1
+ # complex_lstm_model.py
2
+ import logging
3
+ from datetime import datetime
4
+
5
+ from typing_extensions import override
6
+ from attrs import define
7
+ from keras import Sequential, Input
8
+ from keras.layers import Bidirectional, LSTM, Dropout, BatchNormalization, \
9
+ Dense
10
+ from keras.saving.save import load_model
11
+ from src.crypto_trader_analysis.apps.learning.models.ai.lstm.base_model import BaseModel
12
+ import os
13
+ from keras.callbacks import EarlyStopping, ModelCheckpoint, ReduceLROnPlateau
14
+ import tensorflow as tf
15
+
16
+ @define
17
+ class ComplexLstmModel(BaseModel):
18
+ def __attrs_post_init__(self):
19
+ self.initialize_model()
20
+
21
+ def initialize_model(self):
22
+ self.model = Sequential([
23
+ Input(shape=(self.sequence_length, self.dimension)),
24
+ self.get_lstm_layer(512, True),
25
+ Dropout(0.3),
26
+ BatchNormalization(),
27
+ self.get_lstm_layer(384, True),
28
+ Dropout(0.3),
29
+ BatchNormalization(),
30
+ self.get_lstm_layer(256, True),
31
+ Dropout(0.3),
32
+ BatchNormalization(),
33
+ self.get_lstm_layer(128, False),
34
+ Dropout(0.3),
35
+ Dense(256, activation="relu"),
36
+ Dense(128, activation="relu"),
37
+ Dense(64, activation="relu"),
38
+ Dense(1)
39
+ ])
40
+ self.model.compile(optimizer="adam", loss="mean_squared_error")
41
+ self.log_model_summary()
42
+
43
+ @staticmethod
44
+ def get_lstm_layer(layers: int, return_sequences: bool):
45
+ return Bidirectional(LSTM(layers,
46
+ return_sequences=return_sequences,
47
+ recurrent_activation="sigmoid",
48
+ use_bias=True,
49
+ unroll=True))
50
+
51
+ @override
52
+ @staticmethod
53
+ def get_tensorboard_callback(target_currency: str):
54
+ import tensorflow as tf
55
+ timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
56
+ log_dir = os.path.join("logs", "COMPLEX_LSTM_MODEL", target_currency, timestamp)
57
+ return tf.keras.callbacks.TensorBoard(
58
+ log_dir=log_dir,
59
+ profile_batch=10,
60
+ histogram_freq=1
61
+ )
62
+
63
+ @override
64
+ def train(self,
65
+ dataset: tf.data.Dataset,
66
+ epochs: int = 20,
67
+ batch_size: int = 32):
68
+ from src.crypto_trader_analysis.apps.learning.models.ai.model_retriever import COMPLEX_MODEL_DIRECTORY
69
+ checkpoint_dir = os.path.join(COMPLEX_MODEL_DIRECTORY, "checkpoints")
70
+ os.makedirs(checkpoint_dir, exist_ok=True)
71
+ checkpoint_path = os.path.join(checkpoint_dir,
72
+ f"{self.target_currency}_checkpoint.keras")
73
+ callbacks = [
74
+ EarlyStopping(monitor="loss", patience=5,
75
+ restore_best_weights=True),
76
+ ModelCheckpoint(filepath=checkpoint_path, monitor="loss",
77
+ save_best_only=True),
78
+ ReduceLROnPlateau(monitor='loss', factor=0.5, patience=3,
79
+ min_lr=1e-6),
80
+ ComplexLstmModel.get_tensorboard_callback(self.target_currency)
81
+ ]
82
+ while True:
83
+ try:
84
+ return self.model.fit(dataset,
85
+ epochs=epochs,
86
+ batch_size=batch_size,
87
+ verbose=1,
88
+ callbacks=callbacks)
89
+ except Exception as exception:
90
+ from src.crypto_trader_analysis.apps.learning.models.ai.model_type import ModelType
91
+ from src.crypto_trader_analysis.apps.learning.models.ai.model_retriever import model_exists, \
92
+ delete_model
93
+ if "Input 0 of layer" in str(exception):
94
+ logging.info("Model dimension mismatch. Re-training model.")
95
+ complex_lstm_model_exists: bool = model_exists(self.target_currency,
96
+ ModelType.COMPLEX_LSTM)
97
+ if complex_lstm_model_exists:
98
+ delete_model(self.target_currency,
99
+ ModelType.COMPLEX_LSTM)
100
+ self.initialize_model()
101
+
102
+ else:
103
+ raise
104
+
105
+ @override
106
+ def predict(self, training_data, target_scaler):
107
+ scaled_pred = self.model.predict(training_data)
108
+ real_price = target_scaler.inverse_transform(scaled_pred)[0][0]
109
+ return real_price
110
+
111
+ @override
112
+ def save_model(self, path: str):
113
+ self.model.save(path)
114
+
115
+ @override
116
+ def load_model(self, path: str):
117
+ self.model = load_model(path)
118
+
119
+ @staticmethod
120
+ @override
121
+ def get_model_path(target_currency: str) -> str:
122
+ from src.crypto_trader_analysis.apps.learning.models.ai.model_retriever import COMPLEX_MODEL_DIRECTORY
123
+ return COMPLEX_MODEL_DIRECTORY + target_currency + '_complex_model.keras'