Photo by Steven Cordes on Unsplash

A few weeks ago, I was forced to transfer my portfolio to Google Sheets after the Python library pandas_datareader for Yahoo! Finance started to break for a number of my key tickers.

It had been years since I last tinkered with Google Sheets in earnest, but I was immediately impressed by the amount of progress Google has made since then.

Between importhtml() and googlefinance(), I was able to obtain quotes automatically across the asset classes. I include the hyperlinks to the respective documentation that could accessed when the function name above is clicked on.

And then I had an idea.

Not as complicated as Schrödinger’s cat though. Photo by Jackie Zhao on Unsplash

This is a follow-up post on my original article on how we could use Python to monitor our investment portfolios (link).

A little more than a year ago, my portfolio was in a sea of red, reeling in the throes / throughs (sorry that was too punny to ignore) of the worst stock market crash since the global financial crisis a mere Chinese zodiac cycle ago.

In those days, if you believed in long-term market value, almost any well-diversified index fund or ETF would have been a buy.

Fast-forward to the present day, the opportunity landscape is now as barren…

Photo by Joanna Kosinska on Unsplash

I recently had a coding challenge where I theorised that a concise solution could be found if functions could be treated as elements and packaged into lists / arrays or even dictionaries. Perhaps I came across an article discussing this feature — hence the intuition — but I never really had the chance to try it out before then.

Turns out that in both Python and JavaScript, functions could indeed be treated as elements and behave appropriately when we pass valid argument(s) to them.

Imagine we wanted to create a simple list of functions that returns the area or volume…

Jon Tyson from Unsplash

It is the last day of the year and I thought that perhaps I should share one last post on a coding challenge before we welcome a hopefully better 2021!

I found an interesting validation problem on Edabit that could help revise some concepts on Python list manipulations. Suppose you have been tasked to write a program to determine the winner of each tic tac toe game — ‘X’ for Player 1 and ‘O’ for Player 2, how could we do it?

Please do not read further if you want to attempt to solve the problem without spoilers first.


A snake but not in Python. Source: Wikimedia Commons, photographed by Rushen.

The game is available here.

I find this snake game project mildly ironic, as I have built this game without using any code from its namesake and all-time favourite language of mine — Python — which would have been quite punny.

Nevertheless, as they say — horses for courses — a web application without the need for any backend would not require the use of Python. As this game resides completely at the client side, JavaScript would have been the perfect choice.

Most importantly, the HTML and JS code have been largely built from the original codebase from Straker’s Github…

The Fibonacci sequence gives rise to the golden ratio found in many beauties of nature. This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.

The Fibonacci sequence was one of the first mathematical concepts that I analysed when I started coding. In particular, this sequence was vital in enabling me to grasp recursion.

To construct a positive Fibonacci sequence, we start by initialising the first two terms: 0, 1.

The next term is derived from the sum of the prior two terms: 0 + 1 = 2. And so on.

In Python, we can automate the process via recursion. So if we want to determine the third fibonacci number: in the function fibonacci, we first check if the sequence already has the value…

At Least One in Many

An OR logic gate. Arturo Urquizo assumed (based on copyright claims). / CC BY-SA (

Python with its highly readable syntax is perfect for solving analytical problems, especially if they are unlikely to become more complicated with scale.

One of the recent problems that I completed recently was a coding challenge that required me to write a short program to evaluate if a mathematical formula or has valid brackets. So, if we strip out all the variables and operator to leave just the brackets, they should balance properly without any unclosed bracket encased in another bracket. For instance, {[()]} and [(){}<>] would be considered valid but [(]) would not.

The Edabit challenge that inspired this…

Dietmar Rabich / Wikimedia Commons / “London (UK), Elizabeth Tower, -Big Ben- — 2010–1979” / CC BY-SA 4.0

In today’s world, we take for granted the numerical system that we use on a daily basis. The average human being is born with ten fingers, hence a counting system on base 10 is very natural to us.

We have exactly 10 elementary numerical symbols, ranging from 0 to 9. Every other natural number can be expressed in a permutation of these 10 symbols. I was teaching my eldest daughter addition with change, and she was able to keep up with the lesson. …

Basket of Fruits, c. 1830s, National Gallery of Art Collection

As a hobbyist, I have tried to complete at least one coding challenge a day to maintain the positive pace of learning.

Languages have now extended to Python, JavaScript, PHP, C++, C, Java, Swift, Kotlin, in order of comfort. In terms of nimbleness, I tend to think quite exclusively in Python for analytical problems, although I do use JS quite a bit when I have to, especially when I am tinkering on something in Chrome, or doing some web development.

As my coding endeavours have largely been bite-sized, I almost never had to resort to building more sophisticated architectures involving…

A Couple Reading by Candlelight c.1650–75, attributed to Gerrit Dou — Royal Collection UK

In recent weeks, I have been looking into the intersection between the languages. On the one hand, we have English as widely understood by human beings in this world. On the other, we have a host of programming languages with English-like syntax, designed to be understood by some human beings, before being compiled down to bytes for machines to understand.

The context of my study was triggered by my desire to extract insight from text — a form of unstructured data critically understood by the average human but had been notoriously difficult for machines to parse and analyse in a…

Kelvin Tan

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store