Hello everyone,

I wanted to announce that a change is pending to Lean that will affect the results of most algorithms, especially those that focus on equity volumes. After this PR is merged, volume will now be adjusted just like prices for splits and other price factors. This can be changed by setting your `DataNormalizationMode` for your securities but by default all data passed through Lean is adjusted. This is a more accurate approach to handling splits and adjustments, as its normalizes the volume to reflect the exchange of the security more realistically.

Here is an example of the adjustment in affect. TSLA had a 5:1 Split occur (1 Share => 5 Shares) on 8/31/20

Lean in its current state (Un-adjusted)

8/24/2020 12:00:00 AM TSLA vol. 19M, Close: 402.84, Price factor: 0.2
8/25/2020 12:00:00 AM TSLA vol. 10M, Close: 404.67, Price factor: 0.2
8/26/2020 12:00:00 AM TSLA vol. 14M, Close: 430.63, Price factor: 0.2
8/27/2020 12:00:00 AM TSLA vol. 23M, Close: 447.75, Price factor: 0.2
8/28/2020 12:00:00 AM TSLA vol. 19M, Close: 442.68, Price factor: 0.2
8/31/2020 12:00:00 AM TSLA vol. 111M, Close: 498.32, Price factor: 1
9/1/2020 12:00:00 AM TSLA vol. 81M, Close: 475.05, Price factor: 1
9/2/2020 12:00:00 AM TSLA vol. 92M, Close: 447.37, Price factor: 1

97853_1621275763.jpg

 

Lean after this PR (Adjusted)

8/24/2020 12:00:00 AM TSLA vol. 96M, Close: 402.84, Price factor: 0.2
8/25/2020 12:00:00 AM TSLA vol. 50M, Close: 404.67, Price factor: 0.2
8/26/2020 12:00:00 AM TSLA vol. 68M, Close: 430.63, Price factor: 0.2
8/27/2020 12:00:00 AM TSLA vol. 114M, Close: 447.75, Price factor: 0.2
8/28/2020 12:00:00 AM TSLA vol. 96M, Close: 442.68, Price factor: 0.2
8/31/2020 12:00:00 AM TSLA vol. 111M, Close: 498.32, Price factor: 1
9/1/2020 12:00:00 AM TSLA vol. 81M, Close: 475.05, Price factor: 1
9/2/2020 12:00:00 AM TSLA vol. 92M, Close: 447.37, Price factor: 1

97853_1621275783.jpg

 

As you can see with the adjustment the volume is much more consistent and more accurately reflects the exchange of the equity because if the cost of a share was cut by ~1/5th with each share becoming 5 the volume should be adjusted by x5. This is important because if we have the volume and close price we should be able to calculate a relatively accurate dollar volume for the day. But if we don't adjust the volume this doesn't work at all.

Pre-split (8/28/20) TSLA's price was $2,213.40, and given the volume of 19M shares exchanged the dollar volume is ~$42B, but if we use the adjusted close price $442.68 and the unadjusted volume 19M, our dollar volume is only ~$8B dollars, which is substantially different and not an accurate representation of exchange that day. But with our adjusted volume 96M, our dollar volume is back at ~$42B creating a balanced adjustment.

 

Thank you,

Colton