Project

Algorithmic Stock Trading Program

You will try your hand at simulated stock market trading! You will use historical stock market performance data for both Apple, Inc (stock: AAPL), and Microsoft, Inc (stock: MSFT) for over the last 15+ years. Only a minimal knowledge of stock trading is needed.

We will not attempt to deal with any of the deeper technicalities of stock trading; however, your project will attempt to make sensible buy, sell, or hold decisions on stock data you are processing.

Your program, as a simulation, will be fed this historical stock data to ‘replay’ the days of trading for that stock. You will have your program act as if days are passing (day 0, day 1, day 2, …, etc), albeit much, much faster. Each ‘day’, you will look back at previous days, and make decisions on how you intend to trade your stock that day (if at all.)

Your program will include a variety of functions, some you design entirely on your own simply because you need them, and others because I specified that you create them.

Central to your program will be two different functions in your code: one where I provide explicit rules for one stock trading algorithm and a second algorithm will be created using your own stock trading rules.

Milestones

This project will be broken up into multiple milestones, each cumulative to the milestones previous to it. This will pace your progress, and make certain you well understand each distinct component of your program.

Each Milestone will be fully described via a link found on Blackboard.

  1. Milestone I (34/100 points)

    Purpose: Read in the financial data into our Python program and organize the data for use.

  2. Milestone II (33/100 points)

    Purpose: Design a function that performs the ‘moving average’ algorithm for stock trading.

  3. Milestone III (33/100 points)

    Purpose: Design your own interesting stock trading algorithm.

  4. Milestone IV [Extra Credit]

    Purpose: Provide some extra-credit opportunities. I’ll ask you to explore some intermediate-level concepts like Object-Oriented design, and Modules.

General Submission Requirements

Each milestone has requirements specific to itself, in addition to the general ones described below. Each milestone builds on the milestones previous to it! Remember, you are building up a full program, component-by-component.

This is not a group project, and all submitted work must be done individually (original, and unique to you.)

Submission Requirements

Please read and follow the Submission Requirements to avoid point deductions. Please use the assignment type of Project and the assignment name of Milestone I, Milestone II, Milestone III, or Milestone IV (Extra Credit) as appropriate in your docstring headers.

In addition, there are project specific requirements:

  1. Your project will be tested with at least two stock data sets from Yahoo Finance: Apple, and for Microsoft. I reserve the right to test it with stock data of other companies, so be sure your code understands this.

  2. A Python file project.py will be submitted as your program. Each milestone will require that you submit a file of this same name, building on the code from the previous submission.

    If you do the extra credit portion, project.py and tradinglib.py (optional; see extra credit) will be the expected file names.

  3. Your final submission must have at least the following functions defined:

    • main()

    • test_data(col, day)

    • transact(funds, stocks, qty, price, buy, sell)

    • alg_moving_average()

    • alg_rsi()

    You will certainly write additional functions of your own design and choosing to help these four functions do their job!

  4. In addition to the above point, any prototype code needs to be used exactly as I gave it to you (function names, arguments (parameters), and their names, docstrings, return values, etc.)

  5. The project cannot be submitted late. You have plenty of time to work on this, don’t squander it.

The grading rubric can be found on Gradescope.