th a huge purchase is bound to drive up the price of the stock st in the short term. The trader sets aside the broker request for a n e Tesla stock for their own portfolio. Then the broker's order is exec en immediately sell the Tesla shares and collect a profit. The trader d on information that was not public knowledge.
th a huge purchase is bound to drive up the price of the stock st in the short term. The trader sets aside the broker request for a n e Tesla stock for their own portfolio. Then the broker's order is exec en immediately sell the Tesla shares and collect a profit. The trader d on information that was not public knowledge.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
WHAT TO START OUT WITH. THIS IS A CODING PROBLEM IN PYTHON3.
class Solution:
"""
RAW_TRADE_HEADER = ["trade_id", "trade_date", "time_of_trade", "portfolio", "exchange", "product", "product_type", "expiry_dt", "qty", "strike_price", "side"]
"""
def process_raw_trade(self, raw_trade: List):
def run(self) -> List[Tuple[str, str]]:
![1. Front-Running Detector
Front-running is defined as trading a stock or another financial asset by a broker who has
inside knowledge of a future transaction that is about to affect its price substantially. It is
illegal and unethical.
Here's an example of front-running: Say a trader gets an order from a broker to buy 50,000
shares of Tesla. Such a huge purchase is bound to drive up the price of the stock
immediately, at least in the short term. The trader sets aside the broker request for a minute
and first buys some Tesla stock for their own portfolio. Then the broker's order is executed.
The trader could then immediately sell the Tesla shares and collect a profit. The trader has
made a profit based on information that was not public knowledge.
Your task is to create a Front-Running Detector that will process option trade data from
different exchanges and determine if front-running has occurred. Your solution should be
able to handle data from multiple exchanges, with the expectation that additional
exchanges will need to be supported in the future. Your implementation should follow good
OOP design practices. Given a trade feed, output a list of all (broker_trade_id,
electronic_trade_id) pairs. Trade pairs should be ordered by the electronic trade time.
A trade pair is considered front-running if all of the following conditions are met:
a. One trade is of type "Broker" and the second trade is of type "Electronic".
b. The Electronic trade occurs 1 minute or less before the Broker trade.
c. Both trades are for the same product.
d. Both trades are of the same type (Call/Put).
e. Both trades have the same side (Buy/Sell).
f. Both trades have the same expiry date.
g. Both trades have the same strike price.
6 days ago](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6d1ae07f-bdb5-47a8-9afa-ea5a04bdf9c8%2F4c6a4914-e0aa-486b-b4ac-9ea1d1a34fcf%2Fbd00y2f_processed.jpeg&w=3840&q=75)
Transcribed Image Text:1. Front-Running Detector
Front-running is defined as trading a stock or another financial asset by a broker who has
inside knowledge of a future transaction that is about to affect its price substantially. It is
illegal and unethical.
Here's an example of front-running: Say a trader gets an order from a broker to buy 50,000
shares of Tesla. Such a huge purchase is bound to drive up the price of the stock
immediately, at least in the short term. The trader sets aside the broker request for a minute
and first buys some Tesla stock for their own portfolio. Then the broker's order is executed.
The trader could then immediately sell the Tesla shares and collect a profit. The trader has
made a profit based on information that was not public knowledge.
Your task is to create a Front-Running Detector that will process option trade data from
different exchanges and determine if front-running has occurred. Your solution should be
able to handle data from multiple exchanges, with the expectation that additional
exchanges will need to be supported in the future. Your implementation should follow good
OOP design practices. Given a trade feed, output a list of all (broker_trade_id,
electronic_trade_id) pairs. Trade pairs should be ordered by the electronic trade time.
A trade pair is considered front-running if all of the following conditions are met:
a. One trade is of type "Broker" and the second trade is of type "Electronic".
b. The Electronic trade occurs 1 minute or less before the Broker trade.
c. Both trades are for the same product.
d. Both trades are of the same type (Call/Put).
e. Both trades have the same side (Buy/Sell).
f. Both trades have the same expiry date.
g. Both trades have the same strike price.
6 days ago
![Note: The incoming trades from CBOE do not have a side field, instead the quantity
represents the side. A positive qty represents a buy and negative represents a sell.
Example:
Trade1: (date= '2022-03-15', time-9:01:00, type=Broker, qty=-500, strike-1500, expiry=¹2022-
04-28', kind=P, exchange-CBOE, trade-id=737acm, product-ABC)
Trade2: (date='2022-03-15', time-9:00:24, type=Electronic, qty=-200, strike-1500,
expiry='2022-04-28', kind-P, exchange=CBOE, trade-id=w6c229, product=ABC)
Trade3: (date = '2022-03-15', time-9:03:45, type=Electronic, qty=-100, strike-1500,
expiry='2022-04-28', kind-P, exchange=CBOE, trade-id=tssrin, product-ABC) [Fails condition
(b)]
Trade4: (date='2022-03-15', time-9:00:53, type=Electronic, qty=-500, strike-1500,
expiry='2022-04-28', Kind-P, exchange-CBOE, trade-id = Ik451a, product=XYZ) [Fails
condition (c)]
Trade5: (date='2022-03-15', time-9:00:05, type=Electronic, qty=-350, strike-1500,
expiry='2022-04-28', Kind=C, exchange-CBOE, trade-id=9numpr, product-ABC) [Fails
condition (d)]
Trade6: (date = '2022-03-15', time-9:00:35, type=Electronic, qty=200, strike-1500,
expiry='2022-04-28', Kind-P, exchange=CBOE, trade-id=922v3g, product-ABC) [Fails
condition (e)]
Trade7: (date = '2022-03-15', time-9:00:47, type=Electronic, qty=-150, strike-1500,
expiry=¹2022-04-21', Kind-P, exchange=CBOE, trade-id=bg54nm, product=ABC) [Fails
condition (f)]
Trade8: (date = '2022-03-15', time-9:02:23, type=Electronic, qty=-200, strike-1550,
expiry='2022-04-28', Kind-P, exchange=CBOE, trade-id=6y7fhm, product=ABC) [Fails
condition (g)]
Output:
[('737acm', 'w6c229')]
6 days ago](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6d1ae07f-bdb5-47a8-9afa-ea5a04bdf9c8%2F4c6a4914-e0aa-486b-b4ac-9ea1d1a34fcf%2Fr8ph3b_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Note: The incoming trades from CBOE do not have a side field, instead the quantity
represents the side. A positive qty represents a buy and negative represents a sell.
Example:
Trade1: (date= '2022-03-15', time-9:01:00, type=Broker, qty=-500, strike-1500, expiry=¹2022-
04-28', kind=P, exchange-CBOE, trade-id=737acm, product-ABC)
Trade2: (date='2022-03-15', time-9:00:24, type=Electronic, qty=-200, strike-1500,
expiry='2022-04-28', kind-P, exchange=CBOE, trade-id=w6c229, product=ABC)
Trade3: (date = '2022-03-15', time-9:03:45, type=Electronic, qty=-100, strike-1500,
expiry='2022-04-28', kind-P, exchange=CBOE, trade-id=tssrin, product-ABC) [Fails condition
(b)]
Trade4: (date='2022-03-15', time-9:00:53, type=Electronic, qty=-500, strike-1500,
expiry='2022-04-28', Kind-P, exchange-CBOE, trade-id = Ik451a, product=XYZ) [Fails
condition (c)]
Trade5: (date='2022-03-15', time-9:00:05, type=Electronic, qty=-350, strike-1500,
expiry='2022-04-28', Kind=C, exchange-CBOE, trade-id=9numpr, product-ABC) [Fails
condition (d)]
Trade6: (date = '2022-03-15', time-9:00:35, type=Electronic, qty=200, strike-1500,
expiry='2022-04-28', Kind-P, exchange=CBOE, trade-id=922v3g, product-ABC) [Fails
condition (e)]
Trade7: (date = '2022-03-15', time-9:00:47, type=Electronic, qty=-150, strike-1500,
expiry=¹2022-04-21', Kind-P, exchange=CBOE, trade-id=bg54nm, product=ABC) [Fails
condition (f)]
Trade8: (date = '2022-03-15', time-9:02:23, type=Electronic, qty=-200, strike-1550,
expiry='2022-04-28', Kind-P, exchange=CBOE, trade-id=6y7fhm, product=ABC) [Fails
condition (g)]
Output:
[('737acm', 'w6c229')]
6 days ago
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
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 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY