Cryptocurrency and Algo Trading Where is the Truth

Introduction

This article discusses certain aspects of cryptocurrencies and financial markets. Despite my professional activity as a programmer, the article does not contain any program code. The main focus is on the possibilities of automation in the field of trading and assessing the feasibility of such solutions. The article will be useful for those who are interested in such areas as trading, arbitrage, buying meme tokens, DeFi, as well as programmers who want to automate these processes. In addition, I will consider the use of neural networks in trading and the launch of my own Telegram game in the TON ecosystem.

Target

I want to pass on my experience to others, and also to save you from making wrong decisions and wasting your time. How realistic is it to earn money in the long term using a strategy without relying on luck?

The path to the stock exchange

My journey into the world of cryptocurrencies and financial markets began with exchange trading. However, it was not spot trading or asset holding; like many others, it was futures and trading. My task was to find a working trading algorithm and automate it. Initially, I started automating indicator trading using indicators such as SMA, EMA, LSMA, ATR, RSI, MACD, Stochastic and others. Having selected a dozen of the most popular indicator strategies from the Internet, such as RSI + MACD and the like, I created several sub-accounts on the exchange for parallel execution of bots and launched real trading. The basis was an hourly timeframe and BTC as an asset. I combined indicators, took into account divergence and the funding rate. I ran back tests, and even if the bot showed a positive result on the test data, the results did not match in real conditions.

At a distance of 500 transactions, the bots turned out to be unprofitable. Various approaches were used: stop losses and take profits, their ratio of 1/3 and others. However, it was not possible to find a “magic button” that would guarantee profit. As a result, it became necessary to develop new solutions and strategies.

Automation of manual trading

After conducting extensive research into various aspects of technical analysis and the concept of Smart Money, the process of developing algorithmic trading systems that imitate manual trading strategies of a trader was started. Various algorithms were used in the process, mainly testing trading based on levels and trends. The TradingView api was used for visualization.

Red lines – resistance, Green lines – support

Algo Trading: Visualization of Levels 1

Algo Trading: Visualization of Levels 1

Algo Trading: Visualization of Levels 2

Algo Trading: Visualization of Levels 2

It was also possible to build Fibonacci levels from the base levels (minor, major and 0.618 in the center), they are marked with orange lines on the image.

Algo Trading: Fibonacci Grid

Algo Trading: Fibonacci Grid

If you need to implement such an analyzer with any settings, you can write to me. I will be happy to make such a service.

Experiments were conducted to determine support and resistance levels through horizontal volumes. One approach was to wait for several retests to enter a trade. The direction of the current trend was taken into account. If the expected profit of the trade was small or the commissions exceeded reasonable limits, a decision was made not to open a position. Various aspects were taken into account during development. Ultimately, even if it was possible to maintain a neutral balance in terms of profit, the commissions from the trades led to losses over the long term. BTC, ETH were used for trading. Several months of testing on real data did not yield a positive financial result.

Interim conclusions

Predicting prices based on levels and trends is often unjustified due to the dynamic and volatile nature of the market. It is important to consider that each financial instrument has its own characteristics, and the behavior of large players and market makers can vary significantly depending on their strategies and goals.

During the coding process, the big picture was not yet understood. Attempts were made to create algorithms based on the order book and limit order analysis. In this context, the problem of fictitious limit orders that can be closed at any time arose. This makes it difficult to form hypotheses within scalping. For example, it may seem that a certain level will be broken and the price will continue to rise, but this is not guaranteed: someone may suddenly place a new limit order or sharply change the current one, while you are waiting for a rebound. As a result, a breakout occurs and your trade is closed by a stop order.

Market making

There are market participants known as market makers. These are specific financial market participants who provide liquidity and trading activity, maintaining readiness to enter into transactions with any other trader on market terms. They can be either a department of the exchange or a separate company. The exchange provides them with access to all information about orders, take profits and stop losses. In exchange for this, they maintain liquidity in the instrument, directing the price to the planned targets. They increase their income, as well as the exchange's income, through liquidation in the derivatives markets.

If they did not have access to all the information about orders, take profits and stop losses, their opportunities to earn money would be significantly limited.

