首页 > > 详细

讲解Quantmod package、辅导Java,c++编程语言、辅导Python、讲解data解析SPSS|辅导Python程序

Assignment 3
Due: Oct 21st, 2019 at 9:59 am
Question 1: Quantmod package (30 Points)
Quantmod is a powerful package when downloading daily equity data. During the class time, I
only present part of the functions from this package. To solve this question, you are required
to use functions from this package.
1. Download 1 year length data for an equity (You can select any equity you like), set the
start time as Jan. 1st, 2018 and end time as Dec 31st, 2018.
2. Calculate daily return using functions from this package. In this question, you shall calculate
both simple return and log return. (The two return sequences will be used in the
next question.)
3. Use chartseries() to add a Relative Strength Index line one the equity you selected. When
visualize this index, please use the default setting. Later, explain how to use this index in
equity trading.
Question 2: Basic statistics value and self-defined function (20
Points)
In this question, you need to design a self-defined function to calculate the first moment up to
the fourth moment for the return sequences you obtained from Question 1. To help you build
this function, please following instructions:
1. Your input should be a vector. Other than this format, your function should stop working
and send the user a warning message.
2. Calculate the first moment up to fourth moment for your input.
3. The object you want to return should be a “report”, this report should contain values
from step 2. Meanwhile, you should tell the user the data is left skew or right skew, heavy
tail or short tail.
Question 3: Data visualization (50 points)
In Question 1, you are required to generate the Relative Strength Index using the function from
Quantmod. In this question, you are required to generate this index by yourself without using
any package. Please use the same equity data you downloaded in Question 1.
1. The final goal is generating a figure which contains two plots. One for the equity price
movement. Another one for the index. Make sure you have proper title, x-label, y-label,
legend and etc. in your plot.
2. Investigate how to calculate the RSI index in detail. Make sure you will have the index
value for all trading days between Jan. 1st, 2018 and Dec 31st, 2018. (Hint: you may
need extra equity data to replicate the same result as you have in Question 1)
3. Based on the index value you get, how many times you observe a strong selling signal
(higher than 70)? How many times you observe a strong buying signal? (lower than 30)
Bonus: Discussion on the Relative Strength Index (50 Points)
Let’s do something new on the Relative Strength Index. Instead of using a fixed threshold in
equity trading, we can design a trading algorithm by ourself.
1. In order to accomplish this task, you need to prepare two data sets: A training data set
which contains 1 year length of data, a testing data set which contains 6 months of equity
data. (0 Points)
2. Based on the RSI values you obtained from the training data set. Find out which statistical
distribution it may apply to. In order to achieve this goal, you need to try at least three
different distributions. (10 Points)
3. Determine the threshold for the buying/selling signal. Let’s say this, when the index value
is outside the 95% confidence interval, you will buy/sell this equity accordingly. (10 Points)
4. Implement the threshold you set up from the previous step to the test data set. How much
money you may earn/loss after 6 month trading? Assume every time you observe this
signal, you will buy/sell 1 share of this equity. Please remember, on the last trading day,
you should not hold any equity in your hand. (20 Points)
5. Comment on your final result and discuss about the algorithm performance. In this part,
I want to see your thinking about using this index in equity trading. (10 Points)

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!