Back to Junior Level

Python CLI Tool


Prerequisite

You are tasked to create a Python CLI program that accepts a list of stock prices for a given day and returns the maximum profit that could be made from buying the stock at a particular price and selling it later at a higher price.

For example if the input is: [45, 24, 35, 31, 40, 38, 11] then your program should return 16 because if you bought the stock at $24 and sold it at $40, a profit of $16 was made and this is the largest profit that could be made. If no profit could have been made, return -1. This should be presented as a python package that can be installed using pip.

Requirements

  • Create a Python module that can be installed using pip to expose a CLI command to determine maximum profits for a given list of prices (integer).
  • Create unit tests that confirm accuracy of the tool.
  • Handle CLI arguments such as --help to show usage and provide an error when the expected argument (list of ints) is not passed or is passed invalid values.
  • Your algorithm should run in linear time with O(n) complexity.

Deliverable

  • The repo should have a good README explanation for us to get the project running locally and review the Tasks
  • We will install the project using pip install . - this should complete any required setup to have the command available at the CLI.
  • The command should provide its own help documentation when passing something like -h or --help.
  • A GitHub repo with read permissions given to GitHub users rafty8s,bsneider, omnipresent07, and barakstout (how to invite collaborators)