Futures

The situation in the futures market is particularly interesting. Let's say you trade futures using leverage, and you always have a liquidation point. Thousands of other traders trading the same instrument act similarly. When orders are placed and there is liquidity in the order book, the market maker's job is to accelerate and maintain trading volumes. With information about all orders, the market maker sees take profits, stop orders, and the liquidation price. He determines where it is most profitable to direct the futures price at a given moment in order to liquidate the positions of longs or shorts. His strategy is largely the opposite of the mass sentiment, aimed at ensuring a larger volume of liquidations.

In other words, the amount of liquidations must exceed the potential profit of the players who took the opposite positions. The higher the leverage, the easier it is for the market maker to achieve this goal. The market maker can be compared to a cheater playing with a marked deck, who is ready to sacrifice the kings to take over your trump cards.

Commissions for market makers cooperating with exchanges are either extremely low or non-existent, which allows them to manage the price with minimal costs. For a market maker, price changes are not a problem, since it is not a real price, but an index or derivative. Therefore, there are no arbitrage risks. Even the spot market on centralized exchanges can hardly be called a market for real assets, since it usually represents custodial data, records in the database of a specific exchange.

Why might the futures price differ from the spot price?

This is due to the ratio of the volume of long and short positions. The predominance of one of these volumes affects the price of the futures. For example, if the volume of long positions is 2 percent higher, then the price of the futures will be higher than the real one by the same 2 percent. Now let's consider how this balance is ensured and who is responsible for maintaining and aligning the price of the futures.

There are two instruments involved here: the market maker and the funding rate.

Funding rate is the fee set by exchanges to maintain the balance between contract prices. In our case, it is the percentage that longs pay to shorts when there are more long positions. This parameter is usually static. The fee is changed and written off three times a day, although the conditions may vary from exchange to exchange. Closing positions before the funding rate is calculated is not advisable, since the fees for opening and closing trades are many times higher than the possible benefit from funding, and you also lose your current position. The only justification for this step is a situation with an extremely high funding rate.

Why is liquidation beneficial?

All profits from liquidations are divided between the exchange and the market maker according to pre-set conditions. So the shorter the time frame over which you try to predict the market and the higher the leverage, the faster you risk losing all the funds on your balance.

For example, if you open a million-dollar long position with 10x leverage on futures, the market maker will immediately record your entry into the market. It will determine your liquidation point, estimate the potential profit from the opposite positions (i.e. shorts), analyze their take profits, and take into account those traders who do not use stop losses. Notably, the probability of market participants observing old positions is lower, and not all traders will have time to close with a profit, which makes manipulation more profitable.

After all the calculations, if it is more profitable to liquidate your position, the market maker will direct the price of the derivative down to your liquidation point, slowly or quickly, but inevitably. Once your position is liquidated or you have locked in a significant loss, the price will most likely return to the spot level, since the market maker is obliged to maintain the price equilibrium.

Market makers use automated bots and constantly improve their algorithms. Although their calculations can sometimes be wrong and lead to losses, the overall profit from liquidations significantly exceeds these losses. Exchanges actively encourage futures trading by offering low commissions and various bonuses, as it brings significant profits at the expense of inexperienced traders.

Obviously, the trader is at a disadvantage compared to the market maker, which makes futures contracts and scalping potentially risky strategies. The exception may be opening long positions with a small leverage. I think it is better to use spot trading, where there are no problems with funding and liquidation. Buy an asset – enjoy and wait for your “Lamba”.

Peculiarities of the spot market

The situation in the spot market is very similar, but here you have no risk of being liquidated, which greatly increases your chances of success. The price fluctuations in this market are much smaller, as there are no liquidations, and margin trading is rarely used due to high commissions. In this situation, the market maker needs to follow a macro strategy.

Imagine that you are actively analyzing the chart using various tools and methods. But think about how many other traders are making the same assumptions? Perhaps most traders expect the price to go in the opposite direction? The market maker analyzes the situation in a similar way, but unlike you, he sees the whole picture. He makes calculations and determines in which direction it is better to move the price in order to activate as many stop losses as possible. Often, buyers and sellers' stop losses are concentrated in the same places. However, it is worth noting that price manipulation is not possible on all assets. On the spot market, there is an arbitrage risk, and the market maker may simply not have enough volume for manipulation. Therefore, in this instrument, your chances of profit are much higher.

