title: I have this code using the alpaca websocket but there is a function which is not defined
body: <pre><code>from time import sleep
  import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  import requests
  plt.style.use(&quot;fivethirtyeight&quot;)
  import alpaca_trade_api as tradeapi
  import threading
  from bs4 import BeautifulSoup
  import datetime
  import logging
  
  api_key = 'YOUR API KEY'
  api_secret = 'YOUR API SECRET KEY'
  base_url = 'https://paper-api.alpaca.markets'
  data_url = 'wss://data.alpaca.markets'
  ws_url = 'wss://data.alpaca.markets'
  
  # instantiate REST API
  api = tradeapi.REST(api_key, api_secret, base_url, api_version='v2')
  
  
  # init WebSocket
  conn = tradeapi.stream2.StreamConn(
      api_key,
      api_secret,
      base_url=base_url,
      data_url=data_url,
      data_stream='alpacadatav1',
  )
  </code></pre>
  <p>I get the error
  conn = tradeapi.stream2.StreamConn(
  AttributeError: module 'alpaca_trade_api' has no attribute 'stream2'</p>
  <p>This code is coming from <a href="https://algotrading101.com/learn/alpaca-trading-api-guide/" rel="nofollow noreferrer">https://algotrading101.com/learn/alpaca-trading-api-guide/</a> on the part where he shows how he made a trading algorithm near the end of the page.</p>
  <p>Do I need to import any extra libraries or am I wrong somewhere In the code.</p>