Assignment 2 Stock Market
DUE DATE AND TIME:: Friday Week 7 (SSeptember 22)),, 7::000PM sharp..
No late submissions will be accepted..
Your work should be pushed to GitLab and your repository should be shared with your tutor and with Steven with Reporter permission..
Start working on the assignment as soon as possible.. The completion may require several sessions of work..
Note:: The webpage of Assignment 2 always contains the most recent version of the assignment.. We advise you to open//rrefresh this page eve ry time you recommence working on the assignment.. In case of changes and corrections in the assignment,, we will make an announcement in piazza.. Check piazza regularly..
Academic Integrity
Do not plagiarise..
Do not show your code to anyone..
Do not view anybo dy elses code..
Do not share your code..
Do not copy anybody elses code..
Do not read anybody elses report..
Do not show your report to anybody..
All parts of code and report for the assignment should be written by you alone.. It is not team work!!
You are req uired to complete an Assignment Cover Sheet and submit it as the first page of your report with your code via GitLab before the due date.. Otherwise,, your assignment will not be assessed and will attract a zero mark..
Introduction
This time the comp1100 team imagined itself a
stock market broker
. You are a
stock trader
.
Your aim is to come up with and implement a trading strategy of buying and selling stocks over a period of time in order to increase your wealth..
Each of you will initially have $5500000 . Once you submit your code,, we will run it on our benchmarks of several years of historic data for several stocks,, and you will be able to see where you stand with respect to your class mates in terms of your wealth at the end of the period.. You will not have access to our testing data..
Technical Tips
Once you have Haskell and doctest installed on your computer,, this assignment should require no external libraries that need to be manually installed..
IntelliJ New Project
1.. Open IntelliJ
2.. Top left corner > File > New > Project
3.. Select Haskell on the left,, and click Next
4.. Select BBuild with cabal,, and click Next
5.. Deselect initialise cabal package (TTh is step is crucial..))
6.. Give your project a name (ee..gg.. comp1100 ass02))
Git Fork the repository
1.. Go to
Assignment 2 GitLab Repository
(hhttps::////ggitlab..ccecs..aanu..eedu..aau//ccomp1100//aass02..ggit))
2.. Click on FFork,, and select your user..
3.. Give your tutor and Steven X.. Han Reporter access to your new repository..
4.. Go to IntelliJ terminal..
5.. Initialise the folder as a git repository (MMake sure you are in the project you created earlier.. Likely in ~//IIdeaProjects//cco mp1100 ass02))
6.. Add your assignment 2 repository as the origin
7.. Add comp1100 assignment 2 repository as the upstream
8.. Pull the origin remote to your local computer
Running the Program
To run the program,, execute the following command in the Terminal,, if you ar e working in Linux or Mac
.//ccompile_everything &&& .//TTrading Data//
or the following command,, if you are working in Windows::
compile_everything_on_Windows &&& Trading..eexe Data//
After the simulation is completed,, you will see the final state of your portfolio (yyour cash,, stocks and their quantity)) and the total wealth of your portfolio::
–
Cash:: $11.25
Stocks::
AAAD 2540985
Wealth:: $44904102.3
–
Modules
The program is split into six modules
Main..hhs
the main module where reading files and other input//ooutput (IIO)) actions are performed.. We will study IO after the break.. For now you are not required to un derstand functions in Main..hhs , but feel free to explore them.. Do not change anything in the module..
Types..hhs
the module with the type aliases specific for trading domain and a defined datatype Order for buy or sell instructions.. Do not change anything in the module..
Portfolio..hhs
the module containing functions related to your portfolio.. Do not change anything in the module..
Simulate..hhs
the module for
backtestin g
your trading strategy.. We have already implemented the function simulate for you.. Do not change anything in the module..
Market..hhs
the module containing fixed in terest rates and the function for executing orders (ii..ee.. buy or sell instructions)) in the stock market,, among other functions.. Observe function calculateWealth there.. Do not change anything in the module..
Order..hhs
the module where you should implement your trading strategy in the function called makeOrders . This is the only module you are allowed to modify..
Do not add anything or change anything in modules Main..hhs , Types..hhs , Portfolio..hhs , Simulate..hhs and Market..hhs . You can only modify module Order..hhs . Feel free to add any auxiliary functions you might need to Order..hhs . However,, the type signature and the name of makeOr ders should not be changed..
Once we receive your code,, we may replace modules Main..hhs , Types..hhs , Portfolio..hhs , Simulate..hhs and Market..hhs f or the web simulation.. Therefore,, it is essential you do not change data structures and type signatures..
Datatypes and Data Structures
Cash stands for cash..
Price is the price of a (pparticular)) stock..
Quantity is the quantity of a (pparticular)) stock..
Stock is the the ticker symbol of a stock,, for example AGL , ORG or TLS .
A portfolio stores information about how much cash and stocks you have.. Its datatype is as follows
type Portfolio = ( Cash , Holdings )
where Holdings is a list of (SStock,, Quantity)) pairs::
type Holding = ( Stock , Quantity )
type Holdings = [ Holding ]
StockHistory is the historical price data of a stock::
type StockHistory = ( Stock , [ Price ]))
Order is the type for an order to bbuy or ssell a stock::
data Order = Order Stock Quantity deriving ( Show )
Description
Folder Data// contains historical data of 40 stocks that you can use for testing your program.. Each file contains data about the prices of a stock over a period of time.. In Main..hhs , we implemented the infrastructure that reads all files from a given folder into the list of type [SStockHistory]] of stock histories,, where each element of the list contains
adjusted closing prices
of a particular stock over a period of time.. Thus,, each element of this list contains data extracted from a single file..
Once the data is loaded,, the system si mulates your trading strategy on this data by calling function runSimulation from the main function::
putStrLn $ showPortfolio (rrunSimulation limitedRange)) limitedRange
Function runSimulation is defined in Simulate..hhs . It calls function simulate with your initial portfolio consisting of $5500000 and zero stocks and represented as a tuple (5500000,, []])) .
Function simulate takes a portfolio (ii..ee.. your portfolio)) and a list of stocks (wwith the history of their prices)),, executes your orders generated by your makeO rders and returns a new portfolio resulting from the execution of these orders..
Your task is to implement function makeOrders in Order..hhs with the goal of increasing your capital..
The type signature of makeOrders is as follows
makeOrders ::: Portfolio > [ StockHistory ] > [ Order ]
It takes your current portfolio and the available stock history (lloaded from all files in Data// ) and returns bbuy and ssell orders in the current day.. In other words,, your makeOrders should analyse all stock histories,, and decide which stocks need to be bought or sold and in which quantities (iin the current moment)).. Thus,, each Order is defined as follows
data Order = Order Stock Quantity
A positive quantity corresponds to buying a stock,, whereas a negative quantity corresponds to selling a stock.. The current price of a stock is always the head of the list of prices corresponding to this stock..
We put a restriction on the cash value of your bbuy order:: it cannot be larger than your current wealth..
Each order costs you 0.11%% of its absolute value.. Therefore,, you should be considerate about how many orders you make..
We will annually pay you an interest of 3%% on your cash savings..
If the cash value in your portfolio becomes negative,, this means you have borrowed funds from us and thus
leveraged
your investment.. Note that our annual rate is 5.5%% of the total value of your loan..
If your total wealth becomes negative,, this means that you cannot repay your debts and are essentially bankrupt.. Nevertheless,, we will keep you in the simulation to compare the degree of your bankruptcy with respect to your class mates in a similar situation.. We recommend you to test and revise your trading strategy to avoid bankruptcy!!
Your tot al wealth is calculated in function calculateWealth in
Market..hhs
.
Short selling
, i..ee.. selling a stock with an intention of buying it in the future with a lower price,, is possible.. This means that you are allowed to have a negative quantity of a stock.. There is a restriction on how much capital you can get through short selling:: it cannot be larger than you r current wealth.. Furthermore,, the commission on short selling is 0.75%% of its value..
Our data structures do not support strategic decisions based on the purchase prices or the profit margins of your stocks..
Proper Implementation of
makeOrders
(440 marks))
Implementation of makeOrders is essential for receiving a passing mark for this assignment,, and thus it is a hurdle . If you do not implement makeOrders , you will not be able to receive a mark higher than 49 for the assignment..
We have implemented a trivial strategy in makeOrders for you as an example.. Provide your own implementation of a non trivial strategy.. Test your implementation thoroughly (ddoctest,, quickCheck)) including all your auxiliary functions..
Do not implement trivial trading strategies such as::
submitting no orders
not considering stock prices at all
Do not adjust your strategy specifically for the data we have provided (tthis is called
overfitting
the data)).. We will evaluate your strategy on a different dataset..
Your strategy should make a genuine attempt to determine which stocks are going to perform better in the future..
makeOrders containing trivial or overfitted strategies will be perceived as non implemented..
In your report you must a rgue why your strategy is non trivial.. If you are in doubt,, contact us privately in piazza..
Testing (55 marks))
You should check the correctness of auxiliary functions locally using doctest and//oor quickCheck . These tests should be written by you personally a nd tested locally.. Pipeline testing does not count as local testing and will not contribute towards your assignment mark..
Description of Functions (335 marks))
In the report describe your understanding of the following functions::
calculateWealth
getStockPrice
executeOrders
simulate
What do these functions do?? How are they implemented?? Which techniques are used in their implementation?? Can they be implemented differently?? What would be an alternative way??
Non informative and superficial answers as calculateWealth is a function that calculates the wealth are not acceptable and will receive mark zero..
Note that you should provide your analysis of these functions in the report . We will not analyse your comments in the modules where these functions are located,, because we may update these modules for the purpose of web simulation..
You must describe these functions yourself!! Never show your analysis of the functions to anyone.. Never look on somebody elses description..
Report (220 marks))
Report is an essential part of the assignment,, and as such,, it is a hurdle for this assignment..
Style
The report should be in PDF format,, located at the root of your assignment repository and named Report..ppdf . Otherwise,, it may not be marked..
The report should have a t itle page with the following items
your name
your university id
collaborators,, if any
You can discuss conceptual ideas of the assignment (bbut not code)) with others.. Mention them as collaborators in your title page..
All other requirements to the style and t he content of the report from
Assignment 1
apply.. Please read them!!
Marks
This assignment is non redeemable and worth 15%% of your total marks.. It is marked out of 100 with im plementation of makeOrders as a hurdle and also with the report as a hurdle . The marks distribution is as follows::
makeOrders 40 marks
local testing 5 marks
description//aanalysis of functions 35 marks
report 20 marks
If you do not have an implementation of makeOrders or it is not proper,, your maximum mark for the assignment will be capped at 49..
If you do not have a report,, your maximum mark for the assignment will be capped at 49..
The following provides a rough guide of your marks based on your progress in the assignment.. However,, the actual decision of your mark may deviate from the description below..
Fail
Under any of the conditions listed below,, your assignment will be automatically marked as failure..
There is no report submitted..
The co de does not compile..
None of the required functions is described..
makeOrders is not implemented properly..
This is an incomplete list.. Other reasons for failure are possible..
Pass
The code compiles and the simulation of your trading strategy works.. Code submitted is of basic quality.. The discussions in the report are mediocre and demonstrate basic understanding of the problem and solution.. One of the functions calculateWealth and getStockPrice is explained..
Functions executeOrders and simulate are either n ot explained or their explanation is mediocre..
Credit
The code compiles.. Implementation of makeOrders is of good quality.. The discussion in the report is sufficient but not comprehensive,, and demonstrates good understanding of the problem and solution.. Fun ctions calculateWealth and getStockPrice are explained and analysed in detail.. Functions executeOrders and simulate are either not explained or their explanation is mediocre.. Auxiliary//hhelper functions are tested (ddoctest,, quickCheck)) when applicable..
Distinction
The code should compile (wwith Wall flag)) without any warnings.. Auxiliary//hhelper functions are comprehensively tested when applicable.. There are some good doctest//qquickCheck examples in your code that are discussed in the report.. Code submitted is of great quality with explanatory comments in the source file.. The report is of great quality,, and includes sufficient details to convey in detail and depth your understanding of the assignment.. Functions calculateWealth , getStockPrice and executeOrder s are explained and analysed in detail..
High Distinction
The code should compile (wwith Wall flag)) without any warnings.. Code (ii..ee.. implementation of makeOrders ) submitted is of excellent quality with appropriate comments in the source file ( Order..hhs ).. Aux iliary//hhelper functions are comprehensively tested (ddoctest,, quickCheck)) when applicable.. Test cases are well designed (ee..gg.. essential edge cases are considered)) and are thoroughly discussed in the report.. All functions calculateWealth , getStockPrice , exec uteOrders and simulat e are explained and analysed in detail.. The report is of outstanding quality,, and includes sufficient details to illustrate your understanding of the assignment..
Submission Checklist
Preferably 24 hours prior to the due time of the ass ignment (FFriday Week 7,, 7::000PM)),, you should make sure that::
you have fully read and you understand the meaning of the pledge of academic integrity which you signed during assignment 1..
you have fully read and you understand the entire specification of the assignment
your work is pushed to GitLab and your repository is shared with your tutor and with Steven X.. Han with Reporter permission..
o Do not email your tutor or Steven to ask if they can see your repository.. If you can see it on GitLab,, and it is shared with your tutor (wwhich you can check through Settings > Members)) with Reporter access,, they will be able to see it..
the relevant Pipeline tests are passed..
your program works on the lab machines if the program does not work on the lab machines,, it might fail the tests
the report is in PDF format,, located at the root of your assignment repository and named Report..ppdf . Otherwise,, it may not be marked..
the completed assignment cover sheet is not in a separate document,, instead,, is the first page of your rep ort.. Otherwise,, your assignment will not be assessed and will attract a zero mark..
The assignment is prepared by Katya and Steven with advice from Bruno
Reviews
There are no reviews yet.