What the Day Left Open
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- junior
Problem
A brokerage's position-keeping service replays the day's executed `trades` to reconstruct each account's holdings. Each trade names a `ticker`, a `side` of `buy` or `sell`, and a share count, where buys add to a position and sells subtract from it. Return the net shares held per ticker, dropping any ticker whose position was fully closed out by the close, and keeping the tickers that went net short.
Summary
Every fill moves a position. Reconstruct where the book settled by the close.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.