How to subscribe and unsubscribe symbols in Fyers API Websocket(API v2)

I have 2 trades open and for those 2 trade symbol I have created a websocket. I am running the websocket in background mode.

Lets say 1 of my trade hits a stop loss and I need to close that trade and open 1 new trade.

How to unsubscribe the old symbol and subscribe the new symbol to the websocket? How do I call the subscribe and unsubscribe function from anywhere in the program?

def subscribe_websocket(symbol):

    #TODO: Call this functon whenever new trade is placed

   [ w](http://self.ws)s.subscribe(symbol=symbol, data_type="symbolData")

   [ w](http://self.ws)s.keep_running()

def unsubscribe_websocket(symbol):

    #TODO: Call this function whenever exit trade is called

   [ w](http://self.ws)s.unsubscribe(symbol=symbol)

Can anyone please help understanding this process and how do I proceed for the above problem?

I am getting below errors:

Hi @siddhantmohanty007-ciy

Please migrate to v3 and for this information Please read the docs>
This thing is already mentioned there.

Is this functionality not available in fyers v2?

Can anyone please help for the above problem?

No @siddhantmohanty007-ciy
It is not there, that’s why APIV3 is there.

NO use of migrating to v3. Not exactly this but similar problems will be faced in future. Not able to trust fyers api products since so many errors are there and the only solution is to move to upper version. Then there will be a problem in v3, fyers will tell to migrate to v4 and so on..

Anyways thanks for your comment.