Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solvso For your problem, assuming you have got n requests (mix of buy and sell) in a single stock arriving one after the other. For

image text in transcribedsolvso

For your problem, assuming you have got n requests (mix of buy and sell) in a single stock arriving one after the other. For simplicity assume that the exchange has asked all the traders to provide only trading quantity and it has already discovered the price! So, each request in your problem comes with a trader's id and trading quanity. Buyers are identified as b1,b2, 63, ..., and sellers are identified as 81, 82, 83,..., (see Figure below). Your goal is to pair buyers with sellers based on their arrival priority. A trader b arrives before the trader b2 and by before b3 and so on. A seller is unsatisfied if his entire share are not sold yet. Similarly, a buyer is unsatisfied if she has not got the desired quantity she has quoted. You as an exchange should try to satisfy a trader as early as possible. Write a python program which reads these requests from a file and outputs matched transactions. Your goal, as stated above, is to satisfy an unsatisfied trader based on their priority. Your program will stop if it can't santify any more trader (i.e., either no buyer is avalable or no seller is available or both). You can test correctness of your code on the examples below (next page). Here are some test examples, bi 20 b2 10 161 | 81 | 20 b2 S15 b2 S25 S125 S2 15 b3 8210 b3 15 Input Output Figure 1: Test b110 b2 15 by $110 S125 1 b281 15 S2 30 b3 S2 30 b3 30 b4 30 Input Output Figure 2: Test

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions