Sunday, October 24, 2021

Online stock filtering and screening by inventory turnover and receivables turnover

Cash flow is critical in running all businesses. Companies without healthy cash flow are very likely to go into financial trouble sooner or later.

In normal business operations, there are several factors that have great impact to the cash flow of the company, including:

  • How fast can the company sell out its goods?
  • How fast can the company collect the full payment from its customers?
The first factor can be rephrased in layman terms as "how fast can the company make money through its operations?", which is no doubt, the faster the better. This can be reviewed by its inventory turnover rate.

When the company's goods are stored in the warehouse or display rack, there is storage cost involved. The value of the goods could also be depreciated as they are approaching their shelflife expiry, or when newer goods are introduced to the market which becomes more attractive to the customers. Most importantly, the goods can only bring revenue to the company after they are sold (or leased) to customers.

The formula to calculate inventory turnover is:

Inventory turnover = Cost of goods sold / Average value of inventory

Low inventory turnover rate indicates:
  • Weak sales
  • Over-stocking (too much goods produced or brought in)
This can be resulting from poor marketing and/or poor sales to clear out the inventory effectively. This can also be due to lack of customers' purchasing interest to the goods, which could be:
  • Price is set too high
  • Product quality is too low
  • Low demand

High inventory turnover rate indicates:
  • Strong sales
  • Insufficient inventory (not a good sign)
This can be resulting from effective marketing and/or aggressive sales. This can also be due to:
  • Price is set too low
  • Product is good that customers are willing to pay for its price
  • High demand
Even if a company achieved a consistently high inventory turnover rate, its cash flow is yet affected by its receivables turnover rate.

There are generally 3 ways a business collect money from its customers:
  • Advanced (prepaid) collection - customer paid before receiving the goods.
  • Cash term collection - customer pay upon goods delivery.
  • Credit term collection - customer is given interest-free period to make payment within a timeline (normally 7-days, 14-days, 30-days, 60-days, etc.) after receiving the goods.
The money that customers owe to the company, normally due to credit terms, is called receivables. It is a common sense that high receivables will tighten up the company's cash flow, and, on the other hand, advanced payment collection will have positive impact on the company's cash flow.

The common formula for receivables turnover is:

Receivables turnover = Total credit sales / Average accounts receivables

However, the formula used in Rakuten Trade Stock Screener is:

Receivables turnover = Total revenue / Average accounts receivables

This could be due to the difficulty in separating the credit sales from the revenue with the financial information made available to the investors.

A high receivables turnover rate indicates that the company is effective in collecting back the money owed by customers. A low receivables turnover rate is normally a red alert to investors and bankers.

Here is an example to perform stock filtering and screening in Rakuten Trade based on the 2 turnover rates as mentioned above.

Login to Rakuten Trade online trading website, select the Stock Screener menu, add a new filtering criterion, and select Receivables Turnover (%). Set its minimum to 10%.

Then, add in another filtering criterion Inventory Turnover (%). Set its minimum to 10%.

You should be able to get a list of around 40-50 matching stock counters on your screen at this moment.

Note that inventory turnover is generally industry-related, and you should compare the inventory turnover rate of a company with its peers in the same industry. For example, we expect a high inventory turnover rate in the FMCG industry.

If you don't have a Rakuten Trade account to access to the Stock Screener above, you can use this link to open a new Rakuten Trade account for free, including no charge for opening new CDS account. By opening account with the link, you can get 500 RT Points within 30 days upon your account activation. Beside that, if you start your trading within the first 10 business days after account activation, your first online trading brokerage fee will be rebated as additional RT Points as well.

Upgraded my Roborock S7 cleaning robot with its auto-empty dock that supports both bag and bagless debris emptying

When I bought my cleaning robot, I have chosen Roborock S7 instead of S6-Max or S5-Max because I knew it is the model that can pair with Roborock auto-empty dock.

In fact, I find it quite difficult to empty out the dust in the Roborock S7 dust box because the debris can be trapped in quite a lot of places inside the dust box. The only effective way to quickly empty it out is to vacuum out the debris, which is exactly what the Roborock auto-empty dock function to do. As such, I suspect that the dust box is designed that way to entice people to buy its auto-empty dock to make life easier.

