Illya Gerasymchuk profile photo
Illya Gerasymchuk
Financial & Software Engineer

⬇️ My Thoughts ⬇️

User Illya Gerasymchuk -

2026-03-04 15:12

Random Forest Cat: An ML Trading Factory

I open-sourced a multi-model, machine-learning based factory for trading strategies on GitHub. It's written in Python and is highly customizable, as it exposes a framework for configuring the pipeline via a DSL.

Currently, it comes with two pipeline configurations: one that focuses on predicting wether the price of Bitcoin in 5 minutes will be higher or lower than now (Polymarket style), and a more generic strategy that shorts or longs Bitcoin at its own discretion.

This project also represents an experiment on enabling AI agents to discover trading strategies that will be profitable with real world, live price data. Clone the project and try asking an LLM to generate a profitable trading strategy using the framework.

You can also just train your own model (or use mine) and use its signals for live trades. Beware that this is a work in progress. I've already integrated an explicit split for a the validation set, but that code is not pushed yet -- I'll probably do it today. More improvements are also on the way.

In either case, the current version of the code on GitHub works, so you can download and run it.

GitHub Repository Link: https://github.com/iluxonchik/random-forest-cat-ml-factory

Random Forest Cat: An ML Trading Factory
User Illya Gerasymchuk -

2026-03-03 15:15

Very excited for the upcoming price rebound in commodity metals

Current prices remain a strong buying opportunity.

Remember that silver is significantly more volatile than gold and can retrace down closer to ≈$70, but it's definitely not the top for this bullrun in metals

Very excited for the upcoming price rebound in commodity metals
💬
User Illya Gerasymchuk -

2026-03-03 14:57

CUSUM Filter Visualized

I’m looking into CUSUM Filters in more depth and just wanted to share this nice visualization that Gemini created to demonstrate graphically how the threshold affects the sampling/event emission for a price series.

In this example, price is used a the feature, but note that CUSUM works with any measured quantity

CUSUM Filter Visualized
💬
User Illya Gerasymchuk -

2026-03-03 14:05

I've been calling for new local heights for oil prices for over 6 months now

Last time Brent Oil traded at $85 per barrel was in 2024

Throughout 2025 and start of 2026, some of the largest finance accounts on X where telling you to short oil. Some are still referring to these price spikes as "noise"

I've been calling for new local heights for oil prices for over 6 months now
💬
User Illya Gerasymchuk -

2026-03-02 15:48

Why High Oil Prices Are Bad For USD (HINT: China & Credit)

I don’t think that higher oil prices will help the value of US dollar medium to long-term this time. Higher oil prices induce higher prices for producers, which lead to higher prices for consumers. The US economy is already extremely dependent on its refinancing capacity. Currently, there are liquidity stress signs across several Fed facilities, which make that refinancing/rolling-over more difficult.

Higher oil prices, means even more new financing to cover the additional costs, which will further increase the country's refinancing burden. So this would push up not only broad & base money, but also raise their "baseline". The "baseline" will increase because the notional USD amount to refinance in the future will increase, meaning higher future liquidity needs.

In the most basic sense, this will increase the domestic supply of USD. If you consider the current slow, but steady decrease of demand for US Treasury debt instruments -- that's reduced demand for USD. Increased supply, combined with a reduced demand, implies a lower price.

The most notable instance of Treasury holding reductions (including not rolling them) is by People's Republic of China -- the world's #1 largest exporter, and China's explicit goal of increasing the share of renminbi in international settlement. Although the first country to successfully move away from USD was Russia -- and they did that by effectively swapping USD-denominated assets for gold and renminbi. If you go back in history, you will find a presidential order from the Russian Federation's president instructing the Central Bank of Russia to increase their gold tonnage holdings back in 2005. Other sovereigns are likely replicate this model, at least in part.

I believe the ECB + NCBs in the EU may also soon move towards the direction of reducing the share of USD-denominated holdings in their balance sheets as well. This situation presents as a great opportunity for increasing share of EUR usage, as it's already the 2nd most used currency, following the USD. Increased bi-lateral trade agreements with China would strengthen both, Euro and renminbi via increased demand -- and there's an intrinsic incentive to do that, as there is a lot of value that can be imported, and is already being imported, from the PRC. This would of course lead to the increase of renminbi-denominated holdings across the central banks in the EU.

