Dynamic rollup object for Arquero

I think the reason this is difficult is that the data columns are not tidy. If you fold the data into a long format first, the cross-product correlation is relatively straightforward in arquero: the only weird bit is a custom join function to avoid duplicating keys on the left and right.

  const long = aq
      .from(data)
      .fold(aq.not("Date"), {"as": ["company", "price"]})
  return long
    .join(long, (a, b) => op.equal(a.Date, b.Date) && a.company < b.company)
    .groupby("company_1", "company_2")
    .rollup(
      {correlation: op.corr("price_1", "price_2")})
    .orderby(aq.desc("correlation"))
    .view()