title: How to stream trades for all spot trading pairs on binance using websockets in python
body: <p>I am trying to stream every single trade for all spot trading pairs on the Binance exchange in real time using web sockets. I have searched for a websocket endpoint to do so and have not found one.
  I have tried making a call to the &quot;<em><strong>exchange info</strong></em>&quot; endpoint and getting all trading pairs. Then from there I filtered out the ones that had a trading status of halted and the pairs that didn't allow spot trading. Then I passed these trading pairs which were made lower cased and abbreviated with the proper &quot;@trade&quot; to show I wanted trade info. When I sent this request to the server Binance didn't respond. I have left my code below for you to reproduce my problem:</p>
  <pre><code>import ssl
  import websocket
  import _thread as thread
  import re
  import ast
  import pandas as pd
  import requests
  import json
  
  def on_message(ws, message):
      print(message)
      message = json.loads(message)
      message = message.get('data')
      
      try:
          symbol = message.get(&quot;s&quot;)
          timestamp = message.get(&quot;T&quot;)
          price = message.get(&quot;p&quot;)
          quantity = message.get(&quot;q&quot;)
          is_buyer_maker = message.get(&quot;m&quot;)
  
          if is_buyer_maker:
              taker = &quot;sell&quot;
          else:
              taker = &quot;buy&quot;
  
          data = {&quot;symbol&quot;: symbol,
                  &quot;timestamp&quot;: timestamp,
                  &quot;price&quot;: price,
                  &quot;quantity&quot;: quantity,
                  &quot;taker&quot;: taker}
  
          print(data)
      except:
          pass
  
  
  def on_error(ws, error):
      print(error)
  
  def on_close(ws):
      print(&quot;### Binance Closed ###&quot;)
  
  def on_open(ws):
      def run(*args):
          print(logon_msg)
          ws.send(logon_msg)
      thread.start_new_thread(run, ())
  
  if __name__ == &quot;__main__&quot;:
      content = requests.get(&quot;https://api.binance.com/api/v3/exchangeInfo&quot;).json()
      content = content.get(&quot;symbols&quot;)
  
      symbols = []
      for thing in content:
          if thing.get(&quot;status&quot;) == &quot;TRADING&quot; and thing.get(&quot;isSpotTradingAllowed&quot;) == True:
              symbols.append(thing.get(&quot;symbol&quot;))
  
      symbols = [i.lower() + &quot;@trade&quot; for i in symbols]
  
      logon_msg = {&quot;method&quot;: &quot;SUBSCRIBE&quot;, &quot;params&quot;: symbols,&quot;id&quot;: 1}
      logon_msg = json.dumps(logon_msg)
  
      websocket.enableTrace(True)
      ws = websocket.WebSocketApp(&quot;wss://stream.binance.com:9443/stream?streams=trade&quot;,
                                  on_message=on_message,
                                  on_error=on_error,
                                  on_close=on_close,
                                  on_open=on_open)
      ws.on_open = on_open
      ws.run_forever(sslopt={&quot;cert_reqs&quot;: ssl.CERT_NONE})
  </code></pre>