Due to the above, the demand for USD is facing a downward pressure, while USD liquidity is showing signs of stress, causing an upward pressure on its supply. Higher domestic prices will only push that supply further up, while leveraging the economy even further (more risk). Sure, higher oil prices means more demand for USD to buy oil in OPEC and higher export revenue, but I don't think that would be sufficient to offset the negative implications.

Why High Oil Prices Are Bad For USD (HINT: China & Credit)
User Illya Gerasymchuk -

2026-03-02 14:48

Crude Oil Prices Continue To Increase

Over the past year, I've reiterated multiple times on the fact that that oil prices will continue to increase and that they'll soon be back up above their June 2025 prices. This happened again today, with Brent Crude Oil being up more than 10% on the day.

About 8 months ago I wrote a thread explaining and predicting an increase in oil and gold prices in the near future. Since then:

➖ Brent Crude Oil went up ≈17%
➖ Gold went up ≈65%
For reference, in the same time period, S&P 500 went up ≈18%.

Worldwide oil trade was (and still is!) subject to great geopolitical risk, part of which is materializing now. In addition to that, monetary debasement continues its course and military conflicts have a tendency to exuberate it, via increased demand, sovereign debt and spending.

Despite that, many continue to believe that violating the International law by invading a sovereign nation and kidnapping their leader implies lower oil prices, just because that sovereign nation is in procession of that natural resource. Of course, the reality is much more complex due to factors such as the required level skill/proficiency, infrastructure, internal risk and the implications of current geopolitical events on the international trade.

To conclude, remember: commodities are at the base of global real economy, and there will be a demand for them almost "no matter what". Of course, not all commodities come with the same risk profile -- I will refer you to my past posts on this topic, which you can read under the "commodities" articles category on my website.

Crude Oil Prices Continue To Increase
User Illya Gerasymchuk -

2026-02-27 14:35

So I extended my MCP server with a tool to execute arbitrary Python code, and now that's pretty much the only tool the host agent is using 😂

Instead of reusing the other tools, the agent prefers to write the whole logic from scratch and then pass to the MCP to execute it. It worked fine, but it's using too many tokens.

Code and context limitations are in the process of being imposed.

So I extended my MCP server with a tool to execute arbitrary Python code, and now that's pretty much the only tool the host agent is using 😂
💬
User Illya Gerasymchuk -

2026-02-27 12:29

Using Neural Networks To Find Imbalances In Limit Order Books

I've been working on model factory that predicts short-term asset movements. The model focuses on predicting whether the price of an asset at a future time T+c will be below or above the current asset's price at time T. c is an arbitrary constant which in my model represents the number of minutes.

Currently, it's structured to match Polymarket's 5 minute BTC up or down markets, so this model can be used for trading on those markets. In this setup, the return is binary -- you either almost double or lose the whole position (assuming an entry as within a small delta of the market open). But this model can also be easily adapted to long/short futures positions with more flexibility on entry or exit times — it would require adapting the labeler and the backtest configuration (namely the cost model and position sizing).

The first version of the model factory relied on features derived from 1 minute OCHLV data for Bitcoin. I focused on setting up a multi-model pipeline, and generalize it into a configurable DSL-like experience. I also focused on avoiding a big part of overfitting/looking forward and doing the first level of parameter optimization. I was able to obtain a small edge (≈0.54 win rate), and short-run live tests showed the model to be profitable, however I’m not very sure how resilient it is to regime changes, nor I find the computed edge sufficient (the win rate is subject to the error from the models). I also wasn’t expecting to achieve a meaningful edge with just OCHLV data, so I’m integrating limit order book (LOB) data in order to extract price movement predictive patterns from the lower level dynamics that end up determining the price.

Given that the order book drives the market price, its reasonable to assume that there is a function that expresses the relationship between the current order book state, and in which direction that state is more likely to move the price in the short-term. It’s my first time working with LOB data, so I looked for papers which explore a framework for modeling price predictions based on a multi-level LOB with price and volume data for bid and ask at each level. After filtering through several options, I settled on one titled “DeepLOB: Deep Convolutional Neural Networks for Limit Order Books” by Zihao Zhang, Stefan Zohren, and Stephen Roberts. I liked it because the authors taking care in avoiding overfitting and leaking forwarding the data, by splitting the data set into one for training, one for validation and one for testing. The model is trained on the training set, the hyperparameters are optimized on the validation set, and the verification/backtesting is done on the test set. I also wanted to integrate neural networks into the pipeline, and DeepLOB model uses a Convolutional Neural Network (CNN) and a Long Short-Term Memory (LSTM) network in its construction.