Currently, there are already 3 generations of Roborock auto-empty dock:

  • The 1st generation can only work with disposable 1.8 litre dust bag, which can easily hold debris for more than a month.
  • The 2nd generation has a cyclone separator unit to collect debris into its dusbin without dust bag. Alternatively, it can also work with the disposable dust bag by replacing the cyclone separator in it with the dust bag components.
  • The 3rd generation, not available to S7 yet, is able to automatically refill the robot's water tank and clean the robot's mopping cloth, besides emptying out the debris from the robot's dust box.
If you intend to buy a Roborock auto-empty docking station, I strongly encourage you to buy the 2nd generation that comes with both the cyclone separator and also the dust bag holder and disposable dust bag. I bought it at the price of slightly above RM1,600 in Banggood online shop.

The Roborock auto-empty dock has 2 colour selections: black and white. The Roborock S7 cleaning robot also has black and white selections.

I find that mixing the colour between the robot and its auto-empty dock also looks nice and would not cause any dissonance. Here is my white Robock S7 and its black auto-empty dock.

You can see that I have already replaced its cyclone separator with its disposable dust bag unit. In this way, I don't need to clean its dustbin, as all the debris will be stored inside the 1.8L dust bag.

Its cyclone separator looks like lotus seedpods. The Roborock auto-empty dock user manual has the instruction to change it with the dust bag unit, and vice-versa.

The Roborock auto-empty dock comes in 2 pieces after unboxing, which we need to assemble its body onto its base by screwing 5 screws that are marked with the screwdriver sign. An L-shape screwdriver is available at the base for that purpose.

The Roborock auto-empty dock comes with a dust box with an air-inlet, to replace the one in the S7. You will need to remove a lit that covers the air-inlet window in the S7 robot too. Detail instruction is given in the user manual.

The debris in the robot's dust box is sucked into the left cylinder of the dock station, and then settles down in the right cylinder, either in its dust bag or directly in the dustbin.

There are 2 filters inside the left cylinder, namely the rear HEPA filter and the front cup filter, both are removable and washable.

After the Roborock S7 robot made its first docking onto this auto-empty docking station, you will find additional functions for this auto-empty dock in the Roborock mobile apps.

The left button at the bottom of the main page has changed to "Empty Dustbin".

There is also an Auto-Empty Settings menu option, in which you can set the empty mode to be either smart, light, balanced, or max.

When assembling this Roborock auto-empty dock, I was amused by its state-of-the-art brilliant and beautiful design, which is a combination of engineering, art, practicality, hygiene, and user experience. It's just amazing. You could be feeling the same when you assemble a unit too.

Note that when the robot is docked onto this auto-empty docking station, it is pretty tightly "sucked" on it and not manually removable, unless by force, which is a big no-no.

If you want to bring the robot to another place for multi-floor cleaning, you can detach it from the docking station by using the Remote Control function in its mobile app. Just control it to move backward, and it will come out from its docking station.

In certain countries, Roborock has bundled them together as S7+. If you see the S7+ model, it is actually an S7 rebot that comes together with its auto-empty dock. But, you need to beware that the auto-empty dock in the S7+ might be of the first generation, without the cyclone separator.

Monday, October 11, 2021

Online stock filtering and screening by profit margins and profit growth

Beside analysing stock counters investability using Return of Equity (ROE) and Return of Assets (ROA), it is also imperative in fundamental analysis to evaluate the business profitability of the stock counters. This can be achieved by looking into their profit margins and profit growth rate.

Operating profit is the profit (i.e. revenue minus the cost of goods sold) derived from the company's core business operations. Operating profit margin is the percentage of operating profit portion divided by total revenue.

A company with higher operating profit margin usually has more room to give discount (i.e. temporary lowering the profit margin in order to secure a deal), and therefore more financially healthy.

Companies which are able to maintain a high operating profit margin all the time are usually having high competition barrier, protecting them from being forced into price war with competitors. 

The operating profit margin is usually going along with the industry. Industries with generally high profit margin including high technology, cosmetics, premium consumer brands, etc. If a company's operating profit margin is above its industry average, it indicates that its management team is more capable in bringing in business profit than its industry peers.

