Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Introduction to Python

SMM283

CASE STUDY

You have just received a positive response from Merrill Lynch on a recent graduate 'Financial Analyst5 role you had applied for and you are invited to a job interview. The job specification includes, among other things, knowledge of Python at introductory level, but with the prospect of been further trained within the organisation. If successful you will work in a recently re-organised asset pricing department and if you were to be successful, you'd work as part of a team dealing with financial analysis and asset pricing that also involves computational work. Your prospective employer has prepared a trial test for you as part of the interview, entirely based on introductory Python programming.

You'd be expected to be tested on programming skills in Python, where a specific task is given that mi ict Pia ccrlarl vA/ithinlimited nmm inf nf tima +c a nrnKlom cnar'ifinatinn Vm i ora avcac+arl

Consider a 2-fund separation/6roblem Write a Pvthon pro a ram that allows the user to choose r JT r J rd

how to enter the (i) expected rate of return, (ii) volatility  two funds (ii) the ccrralaticn ccatluciant (i\/1 cca+luruact onrl o rick 十raa rota ro111rn■ * J

lyU I I C lcl LIU I I L/U C111 L/l CI I L I IV J CtVDiniUll L/UC 111L/ICI I L a I ILJ I i I q I Io 11 CC I a ID UI I C LU I I I ( CeiM

> \ / — ~ \

In the 2-fund portfolio and for the purpose of computing the return and risk of the portfolio, you would need the capital weights. The capital weight wi is set initially to 0.00. The second weight is always w2 = 1-wi. It should use a loop to increment wi by a small value (i.e. o . 0001) and compute w2 such that the sum of capital weights is always 1.00. The maximum value of wi is 1. o. The values should be stored in one-dimensional arrays or lists wi = [], w2 =[].

i.e. wi =[]

w2 =[]

0.0000

1.0000

0.0001

0.9999

0.0002

0.9998

0.5000

0.5000

1.0000

0.0000


The program should compute the expected return, volatility, quadratic utility, and sharp ratio of the 2-fund portfolio using the following corresponding expressions:

 

expected rate of return:

folio quadratic utility in expectation:

iarp Ratio:

For each weight

E(rp) = wiE(ri) + W2E(T2~)

Op = + + 2WiW2bib*i,2

 

Portfolio volatility:

E(up) = E(rp)  1 Aa2

2 P

.(*). A is the risk aversion coefficient

E(m  E(m Sp =

T屏甲』7 -

  巴一=——。卫 一劉

/program should compute portfolio expected rate of return, volatility, ,and Sharp ratio. The computed portfolio returns and volatilities should be stored in arrays [], and vp = [], respectively. ram should then find the portfolio with the ghest utility and highest sharp ratio.

e program so that user has control oveRhow [he  e to choose whether to compute capital Weights using^the Huan whereby w = g + rp * h. The applying HL through the following formulae:

E&2)

,1 = £妇-玖r)血的=

hi

d h vector

Litzenberger

ues can be

nerated by

\ l/v—二夕+吓犬"/

nd W2 = g2 + rp * h2, where

rp. Pogram then should compute

.Store them in the array efvp =( 

ce efficient frontier portfolios.

Capital weights can be generated using wi = gi + rp * rp values are those computed earlier and s

   phe portfolio standard deviation using the formula given abo

[].Note that according to HL theory, these

ight Values within 4 decimal as the portfolio expected return,

-             ... and 4 decimal places. The the lowest portfolio return to the highest. It should print out the arp ratio, clearly indicating the corresponding portfolio with its return and input must be robustly validated and the output should be properly

The program should print on the screen

,points and in a field with a reasonable character width, volatility, utility, and sharp ratio within a reasonable character wi values should be sorted m ximum utility and volatility attributes.

formatted.

You may help to first try to code at the program level or inside a user defined main function and then delegate some code to dedicated user-defined functions of your choice, but not less than 4 user defined functions.

You have flexibility on how many user-defined functions you may create and their specification (not less than four). They must be designed using good cohesion and coupling programming principles. The finished product must contain at least four well designed user-defined functions. This is the only program file you are expected to submit.

You must produce a running program saved in a Python file named “studentID.py” and an output Excel file “StudentlDPortfolioProblem.xls”. You may manually plot the portfolio mean-variance efficient frontier, CML, and identify the market portfolio, based on the program output data in the

excel file. This would allow you to check with literature that the shape of the graph is as described in literature. You may wish to note the maximum utility and sharp ratio in the graph. You do not need to produce any written work on the theorized financial portfolio elements. Focus is on the programming skills.

The program must run in order to be marked.

(100 marks)