Building a Crypto Arbitrage Bot Using Gainium

Hi everyone! I’m trying to build a crypto bot that uses arbitrage opportunities between BTC, ETH, and LTC to generate profits. The bot would monitor price differences between these coins, and only execute swaps when a profitable opportunity arises. The idea is based on simple math, but I could really use help from the community with the technical side of things in Gainium. Here’s the idea along with some calculations.
What the Bot Should Do:

Monitor Real-Time Prices:
The bot will track prices(example) of BTC/ETH, ETH/LTC, and LTC/BTC across exchanges like Binance and KuCoin. It should continuously monitor price movements to detect arbitrage opportunities.

Find Arbitrage Opportunities (Math Behind It):
The idea is to calculate conversion rates between these coins and check if swapping one into another gives more value. Here’s a simplified version of the calculation:

Let’s assume:
    1 BTC = 20 ETH (from the BTC/ETH pair)
    1 ETH = 100 LTC (from the ETH/LTC pair)
    1 BTC = 2100 LTC (from the BTC/LTC pair)

We can set up the following process for the bot to calculate potential profit:
    Start with 1 BTC.
    Convert it to ETH:
    1 BTC×20 ETH/BTC=20 ETH
    1 BTC×20 ETH/BTC=20 ETH
    Convert those 20 ETH into LTC:
    20 ETH×100 LTC/ETH=2000 LTC
    20 ETH×100 LTC/ETH=2000 LTC
    Convert the 2000 LTC back to BTC:
    2000 LTC÷2100 LTC/BTC=0.952BTC
    2000 LTC÷2100 LTC/BTC=0.952BTC

In this example, you lose 0.048 BTC, so the bot would not execute this trade.

But if the prices change to:
    1 BTC = 22 ETH
    1 ETH = 105 LTC
    1 BTC = 2300 LTC

Now, let’s recalculate:
    Start with 1 BTC:
    1 BTC×22 ETH/BTC=22 ETH
    1 BTC×22 ETH/BTC=22 ETH
    Convert 22 ETH into LTC:
    22 ETH×105 LTC/ETH=2310 LTC
    22 ETH×105 LTC/ETH=2310 LTC
    Convert 2310 LTC back to BTC:
    2310 LTC÷2300 LTC/BTC=1.0043BTC
    2310 LTC÷2300 LTC/BTC=1.0043BTC

Here, you’ve gained 0.43% profit. The bot would execute the trade!

Set Profit Margins:
The bot should only execute trades when the profit is above a certain threshold, say 2%. This can be set using a condition like:
If Final BTC−Initial BTC>0.02×Initial BTC, execute trade.
If Final BTC−Initial BTC>0.02×Initial BTC, execute trade.

Automate the Process:
Once the bot identifies a profitable swap based on the calculations, it should automatically execute the trades. I also want to add a stop-loss rule to protect against potential market volatility that could occur during the swap.

My Request:

I understand the math and the concept, but I’m having trouble setting this up in Gainium. Specifically, I need help with:

Writing the rules for these profit calculations between swaps.
Configuring the bot to execute the swaps automatically in Gainium.
Setting up risk management tools like stop-loss to safeguard the strategy.

Has anyone here built something similar or can guide me on how to implement this in Gainium? I’d appreciate any help with examples, strategy templates, or advice on configuring the bot settings. Thank you in advance!

You cannot do this kind of logic with our tools. Sounds more like a rebalancing bot, which we don’t have yet but it was already suggested: Rebalancing bot

Have you considered the fees? I wouldn’t expect any three-currency arbitrage to give you a profit after fees these days.

Oh i thought it would be possible because it would be a nice approach since that method has no fees. thanks again !

i have seen kucoin has no fees on converting coins(just an example)

Don’t be fooled. They claim there are no fees. But if you look at the market price, you will usually, if not always, see that the swap is not at the market price, but usually at a much worse price. In fact, you may end up paying more in hidden fees than you would have paid in the market. Every order has its costs. Even real zero free promotions don’t last forever; and if you miss that point, you end up with losing deals, if the zero fees were the only reason why your strategy was working.

1 Like

Thank you for clarifying this, i thought there were no fees there, that’s why I thought this approach might be good enough. But with fees, it might end up paying more.(there is still a lot to learn).

1 Like

Most of the arbitrage options are now dead as bots and automation have got much more advanced than in 21-22.

Rebalancing bots might be more profitable when BTC price hits bottoms (deep bear market / crypto winters) when you start building a portfolio. Please correct if i am wrong.

Rebalancing bots usually shift funds from the winning to the losing assets, if we want our funds to be spread according to a certain distribution. Maybe it would work if they rebalanced the portfolio according to the market cap like index funds do?

1 Like

Yes, the automation may reduce volatility in next coming cycles and with onset of Spot ETFs the volatility is likely to reduce further. However BTC will continue to rise as most of BTC will be in the custody of big players leaving retail dry. Financial systems will be ruled by BTC owners until some new blockchain tech takes over. We are living in rare times being too early but the pace of cycles will make sure that we are kept out of cash needed to stay in the game. (My personal opinion)

With the introduction of Spot ETFs and increasing institutional control over Bitcoin (BTC), it’s possible we may see reduced volatility in future market cycles. While this might limit the extreme price swings that many traders profit from, it could also mean that rebalancing strategies become more critical for the long-term growth of smaller portfolios. As institutions control more of the supply, retail investors might find it harder to profit from short-term movements.

Some points to consider?

If price fluctuations decrease, we may need to adjust rebalancing thresholds. Smaller movements between BTC, ETH, and LTC might not trigger frequent rebalancing, but having the right threshold could still capitalize on small but steady gains.(with higher fees) :frowning:
As more BTC ends up in the hands of large institutions, would rebalancing between altcoins (like ETH, LTC, or others) offer more opportunities for profit compared to BTC-heavy portfolios?
Also, as mentioned, new blockchain technologies could eventually overtake BTC’s dominance. Should we be prepared to include emerging assets in our rebalancing strategy as potential long-term plays?

Time will show…

Agreed as the debate will continue before some new era of tech reveals itself overshadowing our perceptions of markets now. The big money is big as they keep a watch on whats coming before the herd follows.