code: def _handle_data(context, data):
      # Get price, open, high, low, close
      prices = data.history(
          context.asset,
          bar_count=context.BARS,
          fields=["price", "open", "high", "low", "close"],
          frequency="1d",
      )
  
      # Create a analysis data frame
      analysis = pd.DataFrame(index=prices.index)
  
      # SMA FAST
      analysis["sma_f"] = ta.SMA(
          prices.close.as_matrix(), context.SMA_FAST
      )
      # SMA SLOW
      analysis["sma_s"] = ta.SMA(
          prices.close.as_matrix(), context.SMA_SLOW
      )
  
      # Relative Strength Index
      analysis["rsi"] = ta.RSI(
          prices.close.as_matrix(), context.RSI_PERIOD
      )
      # RSI SMA
      analysis["sma_r"] = ta.SMA(
          analysis.rsi.as_matrix(), context.RSI_AVG_PERIOD
      )
  
      # MACD, MACD Signal, MACD Histogram
      (
          analysis["macd"],
          analysis["macdSignal"],
          analysis["macdHist"],
      ) = ta.MACD(
          prices.close.as_matrix(),
          fastperiod=context.MACD_FAST,
          slowperiod=context.MACD_SLOW,
          signalperiod=context.MACD_SIGNAL,
      )
  
      # Stochastics %K %D
      # %K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100
      # %D = 3-day SMA of %K
      analysis["stoch_k"], analysis["stoch_d"] = ta.STOCH(
          prices.high.as_matrix(),
          prices.low.as_matrix(),
          prices.close.as_matrix(),
          slowk_period=context.STOCH_K,
          slowd_period=context.STOCH_D,
      )
  
      # SMA FAST over SLOW Crossover
      analysis["sma_test"] = np.where(
          analysis.sma_f > analysis.sma_s, 1, 0
      )
  
      # MACD over Signal Crossover
      analysis["macd_test"] = np.where(
          (analysis.macd > analysis.macdSignal), 1, 0
      )
  
      # Stochastics OVER BOUGHT & Decreasing
      analysis["stoch_over_bought"] = np.where(
          (analysis.stoch_k > context.STOCH_OVER_BOUGHT)
          & (analysis.stoch_k > analysis.stoch_k.shift(1)),
          1,
          0,
      )
  
      # Stochastics OVER SOLD & Increasing
      analysis["stoch_over_sold"] = np.where(
          (analysis.stoch_k < context.STOCH_OVER_SOLD)
          & (analysis.stoch_k > analysis.stoch_k.shift(1)),
          1,
          0,
      )
  
      # RSI OVER BOUGHT & Decreasing
      analysis["rsi_over_bought"] = np.where(
          (analysis.rsi > context.RSI_OVER_BOUGHT)
          & (analysis.rsi < analysis.rsi.shift(1)),
          1,
          0,
      )
  
      # RSI OVER SOLD & Increasing
      analysis["rsi_over_sold"] = np.where(
          (analysis.rsi < context.RSI_OVER_SOLD)
          & (analysis.rsi > analysis.rsi.shift(1)),
          1,
          0,
      )
  
      # Save the prices and analysis to send to analyze
      context.prices = prices
      context.analysis = analysis
      context.price = data.current(context.asset, "price")
  
      makeOrders(context, analysis)
  
      # Log the values of this bar
      logAnalysis(analysis)
  
imports: import os
  import matplotlib.pyplot
  import numpy
  import pandas
  import talib
  from logbook import Logger
  from matplotlib.dates import date2num
  from mpl_finance import candlestick_ohlc
  from catalyst import run_algorithm
  from catalyst.api import order, order_target_percent, symbol
  from catalyst.exchange.utils.stats_utils import get_pretty_stats
label_desc: Use image node_id 2 for calling a global function with example usage: _handle_data(context, data) without return types