CPT206 Computer Programming for Financial Mathematics: Coursework Resit Task Specification
Due date: Sunday, 31 July, 2022, 10pm
This is the specification task sheet for the Coursework resit assessment of your CPT206 module. The task covers all Learning Outcomes, and has a weighting of 100% towards the final grade for this module. This assignment has two parts: a coding part described in Section 1, and a report described in Section 2. The submission deadline for this assignment is Sunday, 31 July, 2022, at 10pm. Detailed submission instructions are provided in Section 3.
1 Program description (65 marks)
The aim of this coursework is to build a stock portfolio management system. All the work should be coded into a single Java NetBeans project, with the class structure and different functionalities of the program described as follows. All classes should be properly encapsulated, as seen in the Lectures and Labs throughout the semester. Your project should also contain a Controller class for testing.
1.1 StockOption class (10 marks)
The basic building block of the program will be a StockOption class. A StockOption object comprises of a “ticker” (e.g. "BABA") that identifies the option, the current price of the option, and its volatility coefficient (which should be a number between 0 and 1).
Stock option prices should update randomly, via an update() method, according to the following formula:
• Pnew is the new current price of the option (after update); • Pold is its old current price (before update);
• v is its volatility coefficient;
• r is a uniform random variable on [−1, 1].
For security purposes, StockOption objects should be immutable, so the update() method should return a new StockOption object with the updated price.
1.2 TradingBusiness class (25 marks)
A trading business is an organisation that trades (buys and sells) stock options. A TradingBusiness
object should have a name, and a stock portfolio, describing which stock options, and how many 1
shares in these options, the business currently holds. The portfolio should also store the business’s net spend on each stock option that it currently holds. The net spend on a given stock option o is calculated as follows.
· If the business holds no shares in the option o, the net spend is 0.
· If the business buys k shares in the option o, with a current price of p, increase the net spend
by k × p.
· If the business sells k shares in the option o, with a current price of p, decrease the net spend
by k × p.
You should choose a suitable data structure in the Java collection framework for this, keeping in
mind that the business can hold a particular stock option at most once, but can hold any (positive) number of shares in such a stock option. Leave a comment in your code explaining your choice of data structure for this.
A trading business’s main responsibility is to buy and sell stock shares.
· When buying shares, the business should specify which stock option they wish to invest in, and how many shares they wish to buy. If the business already holds some shares in that
particular stock option, this should modify the net spend, as outlined above.
· When selling shares, the business should have the option of either selling a given number of shares in a particular stock option, or selling all shares of that stock option. In the first case (selling a given number of shares), this should modify the net spend on that option, as outlined above. In the second case (selling all shares), this should remove that particular stock option from the business’s portfolio.
· A trading business should also be able to find out how much profit they would make if they sold all shares currently held in a given stock option at the current price. The profit is given by the amount of money that would be made by selling all the shares in that option, minus the current net spend on the option.
· There should also be an updateAll() method that updates the prices of all stock options held by the business, according to the price update formula in Section 1.1.
· Finally, a trading business should be able to obtain its current valuation, defined as the total money the business would make from selling all shares held in their stock option portfolio.
1.3 TradingCompany class (15 marks)
A trading company is a trading business with an added attribute measuring the company’s liquidity: the amount of money (in liquid, rather than stock option, form) currently held by the company. When a trading company is launched, it has an empty stock portfolio to begin with.
The TradingCompany class should have the same functionalities as the TradingBusiness class, with the following modifications.
· When selling shares, the money raised from that sale is added to the company’s liquidity.
· When buying shares, the money spent on that acquisition is removed from the company’s liquidity, and this operation can only be processed if there is sufficient remaining liquidity.
· The valuation of a trading company is the total money they would make from selling all their shares, plus their current liquidity.
The company can also liquidate (sell) all of its current stock option portfolio at any given time. 2
1.4 Code quality (15 marks)
The remaining marks (15) will be awarded for the quality of your code, as covered throughout the semester in the Lectures and Labs.
• Keep your code neat and tidy; make sure it is properly indented throughout.
• Choosesuitablenamesforvariablesandmethods,respectingstandardJavanamingconventions. • Comment your code as needed.
• Split your code into separate methods as appropriate; methods should not be too long.
2 Report (35 marks)
For this part of the assignment, you will write a report detailing how you designed, implemented, and tested the program described in Section 1. The report should be typed into e.g. a Word document, and submitted as a PDF (see Section 3 for more details).
2.1 System design and implementation (20 marks)
You should explain the design and implementation of your system in terms of its class structure, and how you incorporated some of the OOP concepts covered in the course materials. This part should be no more than 3 pages in length. You should consider the following questions.
How did you go about implementing some of the main functionalities of the program from Section 1? Here you should pay particular attention to explaining some of the more complicated features in your system (i.e. no need to detail a getter method).
Which OOP concepts are incorporated into your system design? where? (see original task sheet for more details)
Testing description (15 marks)
As covered throughout the Lectures and Labs in this module, testing is an essential part of writing computer programs. In your report, you will include a description of how you tested the various parts of the program described in Section 1. You will state clearly what functionalities you tested, and describe how you tested them, thinking carefully about possible corner cases. You may include some sample code if you wish. This section should be one-and-a-half to two pages in length (screenshots excluded).
3 Submission instructions
In the dedicated “Resit submission” Assignment activity on the Learning Mall Online, you will need to submit the following two (2) documents.
· A single ZIP archive of your entire NetBeans project. Include all the resources your project needs to run. This file will be named “CPT206 Resit Project studentId.zip”.
· Your report from Section 2, typed into e.g. a Word document, and converted into a PDF file. This file will be named “CPT206 Resit Report studentId.pdf”.
The submission deadline is: Sunday, 31 July, 2022, at 10pm. 3