Python for Finance Exam 2023 (1)
Python for Finance Exam 2023 (1)
Materials Permitted: Students can use Python (any IDE such as Spyder, Jupyter
Notebook, etc.) to test their code.
Calculators Permitted: No
Revision:
Page 2 of 3 ECON40N15-WE01
Question 1.
Explain in your own words how the pairs trading strategy works. Describe in detail (without writing
code) how it is implemented. Discuss the main risks associated with this strategy. [20 marks]
Question 2.
What is supervised machine learning? Give examples of supervised machine learning applications
to finance-related classification problems. What is meant by the bias-variance trade-off? [20
marks]
Question 3.
Explain the Capital Asset Pricing Model (CAPM), including the model intuition and the main
criticisms. How does Fama-French three-factor (FF-3) model improve upon CAPM? List all three
factors in FF-3 model and explain their meaning. [20 marks]
Question 4.
A) This code will NOT run due to several syntax errors in it. Find the errors and fix them. Type
below the entire block of code but with the errors fixed. [5 marks]
B) Describe in words what this code does. Be specific. [5 marks]
C) There is another issue with this code besides the syntax errors. What is it? [4 marks]
Page 3 of 3 ECON40N15-WE01
Question 5.
A) Above is an extract from a script that backtests a trading strategy. What is the trading strategy?
What are the formation and trading period lengths? Explain precisely, line-by-line, what this
block of code does. [10 marks]
B) How should the code be modified to compute a value-weighted average portfolio return rather
than an equally weighted one? (Explain in words without writing code, but be specific). [10
marks]
C) How does the logic of the algorithm change if you in line 5, 5 is replaced by 10 and in line 8, 4 is
replaced by 9? [6 marks]