In a book am currently reading, "Lindblad, Erik. 2006. Programmering i Python" (about Python 2, but good enough for a beginner at my level), the author writes that just as in every other scientific area in which I've been in touch, planning the work is just as important as executing it. The author writes about three "steps of OOP".
- Object oriented analysis
- Object oriented design
- Programming
1. Object Oriented Analysis
This step is about identifying the objects which will be used, which attributes they will have and which methods they need. By describing what the program is supposed to do in writted text, the nouns in can be used as objects and the verbs as methods in the code."The user uses the program to open a locally saved PDF company data sheet file from which all data is read. Compounded future earnings on an arbitrary time horizon are calculated with an arbitrary growth rate. The compounded earnings are then added to the company's equity so that a figure of what the equity (excluding shareholder paybacks such as dividends and share buy-backs) will be in the given time. By multiplying the future equity by the lowest historical price/book valuation, a future valuation is calculated. The current valuation is calculated and compared to the current price of the stock. The program will tell the user what is the up/down side in the company both in percent and in money."
Objects (nouns)
- Company data sheet
- Current company
- Compounded future earnings
- Current equity
- Compounded future equity
- Lowest historical P/B
- Future valuation of compounded equity
- Arbitrary time horizon
- Arbitrary growth rate
- Current stock price
- Open a PDF and read data.
- Read time horizon from user input.
- Read growth rate from user input.
- Read current stock price from user input.
- Read lowest P/B from data sheet.
- Read last three years net earnings from data sheet.
- Read equity from data sheet.
- Calculate compounded future earnings.
- Calculate future valuation of compounded equity.
- Calculate current valuation of future compounded valuation.
- Calculate up/down side.
2. Object Oriented Design
The design step is intended to concretize the model made in the analysis step by setting attribute names and types. Also methods are named and arguments and return types are decided. The relationships between objects are described in detail (maybe UML is good help?). I'm going to make a kind of flow description to visualize the process.- User opens PDF file in program. datasheet = openDatasheet()
- A module for PDF reading is imported (PyPDF2).
- A method for parsing the PDF data is run. parsePdf(datasheet)
- Return last three years net earnings as a list
- Return lowest P/B as an integer
- Return equity as an integer
- Time horizon input is read. time
- Growth rate input is read. growth
- Current stock price input is read. currentStockPrice
- An instance of Company() is created. Company() has five arguments.
- earningsList=""
- pb=""
- equity=""
- time=""
- growth=""
- Calculator(Company()) is a class that takes a Company object and currentStockPrice and returns two values.
- Return upDownSidePercent as float
- Return upDownSideCash as float
3. Programming
I'm going to write this program in Python 3.6 and I'm going to try to have an iterated process in which I will have a working prototype as often as possible.Ideas of improvement
As I was writing the above three steps, an explosion of ideas took place in my head. Although some of the ideas were existing prior to this post, many new came to mind. When I came up with the idea of the program, I wanted to make it come with a GUI, but due to complexity I'll start without GUI.- Time horizon is set by a date instead of a number of years.
- Output can be saved as csv.
- Output can be saved to a database.
- Calculate future value based on return on equity.
- Allow user to enter a stock ticker and retrieve data automatically (API or scraping).
- Growth rate calculated on historical data instead of arbitrary.
- Make a GUI for the program.
No comments:
Post a Comment