# How the arbitrage works? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How the arbitrage works? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

How the arbitrage works, Is transaction fee is included for calculating arbitrage across exchanges, cryptocoincharts seems to render incorrect values,

1. Any other arbitrage available at open source?
2. How to calculate arbitrage?

To answer your first question: I do not know any free, opensource, trusted software that arbitrages for you. It will not generate any money for the developers, and only depletes their source of income.

To calculate the profit in arbitrage you first have to know all the steps:

1. Buy a Bitcoin for \$600 (rate #1) on exchange A (trading fee #1)
2. Send this Bitcoin to exchange B (withdrawal fee #1)
3. Sell this Bitcoin for \$610 (rate #2) on exchange B (trading fee #2)
4. Send \$610 to exchange A (withdrawal fee #2)
5. Have \$610 instead of \$600 => 1.67% profit

Of course you can do this also with different altcoins, which travel faster between the exchanges than money.

As you see, there are 4 different fees that you have to calculate. Trading fees are most of the time a percentage of the volume, but withdrawal fees are most are most of the time fixed. That is also what I am assuming in the following formula:

Bitcoin on exchange B = X = (Start amount / (rate #1) * (1 – trading fee #1)- withdrawal fee #1)

USD on exchange A = Y = X * (rate #2) * (1 – trading fee #2) – withdrawal fee #2

profit = (Y/X – 1)*100 (outcome in %)

I tried to break the equation in pieces so that is more readable. X in the second equation is calculated in the first one. Y is the outcome of the second equation. Profit uses both variables.

The two most important variables are of course the rates. If they are very close to each other (within ~0.5%) there is very little chance to arbitrage. This is because the trading fees are around 0.2%, and you have to trade twice. If the starting amount is big enough, the withdrawal fee is negligible (for example: 0.00050 BTC on Kraken). You can fill in the variables (rate, fees, start amount) yourself to calculate the profit.

*Note: there could be an error in here. I am in no way responsible for any loss of money because of this calculations. I calculated it myself by hand a dozen of times and it is easy for a mistake to slip in. Also remember that the market changes during the transfer of money/bitcoin, and therefor your chance to make money can vanish.

We are here to answer your question about How the arbitrage works? - If you find the proper solution, please don't forgot to share this with your team members.