The neural networks in DeepLOB works as follows. First, the raw LOB data passes through a CNN to summarize/extract patterns from the data via filters whose weights are learned by the network. The output then goes through the inception module, which is another CNN which operates with multiple convolutional filters if different sizes to capture multiple time window patterns. Then, the resulting matrix is passed to LSTM, which is a recurrent neural network, meaning it’s able to maintain “memory” of the past state when evaluating the new state. LSTM outputs a vector, which is then multiplied by a weight matrix to produce 3 raw scores (logits), which then get mapped to probability for each one of the 3 classes via Softmax: (Up, No Change, Down), which serve as a trading signal.

I’ll be incorporating something similar as signals/experts and/or features in the existing pipeline of my model factory. I’ll also extend the pipeline to add an additional split for the validation set to optimize the hyper parameters of the random forest. I’ll upload the code to GitHub soon, but note that it’s a work in progress.

Using Neural Networks To Find Imbalances In Limit Order Books
User Illya Gerasymchuk -

2026-02-24 13:10

I've been running live a tuned model designed to predict Bitcoin's price moves in Polymarket's BTC's 5 minute up or down markets

Backtests had a quite remarkable perfomance, with PnL over 70% across >500 trades

As expected, real world performance is not as impressive, but it's managing to be slightly profitable 😁 LOB data integration should improve the model's accuracy further.

I've been running live a tuned model designed to predict Bitcoin's price moves in Polymarket's BTC's 5 minute up or down markets
💬
User Illya Gerasymchuk -

2026-02-24 12:55

The model factory has been refactored to use a DSL for configuring the pipeline -- so now you can visualize and configure the whole flow from a single place

This also makes it easier for agents to autonomously discover and verify profitable trading strategies, but I'll cover that in more detail in another post 😁

The model factory has been refactored to use a DSL for configuring the pipeline -- so now you can visualize and configure the whole flow...
User

The random forest's features have been heavily refactored. I also replaced the polymarket feature with lookahead bias (the proxy model) with a combination of other indicators.

The random forest's features have been heavily refactored. I also replaced the polymarket feature with lookahead bias (the proxy model)...
User Illya Gerasymchuk -

2026-02-21 20:23

crypto is not cryptocurrency

crypto is not cryptocurrency
💬
User Illya Gerasymchuk -

2026-02-20 18:03

I'll be using PAXG prices as a proxy for gold prices. The great thing about PAXG is that Binance provides for historical 1-minute OCHLV data dating back more than 5 years

My plan is to use this data to derive more signals and/or features for the meta forest

A script is in the process of downloading and preparing the data 😄

I'll be using PAXG prices as a proxy for gold prices. The great thing about PAXG is that Binance provides for historical 1-minute OCHLV...
💬
User Illya Gerasymchuk -

2026-02-20 16:51

The random forest's features have been heavily refactored. I also replaced the polymarket feature with lookahead bias (the proxy model) with a combination of other indicators.

The random forest's features have been heavily refactored. I also replaced the polymarket feature with lookahead bias (the proxy model)...
User

As a result of the first step in optimizing/prioritizing the random forest’s features -- I've dropped about half of them 😁

As a result of the first step in optimizing/prioritizing the random forest’s features -- I've dropped about half of them 😁
User Illya Gerasymchuk -

2026-02-20 15:26

As a result of the first step in optimizing/prioritizing the random forest’s features -- I've dropped about half of them 😁

As a result of the first step in optimizing/prioritizing the random forest’s features -- I've dropped about half of them 😁
User

Out of Sample Permutation Feature Importance For Random Forest’s Feature Optimization

After the first level of tuning of the random forest’s parameters, it came time to optimize the features on which the random forest gets trained on. I’ve already did a minor cleanup, but I didn’t yet test for the predictive importance of each feature in the random forest.

