Question
Question 2: Stocks (Again) [6 points] Recall the stocks question from lab 4: Let's assume I'm playing the stock market - buy low, sell high.
Question 2: Stocks (Again) [6 points] Recall the stocks question from lab 4: Let's assume I'm playing the stock market - buy low, sell high. I'm a day trader, so I want to get in and out of a stock before the day is done, and I want to time my trades so that I make the biggest gain possible. And obviously I can't buy in the future and sell in the past. Write a function stocks(s) that emits the two trades in chronological order - what you think I should buy at and sell at - in order to maximize my profit. Repeat this question, but load your data from a .csv file on a remote server. The .csv file will be formatted like so: Date,Open,High,Low,Close,Adj Close,Volume 2013-12-24,16295.700195,16360.599609,16295.700195,16357.549805,16357.549805,33640000 2013-12-26,16370.969727,16483.000000,16370.969727,16479.880859,16479.880859,50160000 2013-12-27,16486.369141,16529.009766,16461.230469,16478.410156,16478.410156,47230000 2013-12-30,16484.509766,16504.349609,16476.869141,16504.289063,16504.289063,54220000 Assume that you buy at the value in the "Low" column, and sell at the value in "High". You may not buy and sell on the same day. Your functions, stocks(s) should take in a string of the filename of a CSV file containing the data. You may assume the file is in chronological order.
Question 2: Stocks (Again) I points] Recall the stocks question from lab 4: Let's assume I'm playing the stock market- buy low, sell high. I'm a day trader, so I want to get in and out of a stock before the day is done, and I want to time my trades so that I make the biggest gain possible. And obviously I can't buy in the future and sell in the past. Write a function stocks(s) that emits the two trades in chronological order - what you think I should buy at and sell at - in order to maximize my profit. Repeat this question, but load your data from a .csv file on a remote server. The csv file will be formatted like so Date,Open, High, Low, Close,Adj Close, Volume 2013-12-24,16295.700195,16360.599609,16295.700195,16357.549805,16357.549805, 33640000 2013-12-26,16370.969727,16483.00000e,16370.969727,16479.880859,16479.880859, 50168800 2013-12-27,16486.369141,16529.009766,16461.230469,16478.410156,16478.418156,472300ee 2013-12-3e,16484.509766,16504.349609,16476.869141,16504.289063,16504.289063, 54220000 Assume that you buy at the value in the "Low" column, and sell at the value in "High". You may not buy and sell on the same day. Your functions, stocks (s) should take in a string of the filename of a CSV file containing the data. You may assume the file is in chronological order In [ ]: # Write your answer here This cell should print the values of the trades. They should be [14253.000000, 16174.509766] In [ : tradesstocks( "DJI.csv") print(trades) The cell below is how the autograder will be evaluating your answer. It only needs to be correct to two decimal places. Make sure you return a list of floating point numbers. In []: assert round (trades [e], 2) 15340.69 assert round (trades[1], 2) == 26616.71 In [ ]: | # Hidden test for Q2 In [ ]: | # Hidden test for Q2 Question 2: Stocks (Again) I points] Recall the stocks question from lab 4: Let's assume I'm playing the stock market- buy low, sell high. I'm a day trader, so I want to get in and out of a stock before the day is done, and I want to time my trades so that I make the biggest gain possible. And obviously I can't buy in the future and sell in the past. Write a function stocks(s) that emits the two trades in chronological order - what you think I should buy at and sell at - in order to maximize my profit. Repeat this question, but load your data from a .csv file on a remote server. The csv file will be formatted like so Date,Open, High, Low, Close,Adj Close, Volume 2013-12-24,16295.700195,16360.599609,16295.700195,16357.549805,16357.549805, 33640000 2013-12-26,16370.969727,16483.00000e,16370.969727,16479.880859,16479.880859, 50168800 2013-12-27,16486.369141,16529.009766,16461.230469,16478.410156,16478.418156,472300ee 2013-12-3e,16484.509766,16504.349609,16476.869141,16504.289063,16504.289063, 54220000 Assume that you buy at the value in the "Low" column, and sell at the value in "High". You may not buy and sell on the same day. Your functions, stocks (s) should take in a string of the filename of a CSV file containing the data. You may assume the file is in chronological order In [ ]: # Write your answer here This cell should print the values of the trades. They should be [14253.000000, 16174.509766] In [ : tradesstocks( "DJI.csv") print(trades) The cell below is how the autograder will be evaluating your answer. It only needs to be correct to two decimal places. Make sure you return a list of floating point numbers. In []: assert round (trades [e], 2) 15340.69 assert round (trades[1], 2) == 26616.71 In [ ]: | # Hidden test for Q2 In [ ]: | # Hidden test for Q2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started