AI Hedge Project: Cryptocurrency Algorithm Trading. part 1

AI Art Inc.
AI Hedge Project
Published in
6 min readAug 27, 2022

Creating a crypto trading AI model using modern data-related tools

Photo by Starline on Freepik

Introduction

Recently Ethereum announces that the. current Ethereum Mainnet will merge with the Beacon Chain proof-of-stake systems. It is a good news for the crypto world as over the past half a year, the crypto currency market suffers from a horrible bearmarket.

Many people join in the cryptocurrency heat and hope to profit from it. There are also technical people who wrote algorithm to trade again the market. When machine learning technology is getting more and more mature, it becomes even more crucial to use it as tool for trading and optimization.

Various techniques or tools such as Kafka, Apache Storm etc. are used to automate the entire process. But it is actually too tedious for an average coder who does not have the luxury of such mature flow and infrastrucutre. So the quality of algorithm is very essential for a successful trading result.

The beginning

Thre are numerous introductory articles and open-source tools to do what is mentioned above. In this series of articles, I’m not going to give tutorial or give code snippet like other articles. Instead, I’m going to present what AI Art has done for the past 2 years plus of continuously research result.

The AI Hedge Project was started near the end of 2019 when COVID-19 burst out unexpectedly. Quicky many people where out of job and many lives were lost all around the world. But ironically, stock market bound up after a sharp doward spiral and continued to trend up for a long time. Many governments around the world kept pumping money into not only the stock market but to the general market.

I also joined in the heat and learned a lot from that. Since then, I was wondering if there is a way to build a bot that can continuously calculating and monitoring the buy and sell opportunity in the cryptocurrency market.

So that was the beginning of AI Hedge Project.

The Math, Tools and Modeling

There is Chinese idiom “If a workman wishes to do a good job, he must first sharpen his tools.”. So many people look around and find good tools that can help them to do the job. Not surprising, deep machine learning, came out top from the list of tools that I need.

Machines learning include things such as CNN, RNN, Reinforcement learning, matrix manipulation, Python programming, PyTorch programming, Pandas, Numpy, C++ and the list goes on. So it is definitely not for the faint-hearted. Not only that, if you do not understand the math involved and how to read research papers, then there is no way to proceed any further. Matrix manipulation, Markov Chain, probability, advance calculus like partial differential equation etc. are your friends along your way to modeling. If you want to go ahead by using arbitrary model such as CNN or RNN, I don’t think it will get you too far. What you may get would be countless hours of CPU or GPU computation and burn a hole in your pocket.

No matter what you do, designing the right model is the key to success.

Read, learn, code and then iterate again.

Long, short or hold?

fig1: Initial test, not that great, but a good start. copyright of AI Art

If you read, learn and code enough, you can start to get something like in fig1.

It is a typical graph you will get when you have your signal, position, amount you buy and the total asset and cash you end up with. The result was not very impressive from the beginning, because any average person can argue with you that the result is no better than ‘buy and hold’ strategy. However, when the price goes down,we also profit by shorting our ETH.

Let’s us improve on our model.

Frequency Processing? Signal Processing?

If you graduated from an electronic/electrical major, then in school you must have learned signal processing. According to Wiki, Signal processing is an electrical engineering subfield that focuses on analyzing, modifying, and synthesizing signals such as sound, images, and scientific measurements.

What does that have to do with us?

Don’t you think stock market price looks like a bunch of signal coming continuously from a source?

Yes, so not only you have to learn your math, you also have to learn signal processing from eletrical engineering.

fig2 simple frequency processing illustration. copyright of AI ART

From fig2, the first row is the orginal frequency signal. The third row is the frequency distribution, and the second row is the modified frequency distribution. We process our pricing data before putting them into our AI training to eliminate data that we do not want. From the graph, it means the occurrence of certain frequency (second row) is lower than the actual data (third row). If you think your data is too noisy, this is how you may do to do your analysis.

Our Backtesting and SimulationEnvironment

Seeing is believing. There are many backtesting tools and simulation software in the market, but we decide to build our own because it is not too troublesome and it fits what we are doing better.

Fig3 and fig4 are actual running of our backtesting tool. Although it looks primitive (we do have a graphical interface) but this can be videoed to show what we were doing.

You can see that the bot decide to buy/sell/hold when the data streams come in. At the end, a performance result is give if it is at backtesting mode. This bot is also what we use in the actual simulation in live data (production mode).

fig3. a screen shot sample of our backtesting + simulation bot. copyright of AI ART
fig4. performance result show at the end of a simulation. copyright of AI ART

Significant better result from our first v1 model

After numerous training and simulation test. Brunhild_xxx_strategy is our first model that successfully show very good result. The reason among all of my other better results is that this section of price has a significant downward trend followed by an upward trend and then it goes down again.

fig5 better performance of Brunhild_xxx_strategy. Copyright of AI ART

What it means is that no matter it is going up trend or down trend, this bot can perform significantly better (419.24%) than buy and hold strategy.

Many people show images of their strategy out-perform the market in an upward trend. There is no denial that what they do it awesome, but resisting a downtrend, in my point of view, is very crucial to maintain your investment portfolio.

Don’t you think so?

Conclusion

This article is one of our series to show what we did for the past 2–3 years of research. They will be released one by one to show the progress and result of our research.

There are numerous research papers that we refer to, but I’m not going to bore you here, because you are not a PhD candidate in pursuit of a degree.

By AI Hedge Project team

--

--

AI Art Inc.
AI Hedge Project

Striving for greatness and enlightenment. Full-time Blockchain and business model architect.