code: def handle_data(context, data):
      context.i += 1
      lookback_days = 7  # 7 days
  
      # current date & time in each iteration formatted into a string
      now = data.current_dt
      date, time = now.strftime("%Y-%m-%d %H:%M:%S").split(" ")
      lookback_date = now - timedelta(days=lookback_days)
      # keep only the date as a string, discard the time
      lookback_date = lookback_date.strftime("%Y-%m-%d %H:%M:%S").split(
          " "
      )[0]
  
      one_day_in_minutes = (
          1440  # 60 * 24 assumes data_frequency='minute'
      )
      # update universe everyday at midnight
      if not context.i % one_day_in_minutes:
          context.universe = universe(context, lookback_date, date)
  
      # get data every 30 minutes
      minutes = 30
  
      # get lookback_days of history data: that is 'lookback' number of bins
      lookback = int(one_day_in_minutes / minutes * lookback_days)
      if not context.i % minutes and context.universe:
          # we iterate for every pair in the current universe
          for coin in context.coins:
              pair = str(coin.symbol)
  
              # Get 30 minute interval OHLCV data. This is the standard data
              # required for candlestick or indicators/signals. Return Pandas
              # DataFrames. 30T means 30-minute re-sampling of one minute data.
              # Adjust it to your desired time interval as needed.
              opened = fill(
                  data.history(
                      coin, "open", bar_count=lookback, frequency="30T"
                  )
              ).values
              high = fill(
                  data.history(
                      coin, "high", bar_count=lookback, frequency="30T"
                  )
              ).values
              low = fill(
                  data.history(
                      coin, "low", bar_count=lookback, frequency="30T"
                  )
              ).values
              close = fill(
                  data.history(
                      coin, "price", bar_count=lookback, frequency="30T"
                  )
              ).values
              volume = fill(
                  data.history(
                      coin,
                      "volume",
                      bar_count=lookback,
                      frequency="30T",
                  )
              ).values
  
              # close[-1] is the last value in the set, which is the equivalent
              # to current price (as in the most recent value)
              # displays the minute price for each pair every 30 minutes
              print(
                  "{now}: {pair} -\tO:{o},\tH:{h},\tL:{c},\tC{c},"
                  "\tV:{v}".format(
                      now=now,
                      pair=pair,
                      o=opened[-1],
                      h=high[-1],
                      l=low[-1],
                      c=close[-1],
                      v=volume[-1],
                  )
              )
  
file_path: catalyst/catalyst/examples/simple_universe.py
imports: from datetime import timedelta
  import numpy
  import pandas
  from catalyst import run_algorithm
  from catalyst.api import symbols
  from catalyst.exchange.utils.exchange_utils import get_exchange_symbols
label_desc: Use image node_id 2 for calling a global function with example usage: handle_data(context, data) without return types