Find the minimal cost combination of available trades

Assignment Help Computer Engineering
Reference no: EM132155872

Use C++ to do it. Thanks

Given you start with a future expiration, find the minimal cost combination of available trades to turn your start position into your end position.

Definition of Future: An agreement to buy or sell an asset at a fixed price but to be delivered and paid for at some later date (the expiration date).

Definition of Roll: The process of closing out positions in soon-to-expire contracts in favor of contracts with later expiration dates.

Example 1

Given I start with a January Future Contract And my target is the February Future Contract And the (January,February) Contract costs -1 When I sell the (+Jan-Feb) Contract Then I sell a January Contract and buy a February Contract for a loss of 1 And I now own the Feb Future Contract for a loss of 1
Example 2

Given I start with a January Future Contract And my target is the March Future Contract And the (January,February) Contract costs -1 And the (January,March) Contract costs -4 And the (February,March) Contract costs -2 When I sell the (+Jan-Feb) Contract And I sell the (+Feb-Mar) Contract Then I sell a January Contract and buy a February Contract for a loss of 1 Then I sell a February Contract and buy a March Contract for a loss of 2 And I now own the Feb Future Contract for a loss of 3

In example 2, selling the Jan,Mar combination costs more (4) than the cost of selling both the Jan,Feb and Feb,Mar combinations.

Your goal is to find the optimal combination of assets to complete the roll as quick as possible for the best price. The optimal solution will output the roll combination with the minumum cost in the most efficient way possible. If two combinations of assets have the same minimum cost, choose the one with the least trades

Input:

The input gives you your starting and ending months for the roll and all future combinations and their costs. The future combinations contain two expiration months and a cost.

When you buy the future combination, you buy the first month and sell the second month and pay the cost.

When you sell the future combination, you sell the first month and buy the second month and earn the cost.

Input:
Start,End
Month,Month,Cost;Month,Month,Cost;...

For Example 2, the input would be...

Jan,Mar Jan,Feb,-1;Jan,Mar,-4;Feb,Mar,-2
Output:

The output should show the future combinations that result in the minimal cost between the start and end future months. You should output the future trades in the order you traded them to get to the roll month.

Output:
+(Month,Month)
-(Month,Month)
Total Minimum Cost

For Example 2, the output would be...

-(Jan,Feb) -(Feb,Mar) 3
Test 1

Test Input

Download Test Input

Jan,Apr Jan,Feb,-2;Jan,Mar,-2;Jan,Apr,-4;Feb,Mar,-2;Feb,Apr,-1;Mar,Apr,-3
Expected Output

Download Test Output

-(Jan,Mar) +(Feb,Mar) -(Feb,Apr) 1
Test 2

Test Input

Download Test Input

Jan,Mar Jan,Feb,-3;Jan,Mar,-7;Feb,Mar,-3
Expected Output

Download Test Output

-(Jan,Feb) -(Feb,Mar) 6
Test 3

Test Input

Download Test Input

Jan,Mar Jan,Feb,-3;Jan,Mar,-6;Feb,Mar,-3
Expected Output

Download Test Output

-(Jan,Mar) 6
Test 4

Test Input

Download Test Input

Jan,Feb Jan,Feb,-3
Expected Output

Download Test Output

-(Jan,Feb) 3

Reference no: EM132155872

Questions Cloud

Find the degrees of freedom for unequal variance test : Using a significance level of 0.10, test the hypothesis of no difference in the mean number of households picking either service.
Write a program to investigate a set of 15 random numbers : Declare variables. Seed the random number generator with the time of day. Initialize the variables for maximum, minimum, and count.
Compute the t obtained : Dr. Heather predicts that yoga will effect attention as reflected on the ACME Attention Test. The population mean on the ACME Attention Tests is 73.8.
New drug called curezall will be more effective : Dr. Dave is interested in determining if a new drug called Curezall will be more effective in the treatment of depression than SSRI's
Find the minimal cost combination of available trades : Given you start with a future expiration, find the minimal cost combination of available trades to turn your start position into your end position.
Sampling distribution of the sample mean : A random sample of size 122 was taken from a population with a population mean 29 and a population standard deviation 4.
Draw the abstract syntax tree and label the nodes : Derive the constraint set and the test set T_bor-mi for the following predicate pr: ab[c + !cd] where a, b, c, d are Boolean variables.
Receiving a failing grade : The professor awards the top 30% grade of A, the next 30% grade of B, and the next 30% grade of C. With the last 10% receiving a Failing grade
What is the probability of getting the disease : What is the probability of getting the disease when the father never had the disease?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Use the digram coder on files

Use the digram coder on files that are not similar to the ones you used to design the digram coder. How much does this affect your compression?

  Determine the outer surface temperature of the pipe

Hot water is being transported in a horizontal pipe (k = 0.15 W/m·K, Di = 2.5 cm, Do = 4.5 cm), where the pipe inner surface temperature is at 100°C.

  What is the value of the symmetric key

In the Diffie-liellman protocol. g = 7, p = 23, x = 3. and y = 5. What is the value of the symmetric key? What is the value of RI and K2?

  Illustrate interface that organizational users will utilize

Create three to five (3-5) screen layouts that illustrate the interface that organizational users will utilize.

  Explain the social engineering concerns in detail

Imagine a scenario where Jane, an administrative employee of a company, receives a call from James, the company's security administrator.

  Planning for a co-location to continue business as usual in

1 according to your textbook which of the following is not part of risk analysisdetermine how likely each risk is to

  List the time for the worm finishes infecting all computers

List the time for the worm finishes infecting all vulnerable computers in each run; so you need to provide 3 time values.

  Which algorithm makes the most efficient use of memory

Given memory partitions of 100 kb, 500 kb, 200 kb, 300 kb, and 600 kb (in order), how will each of the first-fit, best-fit, and worst-fit algorithms place processes of 212 kb, 417 kb, 112 kb, and 426 kb (in order)?Which algorithm makes the most ef..

  Determine the rate of heat loss from the pipe by radiation

A 10-m-long section of a 6-cm-diameter horizontal hot water pipe passes through a large room whose temperature is 27°C. If the temperature and the emissivity.

  How many bits are there in the network part

how many bits are there in the network part and in the subnet part, respectively

  Show the result of each of the operations in sequence

Show the result of each of the following operations in sequence (that is, (ii) assumes (i) has occurred).

  Write a function that outputs everything in the order

Write a function that outputs everything in the order along with the total price. Write a suitable test program that adds multiple pizzas to an order(s).

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