Jump to content
  • 0

Alter subscriptions and unsubscribe - python streaming API


Panda_don

Question

Can't seem to find an answer to the two questions below:

I use the following code to subscribe to prices:

from lightstreamer_client import LightstreamerSubscription

    market_session = IgStreamingSession(api_key, account_id, rest_api_username, rest_api_password)
    market_subscription = LightstreamerSubscription('MERGE',
                                             markets_to_stream,
                                             ['OFR_OPEN','OFR_HIGH','OFR_LOW','OFR_CLOSE','BID_OPEN','BID_HIGH','BID_LOW','BID_CLOSE','UTM','CONS_END'])

    market_subscription.addlistener(lambda item: do_something_with(item))

    market_streaming_response = market_session.subscribe(market_subscription)
 

1) If I want to unsubscribe to this particular stream (specifically this one as I have other concurrent streams running that I want to continue) - how do I do that?

2) If I want to update the list: markets_to_stream, and receive stream results only for the new list - how can I do that?

 

I have seen this:

# Unsubscribing from Lightstreamer by using the subscription key
lightstreamer_client.unsubscribe(sub_key)

# Disconnecting
lightstreamer_client.disconnect()

 

but do not know how to apply it to my code as mine is slightly different?

Link to comment

1 answer to this question

Recommended Posts

  • 0
On 08/01/2022 at 08:32, Panda_don said:

Can't seem to find an answer to the two questions below:

I use the following code to subscribe to prices:

from lightstreamer_client import LightstreamerSubscription

    market_session = IgStreamingSession(api_key, account_id, rest_api_username, rest_api_password)
    market_subscription = LightstreamerSubscription('MERGE',
                                             markets_to_stream,
                                             ['OFR_OPEN','OFR_HIGH','OFR_LOW','OFR_CLOSE','BID_OPEN','BID_HIGH','BID_LOW','BID_CLOSE','UTM','CONS_END'])

    market_subscription.addlistener(lambda item: do_something_with(item))

    market_streaming_response = market_session.subscribe(market_subscription)
 

1) If I want to unsubscribe to this particular stream (specifically this one as I have other concurrent streams running that I want to continue) - how do I do that?

2) If I want to update the list: markets_to_stream, and receive stream results only for the new list - how can I do that?

 

I have seen this:

# Unsubscribing from Lightstreamer by using the subscription key
lightstreamer_client.unsubscribe(sub_key)

# Disconnecting
lightstreamer_client.disconnect()

 

but do not know how to apply it to my code as mine is slightly different?

Hi @Panda_don,

For further assistance on APIs you can contact webapisupport@ig.com.

All the best - Arvin

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • October can be a bit of a wild card for Solana. I’ve noticed it sometimes rallies if the broader crypto market is feeling optimistic, but there’s also been some volatility. Last year, for example, it had some nice gains, but I've also seen it drop unexpectedly due to market shifts. I think it’s smart to stay updated on the latest news and trends and keep an eye on market sentiment if you're thinking about investing.
    • If you’re eyeing Shiba Inu, I’d suggest doing a bit of homework first. I’ve dabbled in a few cryptos, and the market can be wild—prices can swing drastically in no time. I got into some projects based on hype before and learned the hard way about jumping in too quickly. If you really believe in Shiba Inu’s potential and have a solid plan, it might be worth a shot. 
    • Hey everyone, it’s a new week with bullish momentum. $TON is trading around $5.3 today, and with all the hype and momentum, do you think it could outperform Solana in the long run?   If there's potential, I’d suggest we consider accumulating gradually ahead of the bull run. One way to do this could be by exploring TON giveaways, such as the one currently on Bitget platform.   It’s part of a TON carnival offering multiple learning opportunities and a Learn-to-Earn activity, where you answer TON-related questions and receive freebies.   Overall, these opportunities within the TON ecosystem seem worth considering given the potential. What’s your take on it?
×
×
  • Create New...
us