Metadata-Version: 2.2
Name: yticker
Version: 0.1.4
Summary: A Python package for connecting to yahoo websocket.
Home-page: https://github.com/Tapanhaz/yticker
Author: Tapan Hazarika
Author-email: Tapan Hazarika <tapanhaz@gmail.com>
License: MIT License
Project-URL: Homepage, https://github.com/Tapanhaz/yticker
Project-URL: Repository, https://github.com/Tapanhaz/yticker
Project-URL: Issues, https://github.com/Tapanhaz/yticker/issues
Keywords: yahoo,websocket
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: picows
Requires-Dist: pyrobuf
Requires-Dist: orjson
Dynamic: author
Dynamic: home-page

# yticker
Cython based async python websocket client for yahoo based on picows  : https://github.com/tarasko/picows  


For installation run:

```
pip install yticker
```

#Example ::
===================
```python

import time
import asyncio
import logging
import platform
import warnings
from yticker import YTicker

warnings.filterwarnings("error")

logging.basicConfig(level= logging.DEBUG)

if platform.system() == "Windows":
    import winloop
    asyncio.set_event_loop_policy(winloop.EventLoopPolicy())
else:
    import uvloop
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

async def on_tick(msg):
    print(msg)

async def on_open(msg):
    print(f"{time.asctime()} : {msg}")

async def on_close(msg):
    print(f"{time.asctime()} : {msg}")

async def on_error(msg):
    print(f"{time.asctime()} : {msg}")

async def main(loop):    
    ticker = YTicker(loop)
    ticker.start_websocket(
                message_update_callback= on_tick, 
                open_callback= on_open,
                close_callback= on_close,
                error_callback= on_error
                )
    await ticker.IS_CONNECTED.wait()
    await ticker.subscribe(["BTC-USD", "EURUSD=X", "^NSEI", "RELIANCE.NS", "SBIN.BO"])
    #Sample unsubscribe
    await asyncio.sleep(10)
    await ticker.unsubscribe(["BTC_USD", "^NSEI"])
    #Close websocket
    await asyncio.sleep(10)
    ticker.close_websocket()

if __name__ == "__main__":
    try:
        loop = asyncio.get_event_loop()
    except DeprecationWarning:
        loop = asyncio.new_event_loop() 
    loop.create_task(main(loop))
    loop.run_forever()

```
