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.

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

IN PYTHON PLEASE.

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
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
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

ANSWER IN PYTHON PLEASE.

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
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
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
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
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Predicate
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
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