Position Tracking

Hello, Does anybody know of any libraries or scripts that could help with position tracking?  I have a table of executions and want to calculate in real time the open and closed p/l