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
icon
Related questions
Question
100%
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: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.
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.
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education