kuhl-haus-mdp 0.0.1__tar.gz

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 (32) hide show
  1. kuhl_haus_mdp-0.0.1/LICENSE.txt +21 -0
  2. kuhl_haus_mdp-0.0.1/PKG-INFO +79 -0
  3. kuhl_haus_mdp-0.0.1/README.md +28 -0
  4. kuhl_haus_mdp-0.0.1/pyproject.toml +113 -0
  5. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/__init__.py +10 -0
  6. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/analyzers/__init__.py +0 -0
  7. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/analyzers/analyzer.py +15 -0
  8. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/analyzers/massive_data_analyzer.py +102 -0
  9. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/analyzers/top_stocks.py +408 -0
  10. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/components/__init__.py +0 -0
  11. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/components/market_data_cache.py +29 -0
  12. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/components/market_data_scanner.py +236 -0
  13. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/components/widget_data_service.py +191 -0
  14. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/helpers/__init__.py +0 -0
  15. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/helpers/process_manager.py +228 -0
  16. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/helpers/queue_name_resolver.py +24 -0
  17. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/integ/__init__.py +0 -0
  18. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/integ/massive_data_listener.py +140 -0
  19. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/integ/massive_data_processor.py +236 -0
  20. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/integ/massive_data_queues.py +124 -0
  21. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/integ/utils.py +27 -0
  22. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/integ/web_socket_message_serde.py +143 -0
  23. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/models/__init__.py +0 -0
  24. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/models/market_data_analyzer_result.py +16 -0
  25. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/models/market_data_cache_keys.py +28 -0
  26. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/models/market_data_pubsub_keys.py +27 -0
  27. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/models/market_data_scanner_names.py +10 -0
  28. kuhl_haus_mdp-0.0.1/src/kuhl_haus/mdp/models/massive_data_queue.py +10 -0
  29. kuhl_haus_mdp-0.0.1/tests/__init__.py +0 -0
  30. kuhl_haus_mdp-0.0.1/tests/components/test_widget_data_service.py +54 -0
  31. kuhl_haus_mdp-0.0.1/tests/helpers/__init__.py +0 -0
  32. kuhl_haus_mdp-0.0.1/tests/helpers/test_process_manager.py +130 -0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Tom Pounders
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.1
2
+ Name: kuhl-haus-mdp
3
+ Version: 0.0.1
4
+ Summary: Market data processing pipeline for stock market scanner
5
+ Author-Email: Tom Pounders <git@oldschool.engineer>
6
+ License: The MIT License (MIT)
7
+
8
+ Copyright (c) 2025 Tom Pounders
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Development Status :: 4 - Beta
29
+ Classifier: Programming Language :: Python
30
+ Project-URL: Homepage, https://github.com/kuhl-haus/kuhl-haus-mdp
31
+ Project-URL: Documentation, https://github.com/kuhl-haus/kuhl-haus-mdp/wiki
32
+ Project-URL: Source, https://github.com/kuhl-haus/kuhl-haus-mdp.git
33
+ Project-URL: Changelog, https://github.com/kuhl-haus/kuhl-haus-mdp/commits
34
+ Project-URL: Tracker, https://github.com/kuhl-haus/kuhl-haus-mdp/issues
35
+ Requires-Python: <3.13,>=3.9.21
36
+ Requires-Dist: websockets
37
+ Requires-Dist: aio-pika
38
+ Requires-Dist: redis[asyncio]
39
+ Requires-Dist: tenacity
40
+ Requires-Dist: fastapi
41
+ Requires-Dist: uvicorn[standard]
42
+ Requires-Dist: pydantic-settings
43
+ Requires-Dist: python-dotenv
44
+ Requires-Dist: massive
45
+ Provides-Extra: testing
46
+ Requires-Dist: setuptools; extra == "testing"
47
+ Requires-Dist: pdm-backend; extra == "testing"
48
+ Requires-Dist: pytest; extra == "testing"
49
+ Requires-Dist: pytest-cov; extra == "testing"
50
+ Description-Content-Type: text/markdown
51
+
52
+ <!-- These are examples of badges you might want to add to your README:
53
+ please update the URLs accordingly
54
+
55
+ [![ReadTheDocs](https://readthedocs.org/projects/kuhl-haus-mdp/badge/?version=latest)](https://kuhl-haus-mdp.readthedocs.io/en/stable/)
56
+ [![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/kuhl-haus-mdp.svg)](https://anaconda.org/conda-forge/kuhl-haus-mdp)
57
+ [![Monthly Downloads](https://pepy.tech/badge/kuhl-haus-mdp/month)](https://pepy.tech/project/kuhl-haus-mdp)
58
+ -->
59
+
60
+
61
+ [![License](https://img.shields.io/github/license/kuhl-haus/kuhl-haus-mdp)](https://github.com/kuhl-haus/kuhl-haus-mdp/blob/mainline/LICENSE.txt)
62
+ [![PyPI](https://img.shields.io/pypi/v/kuhl-haus-mdp.svg)](https://pypi.org/project/kuhl-haus-mdp/)
63
+ [![Downloads](https://static.pepy.tech/badge/kuhl-haus-mdp/month)](https://pepy.tech/project/kuhl-haus-mdp)
64
+ [![Build Status](https://github.com/kuhl-haus/kuhl-haus-mdp/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/kuhl-haus/kuhl-haus-mdp/actions/workflows/publish-to-pypi.yml)
65
+ [![CodeQL](https://github.com/kuhl-haus/kuhl-haus-mdp/workflows/CodeQL/badge.svg)](https://github.com/kuhl-haus/kuhl-haus-mdp/actions/workflows/github-code-scanning/codeql/)
66
+ [![codecov](https://codecov.io/gh/kuhl-haus/kuhl-haus-mdp/branch/mainline/graph/badge.svg)](https://codecov.io/gh/kuhl-haus/kuhl-haus-mdp)
67
+ [![GitHub issues](https://img.shields.io/github/issues/kuhl-haus/kuhl-haus-mdp)](https://github.com/kuhl-haus/kuhl-haus-mdp/issues)
68
+ [![GitHub pull requests](https://img.shields.io/github/issues-pr/kuhl-haus/kuhl-haus-mdp)](https://github.com/kuhl-haus/kuhl-haus-mdp/pulls)
69
+
70
+
71
+ # kuhl-haus-mdp
72
+
73
+ Market data processing pipeline for stock market scanner.
74
+
75
+
76
+ ## Note
77
+
78
+ This project has been set up using PyScaffold 4.6. For details and usage
79
+ information on PyScaffold see https://pyscaffold.org/.
@@ -0,0 +1,28 @@
1
+ <!-- These are examples of badges you might want to add to your README:
2
+ please update the URLs accordingly
3
+
4
+ [![ReadTheDocs](https://readthedocs.org/projects/kuhl-haus-mdp/badge/?version=latest)](https://kuhl-haus-mdp.readthedocs.io/en/stable/)
5
+ [![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/kuhl-haus-mdp.svg)](https://anaconda.org/conda-forge/kuhl-haus-mdp)
6
+ [![Monthly Downloads](https://pepy.tech/badge/kuhl-haus-mdp/month)](https://pepy.tech/project/kuhl-haus-mdp)
7
+ -->
8
+
9
+
10
+ [![License](https://img.shields.io/github/license/kuhl-haus/kuhl-haus-mdp)](https://github.com/kuhl-haus/kuhl-haus-mdp/blob/mainline/LICENSE.txt)
11
+ [![PyPI](https://img.shields.io/pypi/v/kuhl-haus-mdp.svg)](https://pypi.org/project/kuhl-haus-mdp/)
12
+ [![Downloads](https://static.pepy.tech/badge/kuhl-haus-mdp/month)](https://pepy.tech/project/kuhl-haus-mdp)
13
+ [![Build Status](https://github.com/kuhl-haus/kuhl-haus-mdp/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/kuhl-haus/kuhl-haus-mdp/actions/workflows/publish-to-pypi.yml)
14
+ [![CodeQL](https://github.com/kuhl-haus/kuhl-haus-mdp/workflows/CodeQL/badge.svg)](https://github.com/kuhl-haus/kuhl-haus-mdp/actions/workflows/github-code-scanning/codeql/)
15
+ [![codecov](https://codecov.io/gh/kuhl-haus/kuhl-haus-mdp/branch/mainline/graph/badge.svg)](https://codecov.io/gh/kuhl-haus/kuhl-haus-mdp)
16
+ [![GitHub issues](https://img.shields.io/github/issues/kuhl-haus/kuhl-haus-mdp)](https://github.com/kuhl-haus/kuhl-haus-mdp/issues)
17
+ [![GitHub pull requests](https://img.shields.io/github/issues-pr/kuhl-haus/kuhl-haus-mdp)](https://github.com/kuhl-haus/kuhl-haus-mdp/pulls)
18
+
19
+
20
+ # kuhl-haus-mdp
21
+
22
+ Market data processing pipeline for stock market scanner.
23
+
24
+
25
+ ## Note
26
+
27
+ This project has been set up using PyScaffold 4.6. For details and usage
28
+ information on PyScaffold see https://pyscaffold.org/.
@@ -0,0 +1,113 @@
1
+ [build-system]
2
+ requires = [
3
+ "pdm-backend",
4
+ ]
5
+ build-backend = "pdm.backend"
6
+
7
+ [project]
8
+ name = "kuhl-haus-mdp"
9
+ version = "0.0.1"
10
+ description = "Market data processing pipeline for stock market scanner"
11
+ authors = [
12
+ { name = "Tom Pounders", email = "git@oldschool.engineer" },
13
+ ]
14
+ readme = "README.md"
15
+ requires-python = "<3.13,>=3.9.21"
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Programming Language :: Python",
19
+ ]
20
+ dependencies = [
21
+ "websockets",
22
+ "aio-pika",
23
+ "redis[asyncio]",
24
+ "tenacity",
25
+ "fastapi",
26
+ "uvicorn[standard]",
27
+ "pydantic-settings",
28
+ "python-dotenv",
29
+ "massive",
30
+ ]
31
+
32
+ [project.license]
33
+ file = "LICENSE.txt"
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/kuhl-haus/kuhl-haus-mdp"
37
+ Documentation = "https://github.com/kuhl-haus/kuhl-haus-mdp/wiki"
38
+ Source = "https://github.com/kuhl-haus/kuhl-haus-mdp.git"
39
+ Changelog = "https://github.com/kuhl-haus/kuhl-haus-mdp/commits"
40
+ Tracker = "https://github.com/kuhl-haus/kuhl-haus-mdp/issues"
41
+
42
+ [project.optional-dependencies]
43
+ testing = [
44
+ "setuptools",
45
+ "pdm-backend",
46
+ "pytest",
47
+ "pytest-cov",
48
+ ]
49
+
50
+ [tool.setuptools]
51
+ zip-safe = true
52
+ include-package-data = true
53
+
54
+ [tool.setuptools.package-dir]
55
+ "" = "src"
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = [
59
+ "src",
60
+ ]
61
+ exclude = [
62
+ "tests",
63
+ ]
64
+
65
+ [tool.pytest.ini_options]
66
+ addopts = [
67
+ "--verbose",
68
+ ]
69
+ norecursedirs = [
70
+ "dist",
71
+ "build",
72
+ ".tox",
73
+ ]
74
+ testpaths = [
75
+ "tests",
76
+ ]
77
+
78
+ [tool.devpi.upload]
79
+ no_vcs = 1
80
+ formats = [
81
+ "bdist_wheel",
82
+ ]
83
+
84
+ [tool.flake8]
85
+ max_line_length = 88
86
+ extend_ignore = [
87
+ "E203",
88
+ "W503",
89
+ ]
90
+ exclude = [
91
+ ".tox",
92
+ "build",
93
+ "dist",
94
+ ".eggs",
95
+ "docs/conf.py",
96
+ ]
97
+
98
+ [tool.pyscaffold]
99
+ version = "4.6"
100
+ package = "mdp"
101
+ extensions = [
102
+ "namespace",
103
+ ]
104
+ namespace = "kuhl_haus"
105
+
106
+ [tool.pdm]
107
+ distribution = true
108
+
109
+ [tool.pdm.build]
110
+ package-dir = "src"
111
+ includes = [
112
+ "src/kuhl_haus",
113
+ ]
@@ -0,0 +1,10 @@
1
+ from importlib_metadata import PackageNotFoundError, version # pragma: no cover
2
+
3
+ try:
4
+ # Change here if project is renamed and does not equal the package name
5
+ dist_name = __name__
6
+ __version__ = version(dist_name)
7
+ except PackageNotFoundError: # pragma: no cover
8
+ __version__ = "unknown"
9
+ finally:
10
+ del version, PackageNotFoundError
@@ -0,0 +1,15 @@
1
+ from typing import Optional, List
2
+ from kuhl_haus.mdp.models.market_data_analyzer_result import MarketDataAnalyzerResult
3
+
4
+
5
+ class Analyzer:
6
+ cache_key: str
7
+
8
+ def __init__(self, cache_key: str, **kwargs):
9
+ self.cache_key = cache_key
10
+
11
+ async def rehydrate(self, data: dict):
12
+ pass
13
+
14
+ async def analyze_data(self, data: dict) -> Optional[List[MarketDataAnalyzerResult]]:
15
+ pass
@@ -0,0 +1,102 @@
1
+ import logging
2
+ from time import time
3
+ from typing import List, Optional
4
+ from massive.websocket.models import EventType
5
+
6
+ from kuhl_haus.mdp.models.market_data_analyzer_result import MarketDataAnalyzerResult
7
+ from kuhl_haus.mdp.models.market_data_cache_keys import MarketDataCacheKeys
8
+
9
+
10
+ class MassiveDataAnalyzer:
11
+ def __init__(self):
12
+ self.logger = logging.getLogger(__name__)
13
+ self.event_handlers = {
14
+ EventType.LimitUpLimitDown.value: self.handle_luld_event,
15
+ EventType.EquityAgg.value: self.handle_equity_agg_event,
16
+ EventType.EquityAggMin.value: self.handle_equity_agg_event,
17
+ EventType.EquityTrade.value: self.handle_equity_trade_event,
18
+ EventType.EquityQuote.value: self.handle_equity_quote_event,
19
+ }
20
+
21
+ async def analyze_data(self, data: dict) -> Optional[List[MarketDataAnalyzerResult]]:
22
+ """
23
+ Process raw market data message
24
+
25
+ Args:
26
+ data: serialized message from Massive/Polygon.io
27
+
28
+ Returns:
29
+ Processed result dict or None if message should be discarded
30
+ """
31
+ if "event_type" not in data:
32
+ self.logger.info("Message missing 'event_type'")
33
+ return await self.handle_unknown_event(data)
34
+ event_type = data.get("event_type")
35
+
36
+ if "symbol" not in data:
37
+ self.logger.info("Message missing 'symbol'")
38
+ return await self.handle_unknown_event(data)
39
+ symbol = data.get("symbol")
40
+
41
+ if event_type in self.event_handlers:
42
+ return await self.event_handlers[event_type](**{"data": data, "symbol": symbol})
43
+ else:
44
+ self.logger.warning(f"Unsupported message type: {event_type}")
45
+ return await self.handle_unknown_event(data)
46
+
47
+ async def handle_luld_event(self, data: dict, symbol: str) -> Optional[List[MarketDataAnalyzerResult]]:
48
+ try:
49
+ return [MarketDataAnalyzerResult(
50
+ data=data,
51
+ cache_key=f"{MarketDataCacheKeys.HALTS.value}:{symbol}",
52
+ cache_ttl=28500, # 7 hours, 55 minutes
53
+ publish_key=f"{MarketDataCacheKeys.HALTS.value}:{symbol}",
54
+ )]
55
+ except Exception as e:
56
+ self.logger.error(f"Error processing LULD message for {symbol}: {data}", e)
57
+
58
+ async def handle_equity_agg_event(self, data: dict, symbol: str) -> Optional[List[MarketDataAnalyzerResult]]:
59
+ try:
60
+ return [MarketDataAnalyzerResult(
61
+ data=data,
62
+ # cache_key=f"{MarketDataCacheKeys.AGGREGATE.value}:{symbol}",
63
+ # cache_ttl=259200, # 3 days
64
+ publish_key=f"{MarketDataCacheKeys.AGGREGATE.value}:{symbol}",
65
+ )]
66
+ except Exception as e:
67
+ self.logger.error(f"Error processing EquityAgg message for {symbol}: {data}", e)
68
+
69
+ async def handle_equity_trade_event(self, data: dict, symbol: str) -> Optional[List[MarketDataAnalyzerResult]]:
70
+ try:
71
+ return [MarketDataAnalyzerResult(
72
+ data=data,
73
+ # cache_key=f"{MarketDataCacheKeys.TRADES.value}:{symbol}",
74
+ # cache_ttl=28500, # 7 hours, 55 minutes
75
+ publish_key=f"{MarketDataCacheKeys.TRADES.value}:{symbol}",
76
+ )]
77
+ except Exception as e:
78
+ self.logger.error(f"Error processing EquityTrade message for {symbol}: {data}", e)
79
+
80
+ async def handle_equity_quote_event(self, data: dict, symbol: str) -> Optional[List[MarketDataAnalyzerResult]]:
81
+ try:
82
+ return [MarketDataAnalyzerResult(
83
+ data=data,
84
+ # cache_key=f"{MarketDataCacheKeys.QUOTES.value}:{symbol}",
85
+ # cache_ttl=259200, # 3 days
86
+ publish_key=f"{MarketDataCacheKeys.QUOTES.value}:{symbol}",
87
+ )]
88
+ except Exception as e:
89
+ self.logger.error(f"Error processing EquityQuote message for {symbol}: {data}", e)
90
+
91
+ async def handle_unknown_event(self, data: dict) -> Optional[List[MarketDataAnalyzerResult]]:
92
+ try:
93
+ timestamp = f"{time()}".replace('.','')
94
+ cache_key = f"{MarketDataCacheKeys.UNKNOWN.value}:{timestamp}"
95
+ return [MarketDataAnalyzerResult(
96
+ data=data,
97
+ cache_key=cache_key,
98
+ cache_ttl=86400, # 1 days
99
+ publish_key=f"{MarketDataCacheKeys.UNKNOWN.value}",
100
+ )]
101
+ except Exception as e:
102
+ self.logger.error(f"Error processing unknown message type: {data}", e)