docstr: Main function that does everything
docstr_tok: ["Main","function","that","does","everything"]
code: def find_anomalies(self):
      """
      Main function that does everything
      """
  
      # Gather data for all stocks
      if self.IS_LOAD_FROM_DICTIONARY == 0:
          (
              features,
              historical_price_info,
              future_prices,
              symbol_names,
          ) = self.dataEngine.collect_data_for_all_tickers()
      else:
          # Load data from dictionary
          (
              features,
              historical_price_info,
              future_prices,
              symbol_names,
          ) = self.dataEngine.load_data_from_dictionary()
  
      # Find anomalous stocks using the Isolation Forest model. Read more about the model at -> https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html
      detector = IsolationForest(n_estimators=100, random_state=0)
      detector.fit(features)
      predictions = detector.decision_function(features)
  
      # Print top predictions with some statistics
      predictions_with_output_data = [
          [
              predictions[i],
              symbol_names[i],
              historical_price_info[i],
              future_prices[i],
          ]
          for i in range(0, len(predictions))
      ]
      predictions_with_output_data = list(
          sorted(predictions_with_output_data)
      )
  
      # Results object for storing results in JSON format
      results = []
  
      for item in predictions_with_output_data[
          : self.TOP_PREDICTIONS_TO_PRINT
      ]:
          # Get some stats to print
          prediction, symbol, historical_price, future_price = item
  
          # Check if future data is present or not
          if self.IS_TEST == 1 and len(future_price) < 5:
              print(
                  "No future data is present. Please make sure that you ran the prior command with is_test enabled or disable that command now. Exiting now..."
              )
              exit()
  
          (
              latest_date,
              today_volume,
              average_vol_last_five_days,
              average_vol_last_twenty_days,
          ) = self.calculate_volume_changes(historical_price)
          (
              volatility_vol_last_five_days,
              volatility_vol_last_twenty_days,
              _,
          ) = self.calculate_recent_volatility(historical_price)
          if (
              average_vol_last_five_days == None
              or volatility_vol_last_five_days == None
          ):
              continue
  
          if self.IS_TEST == 0:
              # Not testing so just add/print the predictions
  
              if self.OUTPUT_FORMAT == "CLI":
                  print(
                      "Last Bar Time: %s\nSymbol: %s\nAnomaly Score: %.3f\nToday Volume: %s\nAverage Volume 5d: %s\nAverage Volume 20d: %s\nVolatility 5bars: %.3f\nVolatility 20bars: %.3f\n----------------------"
                      % (
                          latest_date,
                          symbol,
                          prediction,
                          today_volume,
                          average_vol_last_five_days,
                          average_vol_last_twenty_days,
                          volatility_vol_last_five_days,
                          volatility_vol_last_twenty_days,
                      )
                  )
              results.append(
                  {
                      "latest_date": latest_date,
                      "Symbol": symbol,
                      "Anomaly Score": prediction,
                      "Today Volume": today_volume,
                      "Average Volume 5d": average_vol_last_five_days,
                      "Average Volume 20d": average_vol_last_twenty_days,
                      "Volatility 5bars": volatility_vol_last_five_days,
                      "Volatility 20bars": volatility_vol_last_twenty_days,
                  }
              )
  
          else:
              # Testing so show what happened in the future
              (
                  future_abs_sum_percentage_change,
                  _,
              ) = self.calculate_future_performance(future_price)
  
              if self.OUTPUT_FORMAT == "CLI":
                  print(
                      "Last Bar Time: %s\nSymbol: %s\nAnomaly Score: %.3f\nToday Volume: %s\nAverage Volume 5d: %s\nAverage Volume 20d: %s\nVolatility 5bars: %.3f\nVolatility 20bars: %.3f\nFuture Absolute Sum Price Changes: %.2f\n----------------------"
                      % (
                          latest_date,
                          symbol,
                          prediction,
                          today_volume,
                          average_vol_last_five_days,
                          average_vol_last_twenty_days,
                          volatility_vol_last_five_days,
                          volatility_vol_last_twenty_days,
                          future_abs_sum_percentage_change,
                      )
                  )
              results.append(
                  {
                      "latest_date": latest_date,
                      "Symbol": symbol,
                      "Anomaly Score": prediction,
                      "Today Volume": today_volume,
                      "Average Volume 5d": average_vol_last_five_days,
                      "Average Volume 20d": average_vol_last_twenty_days,
                      "Volatility 5bars": volatility_vol_last_five_days,
                      "Volatility 20bars": volatility_vol_last_twenty_days,
                      "Future Absolute Sum Price Changes": future_abs_sum_percentage_change,
                  }
              )
  
      if self.OUTPUT_FORMAT == "JSON":
          self.store_results(results)
  
      if self.IS_TEST == 1:
          self.calculate_future_stats(predictions_with_output_data)
  
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, path
  import pandas
  import yfinance
  import datetime
  from scipy.stats import linregress
  from datetime import datetime, timedelta
  import matplotlib.pyplot
  from sklearn.ensemble import IsolationForest
  from data_loader import DataEngine
  import warnings
  import argparse
label_desc: Use image node_id 9 for calling the Surpriver obj's underlying member method code with example usage: obj.find_anomalies() without return types