Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python question Question 2: Stocks (Again) [6 points] Recall the stocks question from lab 4: Let's assume lI'm playing the stock market- buy low, sell

python questionimage text in transcribed

Question 2: Stocks (Again) [6 points] Recall the stocks question from lab 4: Let's assume lI'm playing the stock market- buy low, sell high. I'm a day trader, so 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 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 # Write your answer here. This cell should print the values of the trades. They should be [15340.69043, 26616.710938] trades stocks ( "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 assert round (trades[0, 2)15340.69 assert round (trades [1], 2) 26616.71 Question 2: Stocks (Again) [6 points] Recall the stocks question from lab 4: Let's assume lI'm playing the stock market- buy low, sell high. I'm a day trader, so 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 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 # Write your answer here. This cell should print the values of the trades. They should be [15340.69043, 26616.710938] trades stocks ( "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 assert round (trades[0, 2)15340.69 assert round (trades [1], 2) 26616.71

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

ISBN: 3540416641, 978-3540416647

More Books

Students also viewed these Databases questions