class_docstr: (S)elect the (B)etter one among every two adjacent trading (B)ars to sell or buy with (EMA) signal.
class_docstr_tok: ["(","S",")","elect","the","(","B",")","etter","one","among","every","two","adjacent","trading","(","B",")","ars","to","sell","or","buy","with","(","EMA",")","signal","."]
code: def _pred_price_trend(
      self, stock_id, pred_start_time=None, pred_end_time=None
  ):
      # if no signal, return mid trend
      if stock_id not in self.signal:
          return self.TREND_MID
      else:
          _sample_signal = resam_ts_data(
              self.signal[stock_id],
              pred_start_time,
              pred_end_time,
              method=ts_data_last,
          )
          # if EMA signal == 0 or None, return mid trend
          if (
              _sample_signal is None
              or np.isnan(_sample_signal)
              or _sample_signal == 0
          ):
              return self.TREND_MID
          # if EMA signal > 0, return long trend
          elif _sample_signal > 0:
              return self.TREND_LONG
          # if EMA signal < 0, return short trend
          else:
              return self.TREND_SHORT
  
imports: from pathlib import Path
  import warnings
  import numpy
  import pandas
  from typing import IO, List, Tuple, Union
  from qlib.data.dataset.utils import convert_index_format
  from qlib.utils import lazy_sort_index
  from ...utils.resam import resam_ts_data, ts_data_last
  from ...data.data import D
  from ...strategy.base import BaseStrategy
  from ...backtest.decision import BaseTradeDecision, Order, TradeDecisionWO, TradeRange
  from ...backtest.exchange import Exchange, OrderHelper
  from ...backtest.utils import CommonInfrastructure, LevelInfrastructure
  from qlib.utils.file import get_io_object
  from qlib.backtest.utils import get_start_end_idx
label_desc: Use image node_id 4 for calling the SBBStrategyEMA obj's underlying member method code with example usage: obj._pred_price_trend(stock_id, pred_start_time, pred_end_time) and returns: self, self, self, self