The article is around testing the predictable power of a well-known feature of technical analysis: hammer. Hammer at the end of the downtrend has long been considered as a sign of trend reversal. In this article, I intend to use hammers as an entry point for short-term trading and enhance this naive strategy with technical indicators like MACD and RSI and Gradient Boosting Classifier. For this sake, I downloaded history for 17 stocks from S&P 500 for 5 years (30 March 2016–30 March 2021). Stocks are selected pretty randomly.

Part 1: 🔨 Hammer candle

In the first part, I show how I detect hammer and…

NFT weekly statistics

I week ago I decided to start tracking all the hype around NFT. For this purpose, I start to weekly monitor the top 100 positions on

I collected statistics in collectables and art categories from the 5th of March to the 11th of March. At first, let’s look at the collectibles category.

Collectibles stats

  • 32 or roughly a third of the top 100 collectibles left the group during a week.
  • The total capitalization of the top 100 has decreased by 28% (ETH) from 1 294 310 to 926 852. The total supply has increased by 1,32%.
  • During the week 2 collectibles…

  • In this article I try to explain the basics of LPPLS model using Excel and Tesla stock.
  • And show how one may react to all the hype about Tesla (at least, from the model point of view)


The model is about exponential growth. In finance exponential growth is most likely to occur during financial bubbles. The essence of exponential growth: the rate of growth is proportional to the quantity itself.

At first glance, Tesla stock fits nicely in this pattern.

This is a practical application of Marcos López de Prado articles (1 and 2) on portfolio optimization process. More specifically, I will overview the hierarchical risk parity approach (HRP), and one of its variations — theory-implied correlation matrcices approach. Most of the code in the article is from professor Prado articles adjusted for my needs.

This post has 4 parts:

  1. Part 1: about a problem with covariance and correlation matrxices
  2. Part 2: discussion of the mechanics of HRP apporach
  3. Part 3: A variation of HRP with theory-implied clustering tree
  4. Part 4: An application of methods to Russian stock market

Part 1: what is wrong with Markovitz portfolio


In the previous post, I started to write about my trading RL experiment. Today I decided to complete the description of the trading network (I coded it a year ago).

Metrics (or features)

Well, prices themselves are not very helpful for NN, returns too, because they are volatile (5 min) and exhibit stochastic behavior. Therefore, a first idea is to generate some features, like RSI, MACD, support and resistance levels. I used only resistance, support levels and returns of different periods for simplicity. For training, the metrics are calculated at the beginning of the series.

Metrcis class

Thousands of different features can be…

This article is devoted to the herding mechanism in stocks. I base it on the articles:
1) Estimation of Agent-Based Models: the case of an Asymmetric Herding Model, Alfarano et. al. (2005)

2) Ants, Rationality, and Recruitment, Kirman (1993)

In the first part, I present the theoretical model as outlined in the articles. Next, I apply it to several stocks: Apple, GE, and Tesla

Part 1. The model

The model bases on the interplay of two groups:

Fundamentalists who understand the “true” price of an asset. Consider them to be of Buffet-type investors, who can grasp the true value of an asset

Speculative traders…

Particle swarm optimization is a kind of natural algorithms like genetic algorithms.

In this post I’m going to apply it to portfolio optimization problem. The beauty of the algorithm that it can solve non-convex problems when our optimization goal. It can help us when we deal with something more complex than Sharpe ratios optimization.

Part 1: Data

I decided to use 5 ETFs:

  1. IVE iShares S&P 500 Value ETF
  2. MTUM iShares Edge MSCI USA Momentum Factor ETF
  3. IEMG iShares Core MSCI Emerging Markets ETF (USD)
  4. AGG iShares Core U.S. Aggregate Bond ETF (USD)
  5. AOR iShares Core Growth Allocation ETF

The choice of ETFs…

This year I have come across several pieces of research and insights from investment firms and think-tank with estimates of recession probability. I have noticed that many strategists have developed very complicated models on how to measure it.

Allianz Global Investors

Allianz, for instance, has at least three models, which gives very different results ranging from 2% to 88%. So, is 88% of the structural macro model is large, should it signal that we are in the recession?

To clarify the subject for myself, I decided to start from the beginning: from the definition of probability. …

This is a brief introduction to making a simple bot for trading using reinforcement learning.

Looking at the success of Deepmind robots at various games, it is a trivial idea to build a trading bot. In the end, trading is yet another zero-sum like game.

In the beginning, I thought that it would not take long until I manage it to work even with a modest profit. Well, it was my first mistake. So, the rest of the posts (I plan to publish) will be about lowly learning how to learn RL concepts and trying to make them work. …

IBM closest neighbours

The world is occupied by embeddings models. Word2vec, Image to vectors and much more. After recent news about extacting knowledge from science papers, I decided to apply model to the world of finance.

Before I start, I must admit: I haven’t extracted much knowledge, but still have learnt a bunch of things.

Crawling for ETF holdings

At first, I needed information about ETF portfolio holdingts. Reluctant to pay for databases like, I decided to scrap information directly from ETFs’ websites.

There are plenty of ETF providers, so I examined some of them:

  1. Blackrock (1,5 trln): all information on the same page, portfolio holdings…

Andrey Babynin

Finance + Data + Python.

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