Pretax profit is the profit that takes into account both operating income and non-operating income. Examples of non-operating income including investment gains, forex gains, profit from selling out fixed assets, etc. Pretax profit is also known as earnings before interest and tax (EBIT).

Usually, a company will have pretax profit margin that is slightly lower than its operating profit margin. If its pretax profit margin is higher than its operating profit margin, it indicates that the company is making more profit from non-operating revenue than its core business revenue.

Here is an example to perform stock filtering and screening in Rakuten Trade based on profit margins.

Login to Rakuten Trade online trading website, select the Stock Screener menu, add a new filtering criterion, and select Operating Margin (%). Set its minimum to 35%.

Then, add in another filtering criterion Pretax Margin (%). Set its minimum to 30%.

Beside having good profit margins, we might also want to see the company's profit growth year by year. Therefore, select the 3rd filtering criterion Pretax Profit Growth Rate (%) and set its minimum to 10%.

You will instantly get the list of matching stocks on your screen, which is around 40 to 50 counters at the time being.

Combined with our 2 filters of ROE and ROA, the list will be left with only around 10 counters.

You will see some rubber glove counters in the list. The rubber glove industry has been enjoying an exceptional good profit margin over the past 2 years. The question you need to ask as an investor is that: does this good profit margin sustainable, at least for another upcoming year?

Note that companies with low profit margin does not necessary mean that their industry is not profitable, provided that they are able to generate their profit by high volume of sales. Example of such industries including grocery trading, essential food trading, etc.

If you don't have a Rakuten Trade account to access to the Stock Screener above, you can use this link to open a new Rakuten Trade account for free, including no charge for opening new CDS account. By opening account with the link, you can get 500 RT Points within 30 days upon your account activation. Beside that, if you start your trading within the first 10 business days after account activation, your first online trading brokerage fee will be rebated as additional RT Points as well.

Sunday, October 10, 2021

Caltex RM5 cashback with CaltexGO pump-and-go mobile app

As you might have been aware, Caltex Malaysia has recently introduced the CaltexGO pump-and-go mobile app, available in Google Play Store and Apple App Store.

Apparently, it is the same CaltexGO mobile app already in used in Caltex Singapore and Caltex Thailand for the same purpose of enabling contactless and cashless petrol refueling at their petrol station.

This is an enhancement to the existing Caltax tap, pump and go system, which you need to slot in your JOURNEY card to collect BPoints, then tap your credit card or debit card at the petrol pump terminal to refuel your vehicle.

Now, with the CaltexGO mobile app, you can bind your JOURNEY card and your credit/debit card with your user account, and you can refuel your vehicle at Caltex petrol station even without bringing those cards along with you.

CaltexGO will auto-detect the Caltex petrol station you are located at with your mobile phone GPS location detection service. You just need to enter your petrol pump terminal number into the app, then lift the petrol pump and start refueling. When you put back the pump to the terminal, your bill will be instantly generated, and you just tap a confirm button to pay for it. Your JOURNEY card loyalty points will be automatically credited too.

Currently CaltexGO in Malaysia only support VISA or Mastercard credit card or debit card. Hopefully e-wallets will be included too in the future.

As a welcome offer to encourage usage of CaltexGO mobile app, Caltex Malaysia is currently giving out RM5 cashback for petrol refueling of RM30 and above, until 31st December 2021.

Your RM5 cashback will be automatically used during your next petrol refueling of RM30 and above at Caltex station using CaltexGO. You will see it as "promotion discount" in your bill, as shown above. Your bills are paperless and stored in your app, so you can always track back your historical petrol refueling transactions in Caltex station.

This means that you will not immediately get the RM5 cashback during your first time using CaltexGO to pump petrol of RM30 and above. The next time and all subsequent times you do the same, you will get the RM5 cashback automatically, until the end of promotion period on 31st December 2021.

RM5 is equivalent to 16.67% of RM30, which is a pretty good offer, isn't it?

Friday, October 8, 2021

Malaysia year 2022 national and state public holidays

The official 2022 national and state public holidays in Malaysia has been announced by Cabinet, Constitution and Inter-Government Relation Division (BKPP), Prime Minister Department.

