So you are about to start your investment portfolio, then, you wonder how to choose the right company to invest? That was the first question that came to me, such question came not alone: how do I know the financial health of a company? It’s safe to invest in the company? What metrics should I watch to compare different companies? Well, I’m not here to answer those questions, because I’m not an investment expert, so I took some courses and did some research, if you want to understand the logic behind investment you can check for some courses from Candi Carrera.
What I really am is a developer eager to learn new technologies, thats why I automatized the evaluation using Python and several cool tools.
Analyzing companies
I ended up realizing each time I evaluate a company I would made the same questions and check the same values:
- Revenue
- Net Income
- Share Price
- Earnings
- Number of Shares
- Dividends
- Equity
- Total Debt
- Interest Expense
- Ebit
With these values I would calculate some metrics:
- Tendency Slope on Revenue: The company revenue is growing or decreasing?
- Tendency Slope on Net Income: The company net income is growing or decreasing?
- Price to Earning Ratio (P/E): Estimates the years to recover your investment per share.
- Payout Ratio: The % of income used by the company to pay dividends.
- ROIC: How much money is the company generating for each dollar invested.
- Debt to Equity: Proportion between the total debt and the equity, shows how the company is being principally funded by debt or by the shareholders.
- Interest Coverage Ratio: How much of the earnings should be used to pay debt interest. If the company can pay comfortable its debt interest, there’s a warning.
- Price to Book Ratio (P/B): What’s the proportion between the company real value and the share price. Usually the shares are greater than the book value because the market values intangible assets (like “know how” or reputation).
I start by using Yahoo Finance to get this data, it’s apparently the number one site to get information on stock market and it has a simple UI.

It seemed like a simple process to carry out every time I ask myself about an investment, but I noted some manual labor I usually repeat using the Yahoo UI, things that if were automatized could make my decision making faster:
- I need to visually search the values among some other data that is not interesting for me.
- I would need to manually calculate the metrics or search for them in the UI.
- I would like to have some advise according to the company metrics, maybe something customized for me.
And that’s why I built Dufresne.
Meet Dufresne
Dufresne is a simple desktop application built in Python which query data for a company on Yahoo Finance, calculates the metrics and gives an advise on each one.

I wrote Dufresne to check the metrics against predefined values, and then it tells me if the metric is Great which mean I feel pretty comfortable with the value, It’s Ok which means even is not a magnificent value for the metric, I would feel comfortable too and Go Check which mean: hey why the company shows this value?
This Go Check values are not necessarily bad, as they just mean, according to my valuation standard, I’ll need to understand why the company present this behavior.
I want to stress this enough Investment is a personal decision, what’s a good evaluation for my can be a bad one for you, so keep in mind Dufresne just helps me to take decisions according to my preferences. But hey theres is good news, you can easily customize it.
How I built it
Dufresne is under MIT License, this is the code repo. Its design is really simple:

I used QT Widget Designer and PyQt6 to create the UI. PyQt6 is a great framework to create user interface in Python, but it can be a little prone error and not so interactive to create layer by layer only using code, thats why I used QT Widget Designer which is a desktop app to create the user interface with simple drag and drop controls, I want to recommend this cool tutorial to understand how PyQt6 and the designer works.

All the logic modules were built in plain Python3, I used the YFinance library for Python.
Extend to your own criteria
If you want to customize Dufresne, there are some right thumb advise depending of your goal:
I want to customize the UI
Cool then do this, be sure you have pyside6-designer installed; inside the repo you will find a design.ui file, open this file in the pyside designer, voila! now you can easily change the UI. Once you finish your modifications you’ll need to regenerate the MainWindow.py with the last changes, this is also straightforward by running the command:
pyuic6 src/ui/design.ui -o src/ui/MainWindow.py.
The app.py module inherits from MainWindow.py and binds logic to controls, including which values to present, so if you include new values, metrics or controls this is the file you’ll need to modify.
I want to customize the metrics evaluation
Calculated metrics are passed to rules_evaluator.py, take a close look to the evaluate_metric function, it receives a boolean as a second parameter, depending of this value it calls __evaluate_bottom_order or __evaluate_top_order, each one of these methods compare the metric value with thresholds stored on config.py.
The logic for evaluation is as follow: if a greater value of the metric is preferred, you should pass True on evaluate_metric call, False otherwise. The markers are defined with two values which create three areas for the metric, e.g for a Payout Ratio of 0.75.

I want to add more metrics and calculate my own
Well you want to go deeper in the logic, it’s also really simple, let ‘s understand the responsibility of each module.
All logic is controlled by ui_controller.py module, it receives the company MIC (Market Identifier Code), and trigger a query to Yahoo Finance, metrics_probe.py contains specific functions to calculate each metric.
So summarizing:
- Create a new array in
config.pywith the threshold values that define the three areas for your metric. - Include the logic to calculate the new metric on
metrics_probe.py. - Call and store the calculation of the new metric on
ui_controller.py. - Call evaluate_metric from
ui_controller.py, send True as second parameter if greater values for the metric are preferred, False otherwise.
Now be sure you draw the metric on the interface using the steps from customizing the UI.
Here is the link to the Dufresne repo happy coding!













