Neural networks in trading

After applying algorithms and not getting satisfactory results, it became necessary to review the methodology. It was decided to use neural networks. The concept was based on finding fractals, i.e. repeating events from the past. If such fractals really exist, they can be used to predict future market movements.

BTC was chosen as the study, as it is the largest asset, which, logically, should be less susceptible to manipulation and more predictable. Spot market data was used for training, excluding liquidation noise. Timeframes ranged from hourly and higher.

Education

The input neurons of the model included 200 candles containing all the trading data: opening, closing, maximum, minimum and volume. Thus, the matrix dimension was 5 by 200 input data. At the output, the model generated signals: buy (1), sell (-1) or do not make a deal (0). The signal for opening a deal was the impulse of the price change based on the future period of 5 candles or more. If the price changed by a certain percentage from the current 200 candles used as input data, a decision was made to trade. It is important to check the percentage of price deviation in the opposite direction, which can lead to the activation of a stop order.

First, all the data had to be normalized and filtered to speed up the learning process. Filtering involved rounding all the values ​​to a certain multiple, which reduced noise. Smoothing methods such as the moving average (SMA) could also be used.

In our case, all values ​​were rounded to the nearest multiple of 5:

  • 30161 -> 30160

  • 35166 -> 35165

  • 31348 -> 31345

After rounding, normalization was performed: the array of closing prices was reduced to the range from 0.1 to 0.9. Next, based on the closing prices, we normalize the remaining data. It is important to perform normalization correctly, with binding. The problem was that, for example, the maximum values ​​relative to the normalization of closing prices could be greater than 0.9, for example, 0.91. Because of this, normalizing the data without binding to closing prices would be incorrect.

The model was trained on 10,000 candles, which is equivalent to more than a year of trading for the hourly timeframe. I consider this a sufficient period, given the volatility of the market and trading strategies. The model used LSTM neurons with long-term memory. These neurons required longer training, but with additional training they are more resistant to noise and remember previous patterns longer.

Visualization of learning

Neural Networks: Visualizing Trade Entry

Neural Networks: Visualizing Trade Entry

The example demonstrates entering a long position when the output neuron is equal to 1.

  • Yellow line is the future of 10 candles.

  • The blue line is the take profit. If the price goes beyond the line during the position, the output neuron is 1 (for long) or -1 (for short).

  • The pink line is the stop loss. If the price crosses this line, the output neuron will be 0.

  • Green and red lines are the maximum and minimum of future candles for clarity.

  • The black line is the entry price.

The ratio of take profit to stop loss is ⅓. The same for shorts, but in the opposite direction. If the growth or decline does not reach the expected take profit in 10 future candles, then we do not enter the trade.

How to properly conduct tests that simulate trading?

We receive 20,000 hourly candles at once via the API. We use the first 10,000 candles to train the neural network. The total amount of trades is approximately 800, which is 8%. So this is the sum of the output values ​​of the neurons that gave a result of 1 and -1. The ratio of long to short positions is about 55% in favor of longs. This shows that the model is trained to identify long and short positions in approximately equal proportions.

When testing, take profits and stop losses must be set at the same percentage as in the training model. By opening a position, we evaluate the efficiency of the neural network. A position can only be opened once, and until its result is verified, opening a new position is not allowed. It is also allowed to close a position if there is a significant deviation from the probabilistic outcome, for example, if the output value is less than 0.2 for a long.

Testing

Backtesting performed on the data used to train the model shows a performance in the range of 90%-100% successful trades. This indicates that the model works very well. Usually, if the output neuron exceeded the limit of more than 0.7 or less than -0.7, it was a signal to enter. Now let's check on the remaining 10,000 – 20,000 candles, our future data.

Bottom line: No matter how I train and test, we get the same 50% again. It turns out that the neural network is good at identifying the beginning of impulses, but cannot predict which way the reversal will take place. The image shows an example of forecasting in real trading conditions.

