How to make multiple socket connection ?

Ankur_3004
How we can make multiple socket connections using a single python client? Please share the approach.
  • MAG
    MAG edited April 15
    You will need to run three threads using the threading or multiprocessing modules.
    However using a single python client to make multiple connections to websocket is a bad idea. This approach just increases the code complexity and the chances of things going wrong.

    There is no harm in running three separate instances of the same marketdata script with each one subscribing to a separate list of instruments which can be specified as a command line parameter.
    python3 ./getmarketdata.py list1 # subscribes to one instrument list.
    python3 ./getmarketdata.py list2 # subscribes to second instrument list.
    python3 ./getmarketdata.py list3 # subscribes to third instrument list.
    Multithreading introduces unnnecessary code complexity which will make maintenance and debugging all the more difficult.
  • Ankur_3004
    Thank you very much for the quick reply. Will go ahead with this approach.
  • vaibhavsharma13
    @MAG How many instruments can be subscribed in each?
  • MAG
    @vaibhavsharma13 please read the FAQ section. It's mentioned there.

This discussion has been closed.