yticker 0.1.0__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.
yticker-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tapanhaz
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.
yticker-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.1
2
+ Name: yticker
3
+ Version: 0.1.0
4
+ Summary: A Python package for connecting to yahoo websocket.
5
+ Home-page: https://github.com/Tapanhaz/yticker
6
+ Author: Tapan Hazarika
7
+ Author-email: tapanhaz@gmail.com
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 Tapanhaz
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ Classifier: Programming Language :: Python :: 3
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ License-File: LICENSE
33
+ Requires-Dist: Cython
34
+ Requires-Dist: picows
35
+ Requires-Dist: pyrobuf
36
+ Requires-Dist: orjson
37
+ Requires-Dist: uvloop
@@ -0,0 +1,70 @@
1
+ # yticker
2
+ Cython based async python websocket client for yahoo based on picows : https://github.com/tarasko/picows
3
+
4
+
5
+ For installation run:
6
+
7
+ ```
8
+ pip install yticker
9
+ ```
10
+
11
+ #Example ::
12
+ ===================
13
+ ```python
14
+
15
+ import time
16
+ import asyncio
17
+ import logging
18
+ import platform
19
+ import warnings
20
+ from yticker import YTicker
21
+
22
+ warnings.filterwarnings("error")
23
+
24
+ logging.basicConfig(level= logging.DEBUG)
25
+
26
+ if platform.system() == "Windows":
27
+ import winloop
28
+ asyncio.set_event_loop_policy(winloop.EventLoopPolicy())
29
+ else:
30
+ import uvloop
31
+ asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
32
+
33
+ async def on_tick(msg):
34
+ print(msg)
35
+
36
+ async def on_open(msg):
37
+ print(f"{time.asctime()} : {msg}")
38
+
39
+ async def on_close(msg):
40
+ print(f"{time.asctime()} : {msg}")
41
+
42
+ async def on_error(msg):
43
+ print(f"{time.asctime()} : {msg}")
44
+
45
+ async def main(loop):
46
+ ticker = YTicker(loop)
47
+ ticker.start_websocket(
48
+ message_update_callback= on_tick,
49
+ open_callback= on_open,
50
+ close_callback= on_close,
51
+ error_callback= on_error
52
+ )
53
+ await ticker.IS_CONNECTED.wait()
54
+ await ticker.subscribe(["BTC-USD", "EURUSD=X", "^NSEI", "RELIANCE.NS", "SBIN.BO"])
55
+ #Sample unsubscribe
56
+ await asyncio.sleep(10)
57
+ await ticker.unsubscribe(["BTC_USD", "^NSEI"])
58
+ #Close websocket
59
+ await asyncio.sleep(10)
60
+ ticker.close_websocket()
61
+
62
+ if __name__ == "__main__":
63
+ try:
64
+ loop = asyncio.get_event_loop()
65
+ except DeprecationWarning:
66
+ loop = asyncio.new_event_loop()
67
+ loop.create_task(main(loop))
68
+ loop.run_forever()
69
+
70
+ ```
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
yticker-0.1.0/setup.py ADDED
@@ -0,0 +1,80 @@
1
+ import os
2
+ import sys
3
+ import platform
4
+ import subprocess
5
+ from Cython.Build import cythonize
6
+ from setuptools import setup, Extension, find_packages
7
+ try:
8
+ from pyrobuf import __path__ as pyrobuf_path
9
+ except ModuleNotFoundError:
10
+ print("pyrobuf not found. Installing...")
11
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "pyrobuf"])
12
+ finally:
13
+ from pyrobuf import __path__ as pyrobuf_path
14
+
15
+ pyrobuf_src_path = os.path.join(pyrobuf_path[0], 'src')
16
+
17
+ compiler_flags = []
18
+ linker_flags = []
19
+ install_requires = ["Cython", "picows", "pyrobuf", "orjson"]
20
+
21
+ if platform.system() == "Windows":
22
+ if "msvc" in sys.version.lower():
23
+ compiler_flags = ['/std:c++17', "/O2"]
24
+ linker_flags = ["/O2"]
25
+ elif "gcc" in sys.version.lower() or "clang" in sys.version.lower():
26
+ compiler_flags = ["-O3", '-flto']
27
+ linker_flags = ["-O3"]
28
+ event_loop = "winloop"
29
+ else:
30
+ compiler_flags = ["-O3", '-flto']
31
+ linker_flags = ["-O3"]
32
+ event_loop = "uvloop"
33
+
34
+ install_requires.append(event_loop)
35
+
36
+ extensions = [
37
+ Extension(
38
+ name="yticker.yaticker_proto",
39
+ sources=["yticker/yaticker_proto.pyx"],
40
+ language="c++",
41
+ include_dirs=[pyrobuf_src_path],
42
+ extra_compile_args=compiler_flags,
43
+ extra_link_args=linker_flags
44
+ ),
45
+ Extension(
46
+ name="yticker.yticker",
47
+ sources=["yticker/yticker.pyx"],
48
+ language="c++",
49
+ extra_compile_args=compiler_flags,
50
+ extra_link_args=linker_flags
51
+ ),
52
+ ]
53
+
54
+ cythonized_extensions = cythonize(
55
+ extensions,
56
+ include_path=[pyrobuf_src_path],
57
+ compiler_directives={'language_level': "3"}
58
+ )
59
+
60
+ with open("LICENSE", "r", encoding="utf-8") as fh:
61
+ license_file = fh.read()
62
+
63
+ setup(
64
+ name="yticker",
65
+ version="0.1.0",
66
+ author="Tapan Hazarika",
67
+ author_email="tapanhaz@gmail.com",
68
+ description="A Python package for connecting to yahoo websocket.",
69
+ license= license_file,
70
+ url="https://github.com/Tapanhaz/yticker",
71
+ classifiers=[
72
+ "Programming Language :: Python :: 3",
73
+ "License :: OSI Approved :: MIT License",
74
+ "Operating System :: OS Independent",
75
+ ],
76
+ ext_modules=cythonized_extensions,
77
+ install_requires=install_requires,
78
+ zip_safe=False,
79
+ packages=find_packages()
80
+ )
@@ -0,0 +1 @@
1
+ from .yticker import YTicker