"""Reconcile a stock split in a position ledger.

A split changes units and the per-share price basis; it does not itself create wealth. Cash distributions are separate.
All inputs are synthetic teaching examples. Run: python 43_split-position-accounting.py
"""
from tv_math import *

before_units=40
before_price=300
split_ratio=3
units=before_units*split_ratio
reference_price=before_price/split_ratio
assert units*reference_price==before_units*before_price==12000
# A later price of 102 is measured against the adjusted 100 basis.
profit=units*102-before_units*before_price
assert profit==240
print({"new_units":units,"adjusted_basis":reference_price,"later_profit":profit})
