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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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