Neural Networks: Visualizing Trade Entry

Neural Networks: Visualizing Trade Entry

Thus, it can be concluded that it is advisable to try to predict impulses or lateral movements.

Predicting sideways movements – can be used to run grid bots or to create pools.

Impulse – can be used to assess risks or to apply option hedging.

Subsequently, I still managed to achieve 60% successful trades in test conditions. However, there is no guarantee that this approach will work in the future. For anyone interested in observing these processes in real time, I invite you to join my bot at the following link: https://t.me/BTCBrainThe bot trades in real time and provides a full history of transactions for the entire period of its activity.

Interestingly, when we train on daily and hourly timeframes, the error results on daily data are 4 times better, indicating a higher probability of coincidences on a larger timeframe and the presence of more noise on the hourly one. When training on other assets, the results also become worse, sometimes tens of times, and we are not talking about memtokens here, but about the top 10. For example, if we compare BTC and ETH on the same timeframes, they differ by more than 2 times, indicating fewer repeating past patterns in Ethereum compared to Bitcoin.

Technical analysis not working?

It cannot be said that technical analysis is ineffective, since its theory is based on the principles of supply and demand. It allows us to understand the interest in the current level, see the zones of support and resistance for further growth. The main problem is that it is impossible to accurately predict who and when will decide to buy or sell, since expectations may not coincide with our offers.

To clarify, I repeat: indicators are not able to predict the future and do not provide a balance of probabilities. However, they are excellent at reflecting past events. Technical analysis, whatever it may be, only indicates possible zones of future attraction and nothing more. It is difficult to operate with probabilities in this context, since it is impossible to know the intentions of other market participants. The exchange, together with the market maker, always remain the winner, since they have access to data on your actions.

Summary

Those who play futures often end up on the losing side. Trying to predict market movements, play on a breakout or expect a rebound in this context is pointless. Market makers' algorithms will always work against the majority of participants. Some will win, some will lose, but the overall outcome will be unfavorable for most. In the face of such risks, it is recommended to limit your trading to spot markets. However, even in this case, everything is subject to chance, because sudden news can change the situation. Constant monitoring of news, as well as the use of stop losses and take profits, are necessary. Consider whether you need such risks. Even a regular index often outperforms hedge funds with their analysts and traders. Success stories are usually based on great luck and often end in failure.

In the area of ​​advertising educational materials on trading, large exchange platforms are often behind the distribution. So-called traders, who in fact earn not on the market, but on the sale of books and courses, are also involved in this. It is profitable for exchanges to promote their products, especially futures, so such “pseudo-traders” receive significant commissions from their affiliates.

The only effective way to do research, in my opinion, is to combine fundamental and technical analysis. What I mean is to make assumptions based on known data about the product and test them using technical analysis. First, we study all available information about the project: round times, asset unlock dates, tokenomics, news, and macroeconomic data. Then we compare them with the results of technical analysis and formulate hypotheses based on the principles of supply and demand.

Alternative ways to earn money

It seemed time to leave these thoughts, but the idea of ​​”Lamba” still did not leave me. As usual, I developed several new concepts.

One of them was to connect to a dozen major exchanges via web sockets and get real-time price changes. If a price change occurs on one exchange, it should cause a similar price movement on other exchanges. This behavior is driven by inter-exchange arbitrage, which is aimed at maintaining price uniformity.

In practice, it turns out that the connection between arbitrage and price alignment is not so obvious. For example, it may happen that price changes on one exchange will lead to adjustments on others, but this does not necessarily happen. In some cases, the price may stabilize within one exchange, without affecting others. It is impossible to determine probabilistically how and where exactly the reaction will occur. However, it can be said that such a reaction does take place and occurs quite quickly, within one minute.

DEX CEX Arbitrage

The question of whether assets can be arbitraged on blockchains and centralized exchanges is an interesting area of ​​research. The study began with an analysis of trading operations on the decentralized exchanges Radium and Ocra, which operate on the Solana network. The process of working with the blockchain RPC server API and conducting transactions in pools turned out to be complex and time-consuming. It is important to consider the pool size, gas costs, as well as fees and slippage.

