Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation error on lightreamer.Subscription #321

Open
alhennessey92 opened this issue Jan 14, 2024 · 2 comments
Open

Deprecation error on lightreamer.Subscription #321

alhennessey92 opened this issue Jan 14, 2024 · 2 comments

Comments

@alhennessey92
Copy link

Getting a deprecation warning on my code that was previously working fine.

Error:
/app/app.py:2127: DeprecationWarning: trading_ig.lightstreamer.Subscription is deprecated, and will be removed in a future version; use the official Lightstreamer Python client instead [server] subscription_prices = Subscription( [server] Traceback (most recent call last): [server] File "/app/app.py", line 2134, in <module> [server] sub_key_prices = ig_stream_service.ls_client.subscribe(subscription_prices) [server] File "/usr/local/lib/python3.9/site-packages/lightstreamer/client/ls_python_client_wrapper.py", line 1138, in subscribe [server] self.delegate.subscribe(subscription.delegate) [server] AttributeError: 'Subscription' object has no attribute 'delegate'

Code around them lines:

`main_stream = "CHART:CS.D.GBPUSD.TODAY.IP:{}".format(stream_scale_time)
    subscription_prices = Subscription(
        mode="MERGE",
        items=[main_stream],
        fields=["LTV", "UTM", "OFR_OPEN", "OFR_HIGH", "OFR_LOW", "OFR_CLOSE", "BID_OPEN", "BID_HIGH", "BID_LOW", "BID_CLOSE", "CONS_END", "CONS_TICK_COUNT"]
    )

    subscription_prices.addlistener(on_prices_update)
    sub_key_prices = ig_stream_service.ls_client.subscribe(subscription_prices)`

I have tried removing the line sub_key_prices = ig_stream_service.ls_client.subscribe(subscription_prices)
However still getting the below error.

Error:
/app/app.py:2127: DeprecationWarning: trading_ig.lightstreamer.Subscription is deprecated, and will be removed in a future version; use the official Lightstreamer Python client instead [server] subscription_prices = Subscription(

Everything was working fine before i restarted my Docker Desktop and it had to rebuild the container, so not sure if this is because the library has been updated.

Thanks for any help

@galburn
Copy link

galburn commented Jan 15, 2024

I had this, or very similar, when I updated trading-ig from 0.0.20 to 0.0.21. I took the opportunity to rework the code rather than resolve or work around the issue - version 0.0.21 added lightstreamer auto-reconnects which is a very useful thing to me.

To help with diagnosis, you could try installing the specific version 0.0.20 and see is that get's things working again:-
pip install --force-reinstall -v "trading-ig==0.0.20"

If and when you upgrade trading-ig to 0.0.21 (or higher), please remember to stick to version 1.0.3 of the lightstreamer library (compatible with Lightstreamer Server 7.3.3), as version 2.0.0 requires Lightstreamer Server 7.4.0 (not yet deployed by IG).

@9gix
Copy link
Contributor

9gix commented Jan 23, 2024

subscription.delegate is only available in the the official Lighstreamer library. (lightstreamer.client.Subscription, and not trading_ig.lightstreamer.Subscription`)

So, you could try changing your Subscription import from/to the following

#from trading_ig.lightstreamer import Subscription
from lightstreamer.client import Subscription

because of this changes, the subscription.addlistener also need to be change to subscription.addListener with the listener parameter instead of a simple callable function, you now need to create a SubscriptionListener object with onItemUpdate method instead. (see the lightstreamer-client-lib and sample/stream_ig.py)

PS: the change from trading_ig.lightstreamer to official lightstreamer happen at trading-ig>=0.0.21 onwards. So if your code isn't ready for this migration, you should keep it at trading-ig==0.0.20, it should work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants