Assignment 8 Solution

Assume that you are a software developer in an investment bank on Wall Street, New York. Your boss asks you to design a trading strategy and test it. You will design a set of classes that work together to simulate buying and selling a stock. The classes you will design are the following:


·         The Stock Class: this class will represent a stock. You need to decide the member variables of this class based on the input file. This input file is given to you and it is a

“comma-separated-value” file (.csv). You can open a .csv file using Microsoft Excel.


·         The AlgorithmTrader Class: this class will simulate the stock trading activities. Its responsibilities are as follows:


o Read stock minute-by-minute data from an input file, MSFT.csv. o Store stock minute-by-minute data in an Array List.


o  Decide when to buy and sell a stock using the simple algorithm.


§    Entry position strategy: if a stock’s share price increases 5 times consecutively, then you buy 10,000 shares based on the current price.


§   Exit position strategy: if your current position is gaining 0.12% profit or losing 0.12%, then you sell all the shares you are holding base on the current price.


§   Special Exit strategy: if you are still holding a stock at the last minute of a trading day, you MUST sell all of the shares you own. Because the risk of losing money is too big during the after hour trading period.

o   Simulate buying and selling stocks


o   To write a summary of Transactions, Profit/Loss for each minute. Please see the tradingSummary-sample.csv file on Blackboard.


o   Note, the AlgorithmTrader class MUST use an array of objects of the Stock class.


·         Demonstrate the classes by creating instances of each class. Create the main class Simulate one day of trading stocks. This main method should ask user to enter an input file name, create an object of the AlgorithmTrader class, open an output file, and call the methods of the AlgorithmTrader object.


Note: your program must be user-friendly and intuitive. This is a part of your grade. In other words, even if your program does everything the problem statement states, your grade may be reduced because of difficulty to it.




The name of the input file which stores a stock’s minute-by-minute data. Please download the MSFT.csv file from Blackboard. This input is from the user’s keyboard. If the file doesn’t exist, please print an appropriate message and terminate the program.




Your program should create an output file and store it on your computer disk. Your output file must be a .csv file. Please name the file tradingSummary.csv. A sample output file, tradingSummary-sample.csv, can be downloaded from BB.


Sample Output:




















Use of Methods, Parameters, Modularity, Design, etc.


Part of your grade on this and ALL future programming projects in this course will be determined by how well you use multiple functions and parameter passing appropriately and how well you design a modular and functionally cohesive program using the principles discussed in class. Large grade point penalties can be incurred for not setting up a modular, well designed program structure. This emphasizes good program structure, design, and fundamental software engineering principles.




Be sure to read and understand the sections in the Course Syllabus handout on general project requirements. Also be sure to study the style, documentation and formatting guidelines discussed in the Programming Style Guidelines handout and in the lecture.


What File To Turn In and How to Turn In Your Work using Blackboard


You must turn in your Java program source file in a zip file. The zip file must include a file which defines the Stock class, a file that defines the AlgorithmTrader class, and a file which includes the main() method. The zip file’s name must follow this format: hw8_SimpleAlgortihmTrader.zi
Powered by