Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CS-677: Day Trading with Oracle
Assignment
In this assignment, you will use Python to analyze the distribution
of returns and a number of trading strategies. This
assignment has to be done in Python only (no NumPy or Pandas)
except for generating daily returns data and saving it to
a file.
As part of the preliminary assignment, you have generated a
daily stock file for your stock and a daily file ”spy.csv” for the
S&P-500 (using the symbol ”spy”). For both files, you have
data for 2015 - 2019 (5 years).
In this assignment, you will investigate 2 sets of questions concerning
daily returns
1. If you buy a stock for just one day, what is the best day of
the week to do so. Specifically you will analyze the daily
returns for each day of the week. A ”Monday” return is
the percent change in (adjusted) closing price from previous
Friday to Monday. A ”Tuesday” return is the percent
change in price from Monday to Tuesday and so on.
2. comparison of returns if you have an ”oracle” that can predict
the future behavior of your stock price
We start with introducing some notation. Let R = {r1, . . . , rn}
Page 1
BU MET CS-677: Data Science With Python, v.2.0 CS-677: Day Trading with Oracle
denote your daily returns for your stock for n days. The mean
of the daily returns
μ(R) = r1 + · · · + rnn
To compute the standard deviation σ(R) we can use
Let us split the daily returns R into two sets
1. R?: all negative returns
2. R+: all non-negative returns
Finally, let |R?| denote the number of days with negative returns,
and |R+| denote the number of days with non-negative
returns.
Question 1:
1. for each of the 5 years, compute the mean and standard
deviation for the sets R, R? and R+ of daily returns for
your stock for each day of the week
2. summarize your results in the table as shown below (5 tables
total).
3. are there more days with negative or non-negative returns?
Page 2
BU MET CS-677: Data Science With Python, v.2.0 CS-677: Day Trading with Oracle
Day μ(R) σ(R) |R?| μ(R?) σ(R?) |R+| μ(R+) σ(R+)
Monday
Tuesday
Wednesday
Thursday
Friday
4. does your stock lose more on a ”down” day than it gains
on an ”up” days.