Your task is to implement a class that provides methods ProcessTrade, Process PriceUpdate, OutputWorst rade. These method calls correspond to the instructions described above with the method arguments corresponding to the update or query attributes. Constraints • 1 ≤ N, Tradeld, Price, Volume ≤ 106 It is guaranteed that price update for an instrument is available before first trade on that instrument. . Input Format For Custom Testing Input to the program is specified using a simple text format. The format and details of parsing are not relevant to answering the question but custom input can be used to help with development and debugging. The first line of input contains an integer N that denotes the number of instructions. Each of the N subsequent lines contains either an update or a query in the format below: Updates: . TRADE PRICE Query: • WORST TRADE Some example inputs and their expected outputs are described
Your task is to implement a class that provides methods ProcessTrade, Process PriceUpdate, OutputWorst rade. These method calls correspond to the instructions described above with the method arguments corresponding to the update or query attributes. Constraints • 1 ≤ N, Tradeld, Price, Volume ≤ 106 It is guaranteed that price update for an instrument is available before first trade on that instrument. . Input Format For Custom Testing Input to the program is specified using a simple text format. The format and details of parsing are not relevant to answering the question but custom input can be used to help with development and debugging. The first line of input contains an integer N that denotes the number of instructions. Each of the N subsequent lines contains either an update or a query in the format below: Updates: . TRADE PRICE Query: • WORST TRADE Some example inputs and their expected outputs are described
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%

Transcribed Image Text:Your task is to implement a class that provides
methods ProcessTrade, Process PriceUpdate, OutputWorst
rade. These method calls correspond to the instructions
described above with the method arguments corresponding to
the update or query attributes.
Constraints
• 1 ≤ N, Tradeld, Price, Volume ≤ 105
• It is guaranteed that price update for an instrument is available
before first trade on that instrument.
Input Format For Custom Testing
Input to the program is specified using a simple text format. The
format and details of parsing are not relevant to answering the
question but custom input can be used to help with development
and debugging.
The first line of input contains an integer N that denotes the
number of instructions. Each of the N subsequent lines contains
either an update or a query in the format below:
Updates:
4 TRADE <TradelD> <InstrumentID> <BUY/SELL> <Price> <Volume>
. PRICE <InstrumentID> <Price>
Query:
. WORST TRADE <InstrumentID>
Some example inputs and their expected outputs are described
below.

Transcribed Image Text:Sample Case 1
Sample input for custom testing:
6
PRICE Facebook 80
PRICE Apple 120
TRADE 100 Apple SELL 90 2
TRADE 19 Facebook BUY 100 4
WORST TRADE Facebook
WORST TRADE Apple
Expected output:
10
100
Explanation:
There are 2 instruments (Apple and Facebook), each of which
has 1 trade. There are 2 queries, 1 for each instrument.
1. PNL from tradelD 100: (90-120) * 2 = -60
• Apple price at the time of the trade is 120 and we sell at 90,
so we make a total loss of 60. We trade 2 lots, so the loss-per-
lot is 30:
2. PNL from tradelD. 10: (100 - 80) * 4 = 80
o Facebook price at the time of the trade is 80 and we buy at
100, so we make a total loss of 80. We trade 4 lots, so in total
we make a loss-per-lot of 20.
For both Facebook and Apple, we do exactly one bad trade
which is hence also the worst trade for each instrument.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education