To optimize the random forest’s features, I’m using Out of Sample Permutation Feature Importance (OOS). The OOS approach consists in three core steps:

1️⃣ Train the random forest once on the training data
2️⃣ Take out-of-sample validation data (testing data), permute the values of a single feature/values within the same column and pass them to the model trained in step 1.
3️⃣ A feature is important for the model if the model’s predictive power reduces significantly when that feature’s values are randomly shuffled.

The “out of sample” part refers to the fact that the set of data used to train the model and evaluate it after permutations is distinct, thus reducing the contribution of noise to the evaluation metrics. By default, scikit-learn uses Gini Importance to rank features by their utility to the model. Gini is a bad metric for my data because of:

➖ High cardinality bias (it has an inherent bias towards continuous variables, and some of my features are discrete)
➖ Gini importance is computed on the training data
➖ In case of two correlated features, the random forest will randomly pick one at each split, but Gini will actually divide the importance between the two

Additionally, the out-of-sample Area Under the ROC Curve (AUC) of 0.7566 is unrealistically good for predicting 5-minute Bitcoin price moves. This value implies that if you pick a random 5-minute winning window and a 5-minute losing one, my model ranks the winner window ≈76% of the time. Either I found a model that beats virtually every financial institution in existence, or there is a lookahead bias and overfitting happening in the model.

Conclusion: my meta forest — the “seconds_to_settle” feature is basically carrying the entire model 😂 So in its current state, the random forest is training almost entirely on the time of day/time to expiration. The cleanup has started.

Out of Sample Permutation Feature Importance For Random Forest’s Feature Optimization
User Illya Gerasymchuk -

2026-02-20 15:08

Out of Sample Permutation Feature Importance For Random Forest’s Feature Optimization

After the first level of tuning of the random forest’s parameters, it came time to optimize the features on which the random forest gets trained on. I’ve already did a minor cleanup, but I didn’t yet test for the predictive importance of each feature in the random forest.

To optimize the random forest’s features, I’m using Out of Sample Permutation Feature Importance (OOS). The OOS approach consists in three core steps:

1️⃣ Train the random forest once on the training data
2️⃣ Take out-of-sample validation data (testing data), permute the values of a single feature/values within the same column and pass them to the model trained in step 1.
3️⃣ A feature is important for the model if the model’s predictive power reduces significantly when that feature’s values are randomly shuffled.

The “out of sample” part refers to the fact that the set of data used to train the model and evaluate it after permutations is distinct, thus reducing the contribution of noise to the evaluation metrics. By default, scikit-learn uses Gini Importance to rank features by their utility to the model. Gini is a bad metric for my data because of:

➖ High cardinality bias (it has an inherent bias towards continuous variables, and some of my features are discrete)
➖ Gini importance is computed on the training data
➖ In case of two correlated features, the random forest will randomly pick one at each split, but Gini will actually divide the importance between the two

Additionally, the out-of-sample Area Under the ROC Curve (AUC) of 0.7566 is unrealistically good for predicting 5-minute Bitcoin price moves. This value implies that if you pick a random 5-minute winning window and a 5-minute losing one, my model ranks the winner window ≈76% of the time. Either I found a model that beats virtually every financial institution in existence, or there is a lookahead bias and overfitting happening in the model.

Conclusion: my meta forest — the “seconds_to_settle” feature is basically carrying the entire model 😂 So in its current state, the random forest is training almost entirely on the time of day/time to expiration. The cleanup has started.

Out of Sample Permutation Feature Importance For Random Forest’s Feature Optimization
User Illya Gerasymchuk -

2026-02-19 16:04

The time to optimize hyperparameters of the random forest has come

Starting with a grid search approach

The time to optimize hyperparameters of the random forest has come
💬
User Illya Gerasymchuk -

2026-02-19 13:56

The model's first live data trade was a successful Bitcoin short! The position was open for 4 minutes, for a 0.11% return

The model's first live data trade was a successful Bitcoin short! The position was open for 4 minutes, for a 0.11% return
💬
User Illya Gerasymchuk -

2026-02-19 13:52

Added a connection to Binance's futures API and now I have the base learners and the random forest looking for profitable 5-minute Bitcoin trades in real time

Let's see how it goes, the model already entered its first trade. Let's see how it goes 😄