Based on the results of the experiment, the arbitrage strategy worked. The bot had to monitor arbitrage opportunities for a long time from 5 to 10 hours per transaction, continuously tracking and analyzing each transaction in two pools on different exchanges. As a result, the amount earned was insignificant, since the spread was small. Increasing the volume of the transaction is an additional problem, since it can lead to significant slippage and a strong change in price, which ultimately did not allow for earnings.

The reasons for the low efficiency of arbitrage in this context are that many exchanges and third-party services already have systems that minimize or eliminate arbitrage situations. It is very difficult to compete with such systems. For more efficient arbitrage, it is recommended to have your own node in the blockchain, since transaction speed is critical, and public servers have traffic restrictions.

Overall, the results showed that server costs can significantly exceed potential profits. Therefore, I would recommend carefully evaluating the pool size and possible slippage to avoid losses.

Arbitrage on centralized exchanges

It is almost impossible to find a sustainable arbitrage situation on highly liquid assets, as such opportunities usually exist only for a very short period of time and are quickly eliminated. The time interval required to withdraw funds from one exchange and credit them to another is at least several minutes. During this time, the probability of the spread disappearing is quite high, which makes attempts to make a profit through arbitrage in such conditions unlikely.

In the case of assets with low liquidity, where market makers are either absent or present in limited numbers, the market order book may be half empty, which creates a sad situation and leads to a significant difference between the ask and bid prices. In such situations, even if the spread is, for example, 3%, the price movement may be so significant that it will lead to losses, or your limit order risks disappearing into oblivion.

If you have not yet lost interest in my research and search for that very “Lamba”, I suggest you continue studying.

Earnings on fundraising

There are two main approaches to making money from fundraising.

A working strategy

The basic principle of the strategy is to use a delta-neutral approach. If there is an excess of longs over shorts, then the longs pay interest to the shorts.

To implement this strategy, you need to: Buy an asset on the spot market for half of the deposit. Use the remaining half of the deposit to open a short position without leverage on the futures. Since the strategy is delta-neutral, losses are limited only by commission costs. The result of the strategy is receiving a small percentage three times a day, which is paid by longs.

For example, this strategy can be applied to BTC.

https://www.coinglass.com/ru/currencies/BTC

Bitcoin is often held long for most of the year. The profit from such a strategy can be comparable to or even greater than the income from renting out an apartment. However, despite the potential profit, investing in crypto assets may be subject to various unforeseen risks, unlike the more stable income from real estate.

Earnings on calculation of the financing rate

Changing the funding rate is often accompanied by sharp price fluctuations, especially at high funding percentages. However, in practice, such jumps do not always occur, which makes this method less reliable for making a profit.

This is because the ratio between longs and shorts can vary significantly. For example, if there are 4% more longs than shorts, the futures price will be higher. However, at the time the funding rate is recalculated, this ratio may be completely different. Therefore, the funding rate reflects the ratio at the time of calculation, not at the current time. To determine the funding rate, check the ratio of the spot price to the futures price.

The main players using this strategy are automated trading systems and market makers. Their algorithms open new orders and close existing ones to minimize losses associated with funding.

Wallet tracking

In the blockchain, all transactions are visible, which makes it easy to monitor specific wallets and copy their token buying and selling operations. There is no need to sell tokens at the same time as the wallet being monitored; for example, you can sell when you reach a profit of 20%.

Automating the process of buying and selling tokens faces a number of problems, such as pools closing or decreasing liquidity. Moreover, if a smart contract is editable, it can be changed at any time. As a result, the price of the token may increase, but its sale will become impossible. Such tokens are often created for the purpose of quick profit and subsequent launch of a new project, so it is important to check smart contracts for the possibility of changes.

As for the token growth by 20%, you simply won’t see it, and the risk that the token will be a scam is much higher. In my testing, 30% of tokens showed growth, and the rest fell sharply in price, despite careful selection of wallets with large volumes and a positive history. In the end, this strategy turned out to be ineffective.

