export function checkTapeAlignment(row, tolerance = 0.20) {
  const direction = row.direction; // 'BULL' or 'BEAR'
  const session = row.session_bucket;

  let priceMove = 0;
  
  if (session === 'PRE' && row.pct_vs_prior_close != null) {
    priceMove = row.pct_vs_prior_close;
  } else if (session === 'RTH' && row.pct_vs_rth_open != null) {
    priceMove = row.pct_vs_rth_open;
  } else if (session === 'POST' && row.pct_vs_prior_close != null) {
    priceMove = row.pct_vs_prior_close;
  }

  // Bull flow needs price up >= tolerance
  if (direction === 'BULL' && priceMove >= tolerance) return 1;
  
  // Bear flow needs price down <= -tolerance
  if (direction === 'BEAR' && priceMove <= -tolerance) return 1;

  return 0;
}

export function getTapeAlignmentArrow(aligned, direction) {
  if (!aligned) return '';
  return direction === 'BULL' ? '↗︎' : '↘︎';
}