Added a connection to Binance's futures API and now I have the base learners and the random forest looking for profitable 5-minute...
💬
User Illya Gerasymchuk -

2026-02-19 12:31

This a gross oversimplification of what it takes to replicate the human brain with AI

The post is assuming we have a model that can accurately replicate the human brain, which we don't.

200T parameter models won't solve that -- you'll still have a high model bias.

This a gross oversimplification of what it takes to replicate the human brain with AI
💬
User Illya Gerasymchuk -

2026-02-18 16:19

Vibe-Coding Vulnerabilities With Claude Code

A decade ago there was a joke that IoT stands for "Internet of Vulnerabilities", given how vulnerable many Internet of Things devices were and how easy it was to exploit them.

I think we will enter an even bigger era of vulnerabilities with vibe-coded systems, especially with agents handling everything from feature development to deployment. You are outsourcing the security of your product/application to a probabilistic mathematical model, which hallucinates by design.

For a sufficiently complex system, it's not a question of IF but of WHEN the LLM will make a security-compromising mistake. Unfortunately, large customer data leaks may become the norm.

If you care about the secrecy of your data, I would advise you be very wary of products developed in such manner. Of course, for many use cases you may also not care about this, and prioritize lower cost or specific features. But you must be aware of the risks.

You are essentially one prompt away from compromising your system and its data. We will probably even have new laws/regulations coming out to address this.

Vibe-Coding Vulnerabilities With Claude Code
User Illya Gerasymchuk -

2026-02-18 16:06

Proxy Model From Polymarket's 15 Minute Bitcoin Price

I found historical datasets for Polymarket's 15 minute up or down Bitcoin price and I think I can use this data to obtain useful signals via a proxy model. I'll start with linear regression to build a prediction model, to see if this transfer learning approach works here.

Yes, it will be overfitting, but for this signal generator it would be by design. The end goal is to find features that improve the random forest's split rules, thus further improving the win rate.

Proxy Model From Polymarket's 15 Minute Bitcoin Price
User Illya Gerasymchuk -

2026-02-18 14:40

Primary Dealers Failures To Settle Implications For Risk Assets

Security settlement failures on the dealer side are a signal of liquidity stress. In short, it signals that either collateral (securities) or USD liquidity are short. Generally, this is bearish for risk assets.

Dealers exercise a key liquidity role in the financial markets microstructure, so a significant stress on their operations will propagate throughout the market.

You can anecdotally visualize this correlation in Bitcoin by noticing that the peaks of failures to receive/deliver by dealers coincide with at least short-term tops for Bitcoin prices.

This weekly set of data is made freely available by Office of Financial Research (OFR), and you can download it CSV or JSON formats. If you are incorporating this data into your machine-learning trading models, beware of the look-ahead bias, as this OFR data is released with about a week of delay.

Primary Dealers Failures To Settle Implications For Risk Assets
User Illya Gerasymchuk -

2026-02-18 14:30

After tweaking the existing set of base learner models, the random-forest driven trading model factory continues to improve

The win rate for predicting Bitcoin's 5-minute price moves (binary) is now approaching 54%. A win rate of ≈56% should suffice to accommodate for transaction costs. Win rates over 60% is where it starts to get interesting.

After tweaking the existing set of base learner models, the random-forest driven trading model factory continues to improve
💬
User Illya Gerasymchuk -

2026-02-18 01:40

If you invested just $100 in Gold in 4000 BCE, today it would be worth $100

This is because USD didn't exist 6000 years ago, so it wouldn't be accepted as means of settlement in Ancient Egypt, thus you wouldn't find a counterparty willing to sell you gold in exchange for US currency.

6000 years is also for how long gold has been used as money. Yet, some still believe that Bitcoin is the new gold and that it will replace gold as money 😄

If you invested just $100 in Gold in 4000 BCE, today it would be worth $100
💬
User Illya Gerasymchuk -

2026-02-17 17:12

Expert optimization is going well, and I'm starting to move towards the alpha in 5-minute Bitcoin price markets

I'm not claiming that the model that I currently have is meaningful (it's NOT!), but it's getting closer to interesting win rate ratios (>55%)

Expert optimization is going well, and I'm starting to move towards the alpha in 5-minute Bitcoin price markets
💬