Cash may be king, but cashflow is god—at least for small businesses, who can be simultaneously profitable yet bankrupt. A creditor, perhaps with cash flow problems of its own, need only delay the payment of its accounts receivable long enough such that the small business in question lacks the resources to meet its short-term obligations.

Unfortunately, even fractional CFOs may be disinterested in a small business due to its size. The responsibility of cash flow management therefore falls frequently on the shoulders of those who feel ill equipped to manage what amounts to the differencing of statistical distributions over time. Luckily, there are strategies available to small business owners such as invoice factoring that can help tilt the balance in their favor. Today, we look at how data science helped one client depress net borrowing costs by earning interest on the investment of excess capital.


A client with excess capital requested the quantification of company cash flow. The goal was to maintain enough cash on hand to avoid fees associated with credit-card-funded overdraft protection while investing the difference into four-week treasury bills. Figures 1 and 2 depict raw transactions, aggregated by date, and probability plots with the normal distribution serving as theoretical, respectively.

Fig. 1: Transactions were aggregated by day with outliers included. The result did not appear to match any known probability distribution.

Fig. 2: Empirical distributions are indicated by orange, with their theoretical counterparts appearing in red. A normal distribution was fitted to transactions smoothed by their five-day moving average and delimited to four times their interquartile range. The Shapiro-Wilkes test was performed on the smoothed transactions, which were not found to be significantly different from normal. All theoretical-versus-actual plots appear to support the hypothesis of normality.


The client was advised to retain a value equivalent to the fifth-largest transaction, so as to omit obvious outliers, plus four standard deviations’ worth of smoothed cash flow, with the standard deviation drawn from Figure 2. This implied the retention of \$75,000 dollars, freeing up \$138,000 to invest in government bonds. The riskless profit on the latter was approximately \$240, whereas the former has proven sufficient in keeping the client’s bank account balance out of the red. The client was able to depress borrowing costs by earning a risk-free profit on excess capital as desired.

Packages Used

Garrett Grolemund, Hadley Wickham (2011). Dates and Times Made Easy with lubridate. Journal of Statistical Software, 40(3), 1-25. URL

Joshua Ulrich (2018). TTR: Technical Trading Rules. R package version 0.23-4.

Marie Laure Delignette-Muller, Christophe Dutang (2015). fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34. URL

Client data has been numerically perturbed for the sake of privacy such that underlying statistical relationships remain unchanged.