Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Assignment 2 Assignment: load your stock and SPY analyze trading strategies last question (last digit) is optional use numpy (math), matplotlib (but  no pandas)   In this assignment, you will implement and analyze the efol- lowing day trading strategy for Salesforce, Inc

Assignment 2 Assignment: load your stock and SPY analyze trading strategies last question (last digit) is optional use numpy (math), matplotlib (but  no pandas)   In this assignment, you will implement and analyze the efol- lowing day trading strategy for Salesforce, Inc

Computer Science

Assignment 2

Assignment:

  1. load your stock and SPY
  2. analyze trading strategies
  3. last question (last digit) is optional

use numpy (math), matplotlib (but  no pandas)

 

In this assignment, you will implement and analyze the efol- lowing day trading strategy for Salesforce, Inc. (CRM) and SPDR S&P 500 ETF Trust (SPY) stocks:

For your stock, for every day you have the ”Open” and ”Adj Clode” prices. You will investigate the performance of the fol- lowing ”day trading” strategy. You believe that a stock has ”inertia” (and assume that you will know the direction of the stock movement in the morning compared to last night’s clos- ing price). In fact, assume that you know the opening price just before the market opens). Your day trading strategy for your stock is the following:

  1. if the Open price is higher than the ”Adj Close” price of yesterday (i.e. overnight return is positive) then you assume that the stock price will continue to increase during the day. Therefore, you buy $100 worth of shares at the ”Open” price and sell this number of shares at the end of the day (at adj close) to close your ”long” position. The number of shares will typically be fractional, like 1.12 or 0.89. Your profit/loss per share is (adj close - open).
  2. if the open price is lower than the ”Adj Close” price of yesterday (i.e. overnight return is negative) then you assume that the stock price will continue to fall during the day. Therefore, you sell short $100 worth of shares at the ”Open” price and buy this same number of shares at the end of the day (at adj close price) to close your ”short” position. You profit loss per share is (open - adj close)
  3. unless the opening price equals yesterdays (adj) closing price, you will always day trade. Aassume assume in both cases (whether you establish a long or short position) that you have $100 to invest and you know the overnight returns. We ignore trading costs in our analysis.
  4. for every day that you trade, you are given $100 (regardless of your previous trading performance).
  5. finally, in your computation of percentages, number of shares, prices - round to 2 decimal points.

Here is a simple example to illustrate:

 

 

For example, consider your strategy on Wednesday morning. The closing price on the previous day (tuesday) was $95 and the opening price on Wednesday is 92. The overnight return rate is 100% · (92 − 95)/95 = −3.2%. The stock fell overnight and you believe that it will continue falling in price for the rest of the day. Therefore, you sell short $100 dollars worth of stock (100/92 = 1.09 shares). At the end of the day, you buy 1.09 shares at the Wed closing price of 90: this will cost you 1.09 · 90 = 97.83. You profit is then 100 − 97.83 = 2.17

Now, consider your day trading startegy on Friday morning. The closing price on the previous day (Thursday) was $85 and the opening price on Friday is $90. The overnight return rate is 100% · (90 − 85)/85 = 5.9%. The stock rose overnight and you believe that it will continue rising in price for the rest of the day. Therefore, you buy $100 dollars worth of stock (100/90 = 1.11 shares). At the end of the day, you sell 1.11 shares at the Friday closing price of $95: this will give you 1.11·$95 = $105.45. You profit is then $105.45 − $100 = $5.45

Let us define some additional notation. Take a particular time period (e.g. year). Let |S| denote the number of days when you took the short position and let |L| be the number of days when you took the long position. Let |S + L| be number of days that you traded your stock (both long and short). Let P(S) be the total profit/loss for ”short position” days and P(S)/|S| be the average daily profit for ”short position” days. Similarly, Let P (L) be the total profit for ”long position” days and P(L)/|L| be the average daily profit for ”long position” days. Similarly, let P (L + S) be the total profit for ”long and short” position” days and P (L + S)/|L + S| be the average daily profit for such days. Similarly,

Questions: For all questions, you take the daily 5-year data for your stock and for S&P-500

For each of the 5 years, compute statistics on your trading days and summarize them in the following tables (one table for your stock and one table for S&P-500)

 

 

  1. what is the average daily profit for your stock and ”spy”? Since you always start with $100, this number will coincide with percentage profit.
  2. is the profit from ”long” positions (when you buy) higher or lower than your profit from ’short” positions (when you sell short)? What is more profitable: long or short positions?
  3. suppose you add a restriction that you will trade only if the absolute value of overnight return is more than some threshold value x (e.g. 5%). (for example, unless stock price rises or falls overnight by more than 5%, you will not trade). With such a restriction, you will trade less frequently but maybe your profut per trade will increase. We would like to investigate the impact of this hyperparameter x. Take 100 points for x from 0 to 10% and plot the average profit per trade P (S + L)/|S + L| (over 5 years). Discuss your findings. Any patterns? Any optimal values for x?
  4. perform the above analysis separately for long and short positions (both your stock and S&P-500). Discuss your findings.
  5. plot two histograms on the distribution of last digit (cent position) for the ”Open” prices for your stock and for S&P- 500. What digit has the highest and the lowest frequency? For which security, the distribution seems to be more uni- form?

Option 1

Low Cost Option
Download this past answer in few clicks

22.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE