程序代写代做代考 Assignment instruction

Assignment instruction

Question 1 to 3:

Derive the formula using a general model (don’t need to simplify to double MA).

Question 4:

Write a R function as follows:

Q4<-function (S = S&P500, m=length_of_long_term_MA, r=length_of_short_term_MA) This function returns two output 𝐸(𝑅𝑡) and 𝐻, where 𝐸(𝑅𝑡) = √ 2 𝜋 𝜎𝑋 ⋅ 𝑐𝑜𝑟𝑟(𝑋𝑡 , 𝐹𝑡−1) ⋅ 𝑒𝑥𝑝 {− 𝜇𝐹 2 2𝜎𝐹 2} + 𝜇𝑋 (1 − 2𝛷 [− 𝜇𝐹 𝜎𝐹 ]), (2) 𝐻 = 𝜋 𝑐𝑜𝑠−1 𝜌𝐹(1) . (3) Use the results that you derive from Question 1 to Question 3. For example, 1. 𝜎𝑋 is the sample standard deviation of log S&P500 index. 2. 𝜇𝐹 = 𝐸(∑ 𝑑𝑖𝑋𝑡−𝑖) = ∑ 𝑑𝑖𝐸(𝑋𝑡−𝑖) 𝑚−2 𝑖=0 𝑚−2 𝑖=0 , where 𝐸(𝑋𝑖) use the sample mean of log returns. Question 6: The most naïve way to solve this question is to write a double loop over feasible sets of 𝑚 and 𝑟, where 250 > 𝑚 > 𝑟 ≥ 1 and 50 > 𝑚 ≥ 𝑟 ≥ 1, for daily and weekly frequency. Within the

loop, 𝑚 and 𝑟 are the augments to Q4 and return 𝐸𝑅𝑡 for each iteration. The pair of 𝑚
∗ and 𝑟∗

that give you the maximum 𝐸𝑅𝑡 is your optimal choice.

For students who cannot do a full search, you may simplify your computation by considering

• 𝑚 = 250, 120,60,20,10,5, and 𝑟 = 120, 60, 20, 10, 5,1, for daily frequency.

• 𝑚 = 52, 26,13,4,2, and 𝑟 = 26, 13, 4,2,1 , for weekly frequency.

Question 7:

1. Use your optimal choice in Question 6 to answer this question and let (𝑚∗, 𝑟∗) denote

your optimal choice.

2. Cumulative return (𝑐𝑢𝑚𝑅𝑒𝑡𝑡):

𝑐𝑢𝑚𝑅𝑒𝑡𝑡 = ∑ 𝐵𝑡−1𝑋𝑡

𝑁

𝑖=1

,

where 𝑁 is the number of active trading days in your analysis, 𝐵𝑡−1 is the position ±1 at

the end of period 𝑡 − 1, 𝑋𝑡 is the log return over period 𝑡.

The estimate of 𝐸𝑅𝑡 may be given by

𝑐𝑢𝑚𝑅𝑒𝑡𝑡
𝑁

.

3. The length of the (averaged) holding periods:

𝑁

# 𝑜𝑓 𝐵𝑡−1 𝑐ℎ𝑎𝑛𝑔𝑒 𝑠𝑖𝑔𝑛 𝑜𝑣𝑒𝑟 𝑡ℎ𝑒 𝑡𝑟𝑎𝑑𝑖𝑛𝑔 𝑝𝑒𝑟𝑖𝑜𝑑
.

The above formula provides the estimate of 𝐻.

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *