Backtesting is an important part of any strategy. An essential part of most strategies is having a Stop Loss and a Take Profit. In Python, there are a myriad of backtesting options available to you that allow for this but sometimes simple is better. Today, we’re going to look at how one can implement a Stop Loss and Take Profit using pandas before then using bt to run the full backtest.


  1. Overview of bt

1. Overview of bt

bt is a “flexible backtesting” framework for Python that is…

Explosion makes spaCy, a free open-source library for NLP in Python. Recently, they released an update to version 3.1 and this update changed quite a few things from v2, breaking many of the tutorials that were found on Medium previously. The only other article I could find on Spacy v3 was this article on building a text classifier with Spacy 3.0.

Building upon that tutorial, this article will look at how we can build a custom NER model in Spacy v3.1, using Spacy’s recommended Command Line Interface (CLI) method instead of the custom training loops that were typical in Spacy…

For those of you who use the Tastyworks platform, you may have noticed that they have a P50 metric. If you’re wondering what that does, it essentially gives you the Probability of closing that option at 50% profit. Now, I always wondered how that calculated that metric and recently stumbled across this video where they explained how they did. And I needed to replicate it. So, for all you nerds out there who wonder what goes on behind the hood… here ya go!

note: this would also be useful if you didn’t want to close at 50% profit but wanted…

With Singapore now in recovery from the Covid-19 pandemic, the government has began to allow people to meet up in groups of 8. My church group (of 37 people) wanted to meet up for dinner. I hence decided to use R to write some code that would allow us to organise the dinner in the best way possible! ( fictitious names have been used for privacy)

Sorting Requirements

  1. People stay all around Singapore

Happy New Year to everyone! Given the start of the New Year (and the beginning of my preparation for my Finals), I thought it would be apt to start a mini-series on… Demography! With all the confusion that’s been going on in the world in the last year, maybe it would be good to try to understand people better. Which, Demography (defined as “the study of human populations in relation to the changes brought about by the interplay of births, deaths, and migration” (Pressat, 1985)) prompt fulfills. This will likely be a 4 part series, looking at 2 demographic measures…

especially useful when the names don’t match!

A few days ago, I was asked to help someone collate results from an online survey. The problem was, the online survey had been done in two parts, each with its own Google Form. The request was to perform a simple linear regression model with the response variable recorded in one of the Google Forms, and the explanatory variables recorded in the other Google Form. However, there was no unique identifier for each survey participant and the only thing that they had been told to input were their names. This was going to be fun! …

One of the most popular ways to value a company is using a model known as the Discounted Cash Flow Model. This model attempts to find the intrinsic value of a company by projecting its future cash flows and then discounting it. This is typically done using an excel spreadsheet and is relatively simple (just requiring a little bit of math and some manual work to find the financial information of a company). In this article, we’re going to explore how we can easily automate this in Python (both the calculation as well as the pulling of financial data!), …

In a R-approved tidy way

I learnt about tidytext awhile ago and thought it was such a neat framework. The essential idea behind it was that you could perform text mining/sentiment analysis using dplyr and "tidy" dataframes. So, I just had to try it out! I looked around for awhile to find things to perform this exploration on and finally settled on Singapore Prime Minister Lee's Covid-19 related speeches - thought it might be fun to see how that changed over time. As always, a tl;dr to get things going.

( a side note here: this was a rather basic and easy introduction to tidytext…

An example of how you can use the “Reply Keyboard” function in Python-Telegram-Bot to create a simple thematic “photo album”

Ever wanted to create a Telegram bot that would allow you to share your photos with the rest of the world? Not really? Well, after you’re done with this article, you’ll probably think differently. And if not… well, you’re just wrong.

In this article, we will look at using the Reply Keyboard in Telegram (pictured below) to create our very own bot that sends photos to users based on categories. …

What does a group of guys chat about?

A couple of days ago, one of my friends mentioned that it would be interesting to do a visualization of our group chat — to see things like who spoke the most, who spoke after who the most, and what were the words most commonly used. In this article, I show you how I did that using pandas, json, and plotly.

Post Outline

  1. Gathering Data

1. Gathering Data

The group that we were in is hosted on telegram and the data was easy to pull. As shown, you just had to use Telegram Desktop to export the files…

Zachary Lim

Hi! I’m learning to explore data and think about personal finance (not always in that order)

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