If you manually check the DeFi contracts that the wallet you are monitoring participates in, analyze the token in detail, study the distribution of assets among holders, think and make informed decisions, then this approach still makes sense. However, it is not recommended to use automation in this case.

A little bit about frontrunners

Frontrunners, or sandwich bots, operate on mempool networks, constantly monitoring transactions that can significantly affect the price of an asset. Once they detect such a transaction, they try to get ahead of its execution by increasing gas fees to prioritize the execution of their order. However, such manipulations are associated with high risks and difficulties. This strategy requires precise timing and also involves competition with other frontrunners. The implementation of this approach is extremely complex and requires a deep understanding of the network mechanism and algorithms.

Personally, I have not done frontrunning because I understand all the difficulties involved. However, it can be useful to know about such aspects. One way to protect yourself from frontrunners is to set a minimum slippage per trade, which helps reduce the risks associated with this practice.

Crypto startup in the TON network

You are probably already familiar with the successes of Notcoin, Hamsterkombat and the development of the TON ecosystem. In this context, the idea of ​​creating a similar project in Telegram, running on the blockchain and having game dynamics, arose.

The classic children's game “Rock, Paper, Scissors” was taken as a basis. Without going into details, I will describe the basic mechanics and results.

Custodial Game Balance: Withdrawal and deposit of funds is carried out via blockchain.

Acquiring for convenient deposits: Acquiring is connected, automatically converting rubles into TON to the game balance.

The game's main source of income: A 4% commission is withheld from each game played by all users.

Initial balance of new players: Each new player initially receives TON on their balance for test games.

Bonus system to keep the interest going: Players can receive bonuses twice a day, however, once a certain balance is reached, the bonus becomes unavailable.

Referral system: Generate links to invite new players. Users receive a reward for the referral's transition.

Conducting raffles: The player with the maximum number of referrals wins the draw. Repeated participation for winners is excluded.

Rewards for specific actions: Rewards are given for playing games, replenishing the balance by a certain amount, the first deposit or withdrawal of funds, as well as for attracting a certain number of referrals.

Withdrawal limit: A withdrawal limit has been set to prevent small bonuses from being withdrawn.

Ensuring transparency and fairness of the gaming process: All players can see their opponents.

“Party” function: Allows you to play with specific users.

Chat support: Sending notifications about withdrawal of user funds, which encourages the activity of participants.

Multilingual support: Implemented English language support for audiences from different countries.

There are currently over 5,000 registered users in the game. Replenishments come mostly from outside Russia, which was unexpected. The game functions continuously, and user activity remains. You can test and evaluate the game yourself. I would be grateful if you top up your balance with a symbolic amount and try to play.

Bottom line: I distributed cryptocurrencies ten times the amount I received, but the experience was valuable. I plan to return to promoting the project in the future, as the game turned out to be interesting and quite easy to use, like a regular chat.

Link to the game: https://t.me/rocksScissorBot

Decentralized Finance (DeFi)

Earning opportunities without the risk of price changes

DeFi is currently the only area where I have managed to achieve stable profits. Many projects offer attractive interest rates for providing liquidity in the form of stablecoins.

A stablecoin is a token whose price risk is minimal because it is tied to a specific asset and has collateral, making it an index analogue. The main risk in this area is related to possible hacking of smart contracts or fraudulent actions on the part of the platform. For providing liquidity, you can receive a reward in the form of the same stablecoins or in other tokens, which can then be exchanged.

When providing liquidity in exchange for stablecoins, you usually receive NFTs or platform tokens as collateral, confirming your right to receive all rewards and return of liquidity. Currently, with the right approach, you can make a profit of up to 40% per annum on stablecoins.

There are many mechanisms for earning in the DeFi sphere, including liquidity pools, rewards, farming, staking, lending. In this article, I will not dwell on each of them in detail, since this is a vast topic. I can only note that I managed to get more than 50% profit on the deposit. At the same time, I used more risky strategies and, in addition, favorable market development contributed to my success.

For those who want to dive deeper into the world of DeFi, I recommend the channel Crypto Insidewhich I have personally verified and can attest to its veracity. However, always do your own research.

You can contact me via Telegram: @libriant (Vlad Gorbachev).

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *