1

I cannot find any info on how to do this online

Let's say I have a spreadsheet of daily percentage changes as shown below, which D3:D11
daily percentage changes

How would I track how the compounded capital grows and falls on a daily basis assuming some starting capital?

So day one would be $1.009.

Day two would be (1.00946)(1.009)~$1.01854514.

Day three would be (1.00829)(1.00946)(1.009)~$1.027.

I then want to plot this as a time series but if it can't be plotted, I still hope to populate these values as a separate column. So E3 would be 1.009, E4 would be 1.01854514, E5 would be 1.027, and so on.

0

1 Answer 1

0

SCAN function

SCAN(initial_value, array_or_range, LAMBDA) 

The SCAN function scans an array and produces intermediate values by application of a LAMBDA function to each value. Returns an array of the intermediate values obtained at each step.

Formula

=LET(cap,TOCOL(B2:B,1), yst,QUERY(cap, "LIMIT "&ROWS(cap)-1,0), td,QUERY(cap, "OFFSET 1",0), SCAN(1, INDEX(td/yst), LAMBDA(a,v, a*v))) 

Explanation

  1. cap stores the Capital column after removing any blank rows.
  2. yst stores yesterday's capital. Basically offset minus one row from today's value.
  3. td stores today's capital. Basically offset plus one row from yesterday's.
  4. SCAN has its accumulator a starting at 1, and each individual value v is created by dividing that day's capital by yesterday's. The array of those values is created by dividing al the values at once td/yst.
  5. Scan passes the current value of a and the next v into a LAMBDA which multiplies them together, returns the result but also stores the new result in a for the next iteration.

    For example:
    # Example Formula =SCAN(1, {1.01, 1.02, 1.03}, LAMBDA(a, v, a*v)) # Iterations Pass 1. a=1, v=1.01, a*v=1.01 Pass 2. a=1.01, v=1.02, a*v=1.0302 Pass 3. a=1.0302, v=1.03, a*v=1.061106 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.