Forum Discussion

AlphaEra's avatar
AlphaEra
Copper Contributor
Dec 18, 2024
Solved

I don't understand this logic with StockHistory function...

I don't understand this.... I will show my question step by step: 1. =STOCKHISTORY(E4,TODAY()-10,TODAY(),,0,1)  Gives me an array.                         2. I use ROWS and INDEX t...
  • Lorenzo's avatar
    Dec 20, 2024

    There's no logic with STOCKHISTORY. The function pulls information, that's it. The logic you describe is yours

    Assuming you want to pull the last 10 days history for each stock/symbol in E4# and keep/display only the last day, one option:

    in F4:

    =LET(
      end_date,   TODAY(),
      start_date, end_date -10,
      BYROW( E4#, LAMBDA(symbol,
        TAKE( STOCKHISTORY( symbol, start_date, end_date,, 0, 1 ), -1 )
        )
      )
    )

     

Resources