Python-powered analysis of market trends

Every month has a different market flavor, from Chinese growth to easing of Federal Reserve policy. To illustrate this, I conducted natural language processing on daily market commentary. The result is a recap, for the last two years, of the various themes that the market has focused on.

Since 2023, we have seen the market fret about Chinese growth (summer 2023); over-anticipate Fed easing before paring back expectations (winter 23/24); focus on Japan as the Bank of Japan finally started hiking (spring 2024); analyze actual Fed easing (fall 2024); salivate on potential Chinese easing (winter 2024); and stress about tariffs (year-to-date).

We are now in the fourth month of tariffs being the main macro focus, and April thus far has seen a spike in the word “negotiation”.

Acknowledgements: The research I am analyzing is by BNZ, who leverage their timezone vantage point — as the first to see the trading day open — by producing a thorough recap of the previous day.

Method: I used my own Python code to load the reports, extract text from them, omit generic words like “the” and “lower”, count the most common words for every month, and use a mix of rules to determine every month’s macro meme. The code did all of this — over 500 reports to parse — in 178 seconds. You can contact me if you would like to see my code.

Python vs Jupyter vs Spyder vs IDLE…

There are so many “words” around Python. There is clearly an entire ecosystem here. Here I break it down un-comprehensively.

Python is the language. You run Python on one of the following:

  • Terminal / command prompt: This is the black screen with white/green text used by computer geniuses in movies. Very basic, you can’t click anything.
  • Text editor: Not as “bare” as Terminal – has basic functionality. Examples include Atom, Vim, Notepad (yes you can run Python on the thing you use to jot down reminders). Technically Jupyter is not a text editor – it’s a web application – but it behaves like a text editor.
  • Integrated Development Environment (IDE): comes with bells and whistles, which make working on Python easier. Using an IDE is like using Word instead of Notepad to write an essay. Examples include Spyder, PyCharm, IDLE.

Anaconda is a bundle which includes Python as well as Spyder (IDE) and a button which opens up Jupyter on your web browser. I use Anaconda to use Spyder to use Python, if that makes sense.

Which one is the best one to use? It depends on what you want and I have not tested them all, but I like Spyder for data science and analysis.