There are 14 days of national holiday (12 national holidays, whereby Chinese New Year and Hari Raya Puasa have 2 days of holiday respectively, and all the rest are 1 day).

1 of them fall on Friday, 1 fall on Saturday, 5 fall on Sunday, and 2 fall on Monday. Most of the states will have around 4 state holidays in addition to the national holidays. 

Kelantan and Terengganu will have 1 additional holiday for Hari Raya Qurban.

Chinese New Year falls on Tuesday and Wednesday (1st and 2nd February 2022). I believe many people will take a few days leave during the period, namely Monday, Thursday and Friday, so that to enjoy a whole week holiday.

Hari Raya Puasa falls on Tuesday and Wednesday too (3rd and 4th May 2022). Good news is, Monday 2nd May 2022 is also a replacement holiday for Labour's Day which falls on Sunday 1st May. Therefore, you can have another whole week holiday by taking leave on Thursday and Friday.

Deepavali falls on Monday (24th October 2022), so you will have a long weekend.

Click here to download the table of Malaysia year 2021 gazetted national and state public holidays.

Thursday, October 7, 2021

PHP: Exporting data table array to Excel xlsx file with PhpSpreadsheet library

In many occasions when a data table is queried from database and/or displayed on the screen of web application, there is a need to enable the user to download the table, preferably as an MS Excel file.

Traditionally, the method of doing so is to export the table as CSV (comma-separated values) or TSV (tab-separated values) text file, and to use MS Excel to import the CSV or TSV into a worksheet.

There are a lot of shortcomings using this method, including but not limited to:

  • You need to open a new webpage in order to perform the file export, which looks weird to the user experience.
  • The separator character might be different for different users. Some uses comma (","), some uses semicolon (";"), some uses vertical bar pipe ("|"), and so on. Libre Calc in LibreOffice is more flexible in handling the separator character during data import, whereas in MS Excel, if the separator character in the file is not the same with your computer's regional format setting, you will probably get rows of long data in single column.
  • The CSV/TSV is in plain text, and no cell formatting can be made.
  • You need to properly escape and handle the data to be exported, to ensure your data export is successful without error.
  • Numeric fields will most probably be treated as number in the worksheet, although you might want to treat them as text string instead. Common occasions including handling of telephone numbers, batch numbers, serial numbers, etc.
Over the years, there is a trick to export a TSV as XLS (old Excel file format), by putting these 2 lines in the page header:

header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/");

