FIN551 Python Programming
INSTRUCTIONS TO STUDENTS:
-
This End -of-Course Assessment paper comprises 6 pages (including the cover page).
-
You are to include the following particulars in your submission: Course Code, Title of the ECA, SUSS PI No., Your Name, and Submission Date.
-
Late submission will be subjected to the marks deduction scheme. Please refer to the Student Handbook for details.
Question 1
You are only required to submit a Jupyter notebook for this ECA. The use of Python modules is encouraged in this ECA. An analyst has a simple trading strategy. She believes that if the price of a stock is below (above) the floor (ceiling) price, the stock is under - (over -) valued and such instances are the best time to long (short) the stock. She wants to test if her hypo thesis is correct by back -testing it with historical stock prices.
The blue line in Figure 1 illustrates the weekly price trajectory of a stock in 2020. The vertical dotted line denotes the end of an observation period, since the start of a given year. Th e minimum and maximum prices in the observation period are labelled as the floor and ceiling prices respectively and they are denoted by the red and green lines in the figure.
Figure 1. Trading activities in the strategy due to the breaches of the floor/ceiling prices.
If the stock price falls below the floor price, the stock is deemed to be undervalued. The stock is acquired and will be held until it breaches the floor price again. You can assume you can hold fractional units of the stock. Transac tions due to breaches with the floor price are denoted by red triangle markers in Figure 1.
If the stock price is above the ceiling price, it is overvalued and will be sold short. You can assume you can short fractional units of the stock and the number of stocks you can short is dependent on your existing wealth level. The stock will be bought back when it is below the ceiling price. Transactions due to breaches with the ceiling price are denoted by green circular markers in Figure 1. In the figure, there are only 1 (one) pair of transaction occurring, as a result of the floor price, while there are 3 (three) pairs of transactions due to the ceiling price. All transactions must unwind by the last trading date in the year. Hence, if there are any open stock positions, they must unwind at the last traded price of the year. The result of these transactions resulted in a final wealth of $1,132.90 (corrected to 2 (two) decimal points), if the strategy begins with an initial wealth of $1,000. You are to implement the trading strategy in Python, given the following strategy inputs:
Figure 2. Python inputs for trading strategy
Make use of the alpha vantage module to download weekly prices of tgt_stock for the given year in Figure 2. (10 marks)
Question 2
Evaluate the floor and ceiling prices for the inputs given in Figure 2. Print the floor and ceiling prices, corrected to 2 (two) decimal points, clearly in your script. (15 marks)
Question 3
Evaluate the buy and sell dates due to breaches with the floor pric e. Report clearly, the buy and sell dates of tgt_stock in your script. (20 marks)
Question 4
Evaluate the buy and sell dates due to the breaches with the ceiling price. Report clearly, the buy and sell dates of tgt_stock in your script. (15 marks)
Question 5
Evaluate the financial return from the multiple pairs of transactions in Questions 3 and 4. Hence, report clearly, the final wealth of the strategy, corrected to 2 decimal points in your script. (15 marks)
Question 6
Recreate Figure 1 with the strategy inputs given in Figure 2. (10 marks)
Question 7
Besides assessing your programming competency, your submission will be graded based on the following criteria:
• Clear documentation. Suitable use of inline comments and markdown is strongl y recommended, especially if you intend to provide a long description for your code.
• Code management. Any code that is not required should be deleted and not commented out.
• Programming to specifications. You are required to document and explain clearly any assumptions you have made in your implementation. (15 marks)
----- END OF ECA PAPER -----