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

  Leading consultants for a number of patients

Doctors are specialists in some branch of medicine and may be leading consultants for a number of patients, not necessarily from the same ward.

  Determine finish tag-packet-by-packet fair queueing system

Let the packet-by-packet fair queueing system with three logical buffers and with service rate of one unit/second. Determine finish tag, order of transmission and actual packet completion times for each packet arrival.

  Describe an algorithm for a turing machine

Describe an algorithm for a Turing machine which receives the integer n as input and proceeds to write the description of the n-th Turing machine from the standard enumeration on its tape.

  Use this information to find a tighter bound on p

If X is a non-negative random variable with E(X) = ?, then Markov's inequality tells us that for every a, P(X ? a) ? ?/a. As we saw in class, this bound is sometimes very loose. In this problem we'll look at a situation in which extra information ..

  In which case there are no pricing changes

Finally, your management-side software should write to a file the status of the reservations; that is, which house is rented to whom, when, and for what price.

  Compare iso-iec outline with nist documents

Compare the ISO/IEC 27001 outline with the NIST documents outlined in 'Management of Information Security' (by Michael E. Whitman, Herbert J. Mattord).

  Technology in home-workplace has negative impact on women

What technology in the home and workplace has a negative impact on women, if any; and (b) do women roles still remain largely associated with the home and domestic chores.

  Create implementation plan to analyze options

Boardman plans to hire Smith Systems Consulting to help them analyze their options and to create the implementation plan.

  Give an example each of following it relates saving account

If savings account is a class, give an example of each of the following as it relates to that savings account.

  Compare time complexity-convolution using direct convolution

Compare time complexity of convolution with n x n kernel when using: direct convolution with 2-D mask, and separable kernel.

  Find all companies located in every city

Assume the companies may be loacted in several cities. Find all companies located in every city in which small bank corporation is located. Write relational algebra query. Use  in database system concepts sixth edition for schema.

  Determining contents of memory of specified address

Find the contents of memory from address 0x1800 up to, but not including, 0x1809, after this code is executed.

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