Home > Blockchain >  Java Finance scenario Coding Solution
Java Finance scenario Coding Solution

Time:07-16

Given a set of bonds for inventory with the following attributes:

price, asset class, credit rating, quantity
such as $60.46, Corporate, AA, 20
Asset class: corporate, sovereign, municipal
Credit Rating: AAA, AA, A, BBB, BB, B

Given dealId and its total price:

DealId, Price
such as: D1, $4000

Given dealId and its min Asset Class Requirement:

DealId, min Asset Requirement
such as D1, 20% Sovereign
D1, 60% Corporate
D2, 50% Municipal

Given dealId and its min Credit Rating Requirement:

DealId, min Credit Requirement
such as D1 80% AAA
D1 20% AA

Allocate the bonds from inventory to satisfy the deals as much as possible so that you can minimize the bonds you borrowed.

Can anyone please explain how can we go about the solution for the above problem

CodePudding user response:

This looks like a version of a multi-dimensional Knapsack problem, where you want to optimize allocation of assets to specific buckets/requirements.

You have a list of requirements (Asset Class Requirement & Ratings requirements) that you need to satisfy. They basically tell you if given bond can be allocated to a 'bucket' that you need to fill.

You can solve this problem in a non-optimal way with a greedy algorithm where you just allocate first asset that meets criteria. So you go through the requirements and look up the first bond that meets the criteria there. You continue till you run out of requirements or bonds to satisfy them. It's called heuristic. It will quickly produce solution, but most probably it won't be the best.

This will produce some solution. How good it is you can measure by having a cost-function. Cost function will be how much bonds you still need to obtain from the market to satisfy remaining requirements.

If you want better or possibly best solution this becomes a hard problem. There are linear-programming algorithms that can help. Google OR-tools is one of established libraries that runs this kind of optimizations.

You wouldn't believe how much banks and finance companies use 'dumb' algorithms and how much they lose by not employing smarter tactics.

  • Related