← Back
function analyzeOiConcentration(optionsData, cfg = {}) {
  const { underlying = null, limit = 20 } = cfg;

  const filtered = underlying
    ? optionsData.filter(o => o.symbol.startsWith(underlying + '-'))
    : optionsData;

  const strikes = {};
  for (const o of filtered) {
    const parts = o.symbol.split('-');
    const strike = parseFloat(parts[2] || o.strikePrice);
    if (!strike) continue;
    const oi = parseFloat(o.openInterest || o.oi || 0);
    const isCall = o.side === 'CALL' || o.symbol.includes('-C');
    if (!strikes[strike]) strikes[strike] = { strike, callOi: 0, putOi: 0, totalOi: 0 };
    if (isCall) strikes[strike].callOi += oi;
    else strikes[strike].putOi += oi;
    strikes[strike].totalOi += oi;
  }

  return Object.values(strikes)
    .sort((a, b) => b.totalOi - a.totalOi)
    .slice(0, limit);
}

module.exports = { analyzeOiConcentration };

📜 Git History

163bb5dfeat: migrate to options-screener-v2 folder to isolate deployment4 months ago
Show last diff
Loading...