Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Dynamic Running Total - Calculating Shares Outstanding

takumis
5 - Atom

Hi Alteryx Community,

 

I'm trying to calculate a running total of the shares outstanding after stock splits and stock conversions. I'm having difficulty coming up with a workflow that would accommodate any number of share classes, stock splits and stock conversions.

 

My assumption would be that I need to create running totals that essentially reset when a stock split or stock conversion occurs. However, I've hit a wall in trying to figure out how to build a workflow that does that while being flexible to incoming data. 

 

Table 1: Stock Activity

Date IssuedShare ClassAmount of Shares Issued
1/1/2001Common A5000
1/1/2002Common A5000
1/1/2003Preferred A1,000
1/1/2004Preferred B3,000

 

Table 2: Stock Split

DateShare ClassRatio (New Shares over Old shares)
6/30/2001Common A2
6/30/2003Preferred A2

 

Table 3: Stock Conversion

DateNew Share ClassOld Share ClassRatio (New Shares over Old Shares)
3/15/2004Common APreferred A1
3/15/2004Common APreferred B2

 

Desired Output:

 

DateRunning Total_Common ARunning Total_Preferred ARunning Total_Preferred B
1/1/20015,00000
6/30/200110,000 (5,000 x 2)00
1/1/200215,000 (10,000 + 5,000)00
1/1/200315,0001,0000
6/30/200315,0002,000 (1,000 x 2)0
1/1/200415,0002,0003,000
3/15/200423,000 (15,000 + 2,000 + 6,000)00

 

 

2 REPLIES 2
jdunkerley79
ACE Emeritus
ACE Emeritus

That's fiddly due to conversions.

 

I suggest something like:

 

- Put all inputs into one table with common headers (Date, Share Class, Issued, Ratio, Old Share Class). Mapping New Share Class to Old I think

- Next Sort by Date then Share Class

 

- You can then build an iterative macro with following logic:

1. Feed a starting point of 0 as of 1/1/1900 for each class

2. Select rows up to next conversion and use multi row to apply these

3. For first conversion apply conversion first to New and then to Old

4. Feed back end positions after 3 into next iteration.

 

I had a quick play but it will take some time to make work I think. Will try and put together later today.

 

jdunkerley79
ACE Emeritus
ACE Emeritus

Finally got something to work. Keeping it generic makes it quite complex.

 

2019-01-23_21-32-57.jpg

First, make an ordered list of all the events.

Then create a starting position like:

Share ClassIssuedRecordID
Common A0-1
Preferred A0-1
Preferred B0-1

 

This is the table which the iterative macro will keep updating.

 

The iterative macro is pretty fiddly as well, unfortunately:

2019-01-23_21-46-46.jpg

 

The first section picks the rows that haven't yet been processed by the iterative macro. It then chooses down until the first conversion.

Next, it processes the splits and issues using a multi-row formula

After this, it processes the first conversion by getting the current issued state of all stocks and converting as needed. 

If there is no conversion left the iteration will stop otherwise it feeds the final positions back in.

 

A fun and interesting problem - I hope this is enough to get you started.

Labels