Question: Please help!! PYTHON 3: How would you make this function? You can make multiple functions if need be. No pandas please. def alg_moving_average ( filename

Please help!! PYTHON 3: How would you make this function? You can make multiple functions if need be. No pandas please.

def alg_moving_average(filename):

 """This function implements the moving average stock trading algorithm.  The CSV stock data should be loaded into your program; use that data to  make decisions using the moving average algorithm.  Any bookkeeping setup from Milestone I should be called/used here.  Algorithm:  - Trading must start on day 21, taking the average of the previous 20 days.  - You must buy shares if the current day price is 5%, or more, lower than the moving average.  - You must sell shares if the current day price is 5% higher, or more than the moving average.  - You must buy, or sell 10 stocks per transaction.  - You are free to choose which column of stock data to use (open, close, low, high, etc)  Args:  A filename, as a string.  Returns:  Two values stocks_owned and cash_balance :: stocks and balance OF THE APPROPRIATE DATA TYPE.  Prints:  Nothing.  """ # Last thing to do, return two values: one for the number of stocks you end up # owning after the simulation, and the amount of money you have after the simulation. # Remember, all your stocks should be sold at the end!  return stocks_owned, cash_balance
def main(): filename = input("Enter a filename for stock data (CSV format): ") # Call your moving average algorithm, with the filename to open. alg1_stocks, alg1_balance = alg_moving_average(filename) # Print results of the moving average algorithm, returned above: print("The results are...")

CSV file: https://www75.zippyshare.com/v/UwisLRMk/file.html

Please help!! PYTHON 3: How would you make this function? You can

Date, Open,High,Low,Close, Adj Close, Volume 2000-01-03,3.745536,4.017857,3.631696,3.997768,2.695920,133949200 2000-01-04,3.866071,3.950893,3.613839,3.660714,2.468626,128094400 2000-01-05,3.705357,3.948661,3.678571,3.714286,2.504751,194580400 2000-01-06,3.790179,3.821429,3.392857,3.392857,2.287994,191993200 2000-01-07,3.446429,3.607143,3.410714,3.553571,2.396373,1151836060 2000-01-10,3.642857,3.651786,3.383929,3.491071,2.354226,126266000 2000-01-11,3.426339,3.549107,3.232143,3.312500,2.233805,110387200 2000-01-12,3.392857,3.410714,3.089286,3.113839,2.099837,244017200 2000-01-13,3.374439,3.526786,3.303571,3.455357,2.330141,258171200 2000-01-14,3.571429,3.651786,3.549107,3.587054,2.418951,97594000 2000-01-18,3.607143,3.785714,3.587054,3.712054,2.503246,114794400 a00-01-193.7723213.883929 3.691964 3.805804 2 566468 1494108a0 Date, Open,High,Low,Close, Adj Close, Volume 2000-01-03,3.745536,4.017857,3.631696,3.997768,2.695920,133949200 2000-01-04,3.866071,3.950893,3.613839,3.660714,2.468626,128094400 2000-01-05,3.705357,3.948661,3.678571,3.714286,2.504751,194580400 2000-01-06,3.790179,3.821429,3.392857,3.392857,2.287994,191993200 2000-01-07,3.446429,3.607143,3.410714,3.553571,2.396373,1151836060 2000-01-10,3.642857,3.651786,3.383929,3.491071,2.354226,126266000 2000-01-11,3.426339,3.549107,3.232143,3.312500,2.233805,110387200 2000-01-12,3.392857,3.410714,3.089286,3.113839,2.099837,244017200 2000-01-13,3.374439,3.526786,3.303571,3.455357,2.330141,258171200 2000-01-14,3.571429,3.651786,3.549107,3.587054,2.418951,97594000 2000-01-18,3.607143,3.785714,3.587054,3.712054,2.503246,114794400 a00-01-193.7723213.883929 3.691964 3.805804 2 566468 1494108a0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!