docstr: Get stock data.
docstr_tok: ["Get","stock","data","."]
code: def get_data(self, symbol):
      """
      Get stock data.
      """
  
      # Find period
      if self.DATA_GRANULARITY_MINUTES == 1:
          period = "7d"
      else:
          period = "30d"
  
      try:
          # get crytpo price from Binance
          if self.DATA_SOURCE == "binance":
              # Binance clients doesn't like 60m as an interval
              if self.DATA_GRANULARITY_MINUTES == 60:
                  interval = "1h"
              else:
                  interval = str(self.DATA_GRANULARITY_MINUTES) + "m"
              stock_prices = self.binance_client.get_klines(
                  symbol=symbol, interval=interval
              )
              # ensure that stock prices contains some data, otherwise the pandas operations below could fail
              if len(stock_prices) == 0:
                  return [], [], True
              # convert list to pandas dataframe
              stock_prices = pd.DataFrame(
                  stock_prices,
                  columns=[
                      "Datetime",
                      "Open",
                      "High",
                      "Low",
                      "Close",
                      "Volume",
                      "close_time",
                      "quote_av",
                      "trades",
                      "tb_base_av",
                      "tb_quote_av",
                      "ignore",
                  ],
              )
              stock_prices["Datetime"] = stock_prices[
                  "Datetime"
              ].astype(float)
              stock_prices["Open"] = stock_prices["Open"].astype(float)
              stock_prices["High"] = stock_prices["High"].astype(float)
              stock_prices["Low"] = stock_prices["Low"].astype(float)
              stock_prices["Close"] = stock_prices["Close"].astype(
                  float
              )
              stock_prices["Volume"] = stock_prices["Volume"].astype(
                  float
              )
          # get stock prices from yahoo finance
          else:
              stock_prices = yf.download(
                  tickers=symbol,
                  period=period,
                  interval=str(self.DATA_GRANULARITY_MINUTES) + "m",
                  auto_adjust=False,
                  progress=False,
              )
          stock_prices = stock_prices.reset_index()
          stock_prices = stock_prices[
              ["Datetime", "Open", "High", "Low", "Close", "Volume"]
          ]
          data_length = len(stock_prices.values.tolist())
          self.stock_data_length.append(data_length)
  
          # After getting some data, ignore partial data based on number of data samples
          if len(self.stock_data_length) > 5:
              most_frequent_key = self.get_most_frequent_key(
                  self.stock_data_length
              )
              if data_length != most_frequent_key:
                  return [], [], True
  
          if self.IS_TEST == 1:
              stock_prices_list = stock_prices.values.tolist()
              stock_prices_list = stock_prices_list[
                  1:
              ]  # For some reason, yfinance gives some 0 values in the first index
              future_prices_list = stock_prices_list[
                  -(self.FUTURE_FOR_TESTING + 1) :
              ]
              historical_prices = stock_prices_list[
                  : -self.FUTURE_FOR_TESTING
              ]
              historical_prices = pd.DataFrame(historical_prices)
              historical_prices.columns = [
                  "Datetime",
                  "Open",
                  "High",
                  "Low",
                  "Close",
                  "Volume",
              ]
          else:
              # No testing
              stock_prices_list = stock_prices.values.tolist()
              stock_prices_list = stock_prices_list[1:]
              historical_prices = pd.DataFrame(stock_prices_list)
              historical_prices.columns = [
                  "Datetime",
                  "Open",
                  "High",
                  "Low",
                  "Close",
                  "Volume",
              ]
              future_prices_list = []
  
          if len(stock_prices.values.tolist()) == 0:
              return [], [], True
      except:
          return [], [], True
  
      return historical_prices, future_prices_list, False
  
imports: import os
  import ta
  import sys
  import json
  import math
  import pickle
  import random
  import requests
  import collections
  import numpy
  from os import walk
  import pandas
  import yfinance
  import datetime
  from tqdm import tqdm
  from scipy.stats import linregress
  from datetime import datetime, timedelta
  from feature_generator import TAEngine
  import warnings
  from binance.client import Client
label_desc: Use image node_id 4 for calling the DataEngine obj's underlying member method code with example usage: obj.get_data(symbol) and returns: historical_prices,  future_prices_list,  False, list,  list,  True, list,  list,  True, list,  list,  True, list,  list,  True