Company: jpmc_31july
Difficulty: medium
Stock Trading Profit Problem Description A quantitative trading firm aims to develop a tool to track the net profit/loss of the firm at any point in time. This tool processes a list of events, and each event falls into one of four categories: BUY stock quantity : Indicates the purchase of <quantity> shares of <stock> at the market price. SELL stock quantity : Indicates the sale of <quantity> shares of <stock> at the market price. CHANGE stock price : Indicates a change in the market price of <stock> by <price> amount, which can be positive or negative. QUERY : Requests the net profit/loss from the start of trading until the current time. The tool should return a list of numbers corresponding to each QUERY event. Examples Example 1: Input: events = ["BUY googl 20", "BUY aapl 50", "CHANGE googl 6", "QUERY", "SELL aapl 10", "CHANGE aapl -2", "QUERY"] Output: [120, 40] Explanation: Initially, the profit is 0. BUY googl 20 : 20 shares of 'googl' are purch