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
  • General Statistics

    • Total Topics
      22,085
    • Total Posts
      92,934
    • Total Members
      42,475
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    IPS Temp Admin
    Joined 06/10/22 15:40
  • Posts

    • Hi @AndaIG, Please could the [LOUP] Innovator Deepwater Frontier Tech ETF be listed and made available for the ISA tax wrapper, pretty please? Many thanks, Sam
    • Look ahead to 31/5/23: China PMI; France GDP; Germany CPI Economic data is key on Wednesday. It starts in Japan with retail sales, followed by Chinese PMI.  Jeremy Naylor | Analyst, London | Publication date: Tuesday 30 May 2023  IGTV’s Jeremy Naylor looks at the chances that the Chinese yuan will weaken further as it becomes more and more obvious that the recovery in China is further away than initially expected. Then in the eurozone we’re looking at the CAC 40 and DAX as growth and inflation data is released. The only corporate on the schedule is from stationers, WH Smith.          
    • Charting the Markets: 30 May FTSE 100 lower while DAX moves higher in early trading, and Dow looks to edge up following reports of debt ceiling deal. EUR/USD declining and USD/JPY holding firm, while GBP/USD begins to show signs of a higher low. Chris Beauchamp | Chief Market Analyst, London | Publication date: Tuesday 30 May 2023  Gold’s pullback slows down, while Brent crude turns lower and natural gas struggles to hold the 50-day MA.               This is here for you to catch up but if you have any ideas on markets or events you want us to relay to the TV team we’re more than happy to.
×
×
  • Create New...