In general, when we write a class, we want to write one execute function, which will run all the other functions in our class, in the order we want, in the way we want.
For example, when we write our StockAnalysis class, we want one function (named execute) that will call the other functions that get a list of stocks, get the data for each stock, run the calculations, etc.
Here's a simple example:
class StockAnalysis:
def get_stocks(self):
return ['x']
def calculate_performance(self, stock):
performance = 'company {stock} lost $10'.format(stock=stock)
return performance
def execute(self):
stocks = self.get_stocks()
for stock in stocks:
performance = self.calculate_performance(stock)
print(performance)
if __name__ == '__main__':
StockAnalysis().execute()
Task:
- Cleanup
main.py so that it has the above structure
- Feel free to add placeholders for functions we have not yet implemented
- For example, we don't have a performance calculator yet; create a place holder that doesn't do anything