import json
from decimal import Decimal as D


POINT_VALUE = D(50)
FEE_PER_FILL = D("2.25")


def accounting(label, points, fills):
    gross = D(points) * POINT_VALUE
    costs = fills * FEE_PER_FILL
    return [label, points, float(gross), float(costs), float(gross - costs)]


def run():
    old_entry, old_exit = 4298, 4300
    new_entry, new_exit = 4306, 4308
    stitched_points = new_exit - old_entry
    gap = new_entry - old_exit
    realized_points = (old_exit - old_entry) + (new_exit - new_entry)
    assert realized_points == stitched_points - gap
    rows = [accounting("A", stitched_points, 2),
            accounting("B", realized_points, 2),
            accounting("C", realized_points, 4)]
    assert rows[0][-1] == 495.5 and rows[2][-1] == 191
    assert rows[0][-1] - rows[2][-1] == 304.5
    return rows


if __name__ == "__main__":
    print(json.dumps(run()))
