Investment Stratagies- My trading BOT made 1,440 crypto trades in 1 week
My trading BOT made 1,440 crypto trades in 1 week

I noticed early on there were market inefficiencies in the crypto markets, even within the exchanges. With some simple python code and I was able to confirm that a 4-round trade could produce 5% and sometimes 10% gains even with trading fees in under a second.
This article is not investing advice, I am telling a story of my experiences.
This is called arbitrage: “The simultaneous purchase and sale of equivalent assets or of the same asset in multiple markets in order to exploit a temporary discrepancy in prices.”
This is a typical trade. My software would loop through over possible trade combinations and pick the highest estimated return and make 4 simultaneous trades at once.
Sounds simple and it is, but the mechanics are much more complex.
If you get one thing from this article, realize this is a story of liquidity. It may be crypto, but the laws of economics hold, just as if we are trading cows for sheep for corn back to cows.
Hurdle #1: Performing trades via code.
You’ll need an account on a cryptocurrency exchange that allows computerized trading. This means setting up code to interface with the exchange’s APIs. Given security is paramount all trading is done with an API Key unique to your account. Getting this code to run is not trivial, this would be the first code I would write, get to the point you can make a trade at market price for a trading pair. The exchanges have examples of code.
Hurdle #2: Defining the Trading Pairs.
You can’t trade any coin with any coin. The possible trading pairs are limited. You can trade BTC with any other coin, BUT you can’t trade 2nd tier coins with each other. For example, you can trade ETH or BTC with EOS. But you can’t trade EOS with XTZ. I call the BTC and ETH coins the “Primary” coins and the EOS, XTZ and the hundreds of others as “Secondary” coins. Your arbitrage trade set will always be:
Primary to Secondary -> Secondary to Primary -> Primary to Secondary -> Secondary to Primary.

The above figure illustrates this, the blues are primary, and secondaries are orange.
This greatly limits your trading possibilities. But the exchanges are set up this way for a reason. The exchanges provide a trading market, just like the stock exchanges, and key to providing an exchange is a reasonable expectation a trade will be completed. Trading a minor secondary coin with another secondary coin such as TRB with XYO may leave an open order on the trading floor books for an extended period of time. Consider 25 TRB at 0.00007 BTC is a large TRB order and 1,000 XYO at 0.0000007 BTC is a large order. Just not many people are waiting to make a trade on this trading pair. Consequently, the exchanges will allow you to trade these secondary coins but you have to trade BTC, ETH, USDT or another Primary coin to get there. The stock market exchanges use one currency, such as US Dollars as the currency of exchange, crypto markets have 1,000’s of coins as the currency of exchange. Crypto exchanges are a much more complex trading environment, to both run and trade in.
The arbitrage trading pattern almost always uses BTC or ETH or USDT for the 1st and 3rd trades.
Hurdle #3: Getting real time data.
A real time arbitrage of a global market requires real time data, refreshed every second or better. I did my trading on Coinbase Pro, they have the APIs, the trading volume and the large stable of possible trading coins to make this work. But they don’t like guys pinging their system every second for a complete run down of all trading pairs. The exchanges have data limits, and you’ll quickly reach those limits.
The solution was to first run, on program start a complete table of trading pairs and their exchange rates. Then run a websocket of real time trades and update the trading pair exchange rate table. This kept me under the data limits. This websocket constantly streamed all the trades in real time. Your code just has to listen. The trading pair exchange rate table would only be updated when a new trade occurred on that exchange and streamed out on the websocket. I’d get this code running early on. You’ll realize as you see the trades flying by, some trading pairs are traded with considerably more frequency than others. These are your highly liquid trading pairs.
Hurdle #4: Find the trades and execute.
Having the trading pairs and the trading pairs exchange rates run through all the possibilities and find the best return. Sort on return. Execute.
I put in all 4 trades at once and let them settle out. The trades would execute in different orders depending on liquidity, but usually they would settle out in a couple of seconds. You have to make market orders, forget doing limit orders, you need to grab the moment and make the trade, the market inefficiencies don’t last long, under a second at best. Remember you are not alone. Because you are making market orders, you will NEVER get the trade you found, sometimes you will do better, mostly you will do worse. That’s why after experimenting for weeks, I set the software never to make an arbitrage sequence that had less than 10% initial trading advantage. If I was lucky, I might make 5%, often I’d make .5% and sometimes lose money on the trading sequence.
Market inefficiencies don’t last long.
My software did take trading fees into account when calculating “profit”. The exchanges reward frequent traders with lower fees and this makes a big difference. I didn’t start making reasonably profitable trades till my volume got above $50K in a month. So, for the first week, the trades were lean, profit wise, while I paid higher trading fees.
The bot would cycle through for hours, find a +10% trade and make 5 or more trades in under a second. I’d look away for a minute, glance back and found I traded $1,000s. When you realize you made a couple of $100 in seconds, what a rush.
Because I would make all 4 trades at once, I had to have a pool of money in each possible trading pair. If I was trading 20 pairs, I put money in each coin in the trading pairs. At the end of the day, I had to balance the pools. I would trade everything back in to BTC, note the amount and compare what the previous days BTC amount was. This was my profit / loss. This effort was about increasing my holdings in BTC. It got too difficult to resolve back to USD at the end of every day.
I wrote code to fund the pools at the beginning of a trading period, and to resolve all the funds back to BTC at the end of a trading period. Crypto trading is a 24/7 market, we are not. I would shut down every couple of days and take stock of gains/losses and try adjustments to the program.
In a month of letting my bot run free, the results:
· Made over 5,000 trades,
· I traded over $500K,
· Made somewhere around $500 USD in trading.
· My IRS tax filing was over 340 pages long,
· I paid, $200 to have a company compile my trades into a format the IRS would accept,
· I made more money on BTC appreciation than trading,
· The most popular tax prep software packages, suck at reporting crypto trades,
· The exchange made a lot more money than I did
· I noticed I made money in a rising market (which means rising BTC) and tended to lose money in falling markets. Secondary coins drop like a rock in a falling market but rise slower in a rising market.
What I learned. It all about liquidity. The market inefficiencies are in the trading of the secondary coins, the lesser traded coins. They are less liquid because they are traded less. Being traded less means many times you are basing your trade on a trading pair rate that maybe seconds even minutes old.
What I would improve if I tried this again.
· Code limit trades. Give a market maker some percentage to make the trade, like 0.5%, trade off some profit for a quicker trade on a lesser traded coin.
· Eliminate the most ill-liquid coins from the scan. Realizing this eliminates the most promising potential trades, which I realized, can be rarely executed at the last quoted price.
· Increase the speed of my code, maybe ditch python for Go or Julia.
· Limit trading to rising (BTC) markets.
The big take away.
The greatest market inefficiencies mostly occur with the lesser traded coins, the less liquid coins. You rarely can execute a trade with an ill-liquid coin at the last quoted price. At the beginning of this article I said, this was a story of liquidity. This may the most science-fiction trading markets out there, but they still heed to age old economic laws.
Where am I now with crypto? I realized that the crypto markets rise and fall in unison. I am in BTC, ETH, SOL and to a lesser extent, ADA. I made a killing in SHIBA, in and out in a week. My expectation is 100X return in 10 years.
Post a Comment