There is a matured sample source code by Chirp Internet ( that includes a function to do data cleansing before the export. You can click here to look for the source code of that script.

However, the exported file is actually just a TSV instead of real XLS file. Newer version of MS Excel will actually prompt out warning message when you try to open such exported XLS file.

A much better and proper method is to use the PhpSpreadsheet library to generate the real MS Excel file in xlsx (Microsoft Open XML Spreadsheet) format.

By using this method, you can export the Excel file without the need of opening a new webpage that confuse the user. You can also perform many Excel file manipulation by using the functions, classes and methods provided by the PhpSpreadsheet library.

The PHP codes below are originally posted by billynoah in Stack Overflow forum.

Step 1: Install PhpSpreadsheet library using composer, if you haven't done so.

If you are using Laragon WAMP platform, you can install the library by opening the Terminal window (the 4th button in Laragon control panel) and type the following command:

composer require phpoffice/phpspreadsheet

Step 2: Add these 3 lines at the beginning of your PHP script.

require '/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

Step 3: Prepare your dataset in an array. Normally, this is queried from SQL database server using SELECT statement. Note that in order to use the writeXLSX function with source codes in Step 4 below, the dataset needs to be stored in an array instead of an object.

Below is a simple example of such codes, utilizing ezSQL library class:

$db = new ezSQL_mysqli(MY_USR, MY_PWD, MY_DB, MY_HOST);
$items =$db->get_results($sql, $output=ARRAY_A);
$keys = array_keys(current($items));

Step 4: Put the following function somewhere in your script.

function writeXLSX($filename, $rows, $keys = [], $formats = []) {
// instantiate the class
$doc = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $doc->getActiveSheet();

// $keys are for the header row.  If they are supplied we start writing at row 2
if ($keys) {
$offset = 2;
} else {
$offset = 1;

// write the rows
$i = 0;
foreach($rows as $row) {
$doc->getActiveSheet()->fromArray($row, null, 'A' . ($i++ + $offset));

// write the header row from the $keys
if ($keys) {
$doc->getActiveSheet()->fromArray($keys, null, 'A1');

// get last row and column for formatting
$last_column = $doc->getActiveSheet()->getHighestColumn();
$last_row = $doc->getActiveSheet()->getHighestRow();

// if $keys, freeze the header row and make it bold
if ($keys) {
$doc->getActiveSheet()->getStyle('A1:' . $last_column . '1')->getFont()->setBold(true);
// format all columns as text
$doc->getActiveSheet()->getStyle('A2:' . $last_column . $last_row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
if ($formats) {
foreach ($formats as $col => $format) {
$doc->getActiveSheet()->getStyle($col . $offset . ':' . $col . $last_row)->getNumberFormat()->setFormatCode($format);

// enable autofilter

// autosize all columns to content width
for ($i = 'A'; $i <= $last_column; $i++) {

// write and save the file
$writer = new PhpOffice\PhpSpreadsheet\Writer\Xlsx($doc);

Step 5: Call the writeXLSX function to generate your MS Excel file.

writeXLSX(EXCELFILE, $items, $keys);

That's all about it. Pretty easy and straightforward, isn't it?

Sunday, October 3, 2021

Online stock filtering and screening by ROE and ROA

In fundamental analysis, Return of Equity (ROE) and Return of Assets (ROA) are among the most important indicators used to evaluate the investability of targetted stock counters.

There are generally 4 components that make up the shareholders' equity:

  • The shares that are sold out to the shareholders, and tradable in the market.
  • The shares that are repurchased by the company and kept as treasury shares.
  • Company's profit that is reinvested into the business as retained earnings.
  • Additional paid-in capital pumped into the company by its shareholders.
In short, shareholders' equity is the money that the company's shareholder had invested into its business, together with the retained earnings from the company's business profit.

ROE is therefore a measurement to evaluate how effective is the company's management team in managing the business and bringing in annual profit to the company.

ROE = Net Profit / Shareholder Equity

The main different between ROE and ROA is that, ROE does not take into account the financial leverage or debt of the company, whereas ROA includes it.

As you might have aware of the basic financial equation as illustrated in the diagram below:

Total Assets = Shareholders' Equity + Total Liabilities

The company needs assets to run its business. The assets can be funded either from shareholders' equity, or from 3rd parties (non-shareholders) as liabilities, for example, in the form of financing loans.

ROA is a measurement to evaluate how effective is the company's management team in utilizing the company's assets to make profit.

ROA = Net Profit / Total Assets

ROA = Net Profit / (Shareholder Equity + Liabilities)

For those companies that are in net cash position (without any debts), its ROE = ROA.

For those companies with liabilities, its ROE is normally higher than ROA, as assets are increased by taking debt.

As a benchmark, if the ROA is lower than bond return rate or even fixed deposit return rate, the shareholders might as well put their money (and borrowed money) in those low-risk money-generating financial instruments, rather than in the business, which is more risky.

When picking target stocks for investment from thousands of counters in the stock market, one of the initial fundamental shortlisting methods is to filter the target stocks to those that meeting the criteria of ROE > 20% and ROA > 15%.

In Rakuten Trade, you can easily do your shortlisting with just a few mouse clicks.

You just need to login to Rakuten Trade online trading website, select the Stock Screener menu, add a new filtering criterion, and select ROE (%).

After that, do the same to select another filtering criterion ROA (%).

Set the minimum of ROE to 20%, and the minimum of ROA to 15%.

You will instantly get the list of matching stocks on your screen, which is around 30 to 40 counters at the time being.

If you don't have a Rakuten Trade account to access to the Stock Screener above, you can use this link to open a new Rakuten Trade account for free, including no charge for opening new CDS account. By opening account with the link, you can get 500 RT Points within 30 days upon your account activation. Beside that, if you start your trading within the first 10 business days after account activation, your first online trading brokerage fee will be rebated as additional RT Points as well.

Hint: Click on the "Older Posts" link to continue reading, or click here for a listing of all my past 3 months articles.