Write a java program for performing order matching

Assignment Help Basic Computer Science
Reference no: EM13307351

write a Java program for performing order matching according to the typical rules of a double auction system.

For simplicity we will assume that all orders are for a single unit of the traded item. The double action system operates as follows. When a new buy order of $x arrives it is simply stored for future use if none of the stored sell orders has an asking price lower than or equal to $x. Otherwise, the new buying bid is matched with the sell order with lowest asking price (earliest such order if there are ties). The two matched orders are removed from the system, and the buyer receives the item in exchange for paying a clearing price equal to the matched sell order asking price, i.e., the lowest asking price available at the time the new buy order was received.

 

Processing of a new sell order with an asking price of $y is done in a similar way. If all stored buying orders have a bid price strictly lower than $y, then no matches can be made and the new order is simply stored for possible future matching. Otherwise, the new sell order is matched with the stored buy order with highest bid price, handling ties as above. The two matched orders are again removed from the system, and the clearing price paid in this case is the bid price of the matched buy order, i.e., the highest bid price available at the time the new sell order was received.

have your program create the following example input and output

Sample Input 1

 
order 1 sell at 30
order 2 buy at 20


Output for Sample Input 1


units exchanged 0 total clearing price 0

Sample Input 2

order 1 sell at 30
order 2 buy at 20
order 3 buy at 40
order 4 buy at 30
order 5 sell at 10

Output for Sample Input 2

units exchanged 2 total clearing price 60

 

Reference no: EM13307351

Questions Cloud

What is the theoretical rate of moisture removal from grain : A model grain dryer is being used to investigate the drying process. It is discovered that the load cell which supports the dryer indicates that the mass of the dryer and its contentsinitially increases during the heat-up.
The food industry intentionally manipulates consumers : The food industry intentionally manipulates consumers by taking advantage of the fact that most consumers are ignorant of all of the ways that the food industry manufactures and processes its products.
Direct proof or by contraposition : Let f be a function f . Z → Z x Z such that f(n) = (2n, n + 3). Verify whether this function is 1-1 and whether it is onto and let f be a function f . R3 → R such that f(x, y, z) = xyz. Verify whether this function is 1-1 and whether it is onto.
Compute the density of the material : A solid piece of an unknown material wights 96.9 N in air and 59.6 N when submerged in water. The density of water is 1000 kg/m3, Determine the density of the material
Write a java program for performing order matching : write a Java program for performing order matching according to the typical rules of a double auction system.
How you would take any number of values of any type : How you would take any number of values of any type, and then remove the duplicates while at the same time storing the datat in the most efficient manner you can so that you can print out the data as an ordered list? Write a method to do this?
What are the risks associated with the loss of these data : Based on the Ledford (2012) article, what special issues must be considered for corporate data which are not fully digitized? What are the risks associated with the loss of these data? What recovery procedures do you recommend for these situations..
Contrast solutions to tyson situation-jbs-swift situation : Contrast the solutions to the Tyson situation and the JBS-SWIFT situation. Which is likely to have the greatest positive impact on the company and why?
Determine what is the maximum flowrate in the business : A business wishes to discharge salt into a river. the concentration of salt from the business is 210 mg/L. the flow of water in the river (upstream) is 0.5 m^3/s. Upstram the concentration of salt in the river 15 mg/L.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Show how an assembly might replace

show how an assembly might replace this pseudo-instruction with the true instructions to achieve the same effect. You solution must observe MIPS register use conventions.

  Deadlock prevention

In  deadlock prevention , we constrain resource requests to prevent at least one of the four conditions of deadlock (Mutual exclusion, Hold and wait, No preemption, Circular wait). This is either done indirectly, by preventing one of the three necess..

  Extended grep for regular expressions

That contain the word "as" exactly onceb) that contain the word "sa" more than once

  Program to keep track of the participants in a triathlon

Create a program to keep track of the participants in a triathlon. Your program will keep track of the times in three events: Running, Swimming, and Biking. Your program will calculate who is the winner in the Male category and the Female category..

  Writing viruses-worms and trojan horses

Course taught students how to write viruses, worms, and Trojan Horses. It also explained the history of computer viruses as well as how to block attacks.

  Write a java class to find occurence of a digit

Write a java class to Find occurence of a digit.

  Simulate the operation of a simple robot

Write a program to simulate the operation of a simple robot . the robot moves in four directions :forward, right,left. the job of the robot is to move items and place it in the right slots in each station

  Which search engine do you believe provided

Which search engine do you believe provided you the best results? Support your position by explaining why you believe the particular search engine to be better based upon your experience.

  Formulate the lp model for union city to minimize

Relevant information on the six potential locations of the warning siren towers and distance in miles to each of the seven schools is presented in the table below. Formulate the LP model for Union City to minimize towers built.

  Write english statement into a logical statement

Why is it important to change an English statement into a logical statement that follows the framework given by pseudo code and mathematical logic? Share examples and any further thoughts.

  Cloud computing to the rescue

Cloud computing provides scalable computing resources, software applications, data storage, and networking infrastructure at cost below what would cost an organization to provide an equivalent infrastructure internally.

  Write a simple computer program

Write a simple computer program that ask the user for coordinate value in certain form, and then reports the number in all three forms. This will be repeated for input coordinates of all three forms.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd