maxme / bitcoin-arbitrage

Bitcoin arbitrage - opportunity detector
MIT License
2.43k stars 856 forks source link

Profit calculation problem #39

Closed emiberea closed 10 years ago

emiberea commented 10 years ago

Hi, I hope that it is ok if I ask here. I can not understand how the profit is calculated. When I run the application I get the following output: 2014-08-01 15:39:52,269 [INFO] profit: 93.237316 USD with volume: 10.000000 BTC - buy at 592.9140 (BtceUSD) sell at 593.3315 (KrakenEUR) ~1.57%

I can't see how the profit of $93.23 has been calculated as 10 multiplied by $592.9140 is 5929 and then 10 multiplied by the sell price at 593.3315 = $5933 meaning profit of $4 not a profit of $93.23, perhaps im missing something, would it be possible to explain, maybe even i could see the formula you use to calculate the arbitrage profit opportunity (so i can also see if it takes exchange fee's into account). That would be a huge help, and if im totally missing something i apologise in advance.

Thanks.

maxme commented 10 years ago

The log format is kind of confusing I agree but buy at X and sell at Y are used for manual trading, and they refers to the maximum buy price and minimum sell price.

Ref: https://github.com/maxme/bitcoin-arbitrage/issues/13

DorsiaSucks commented 10 years ago

Sorry im still very confused even after reading the other posts......are the prices listed in the logs not the actual prices that the Bot will buy at?? Are they the reccomended prices for me to manually buy at or Does the bot buy at better prices than whats listed in the logs and does in fact make the profits listed in the logs?

2014-08-01 15:39:52,269 [INFO] profit: 93.237316 USD with volume: 10.000000 BTC - buy at 592.9140 (BtceUSD) sell at 593.3315 (KrakenEUR) ~1.57% 2014-08-01 15:39:52,377 [INFO] profit: 31.343052 USD with volume: 5.516387 BTC - buy at 589.5000 (BtceUSD) sell at 589.5078 (PaymiumEUR) ~0.96% 2014-08-01 15:39:52,486 [INFO] profit: 29.919614 USD with volume: 10.000000 BTC - buy at 591.0380 (BtceUSD) sell at 591.0500 (BitfinexUSD) ~0.51% 2014-08-01 15:39:52,602 [INFO] profit: 52.259730 USD with volume: 9.692490 BTC - buy at 591.8500 (BtceUSD) sell at 591.8568 (Bitcoin24EUR) ~0.91% 2014-08-01 15:39:53,488 [INFO] profit: 52.942016 USD with volume: 10.000000 BTC - buy at 592.9140 (BtceUSD) sell at 592.9900 (BitstampUSD) ~0.89% 2014-08-01 15:39:53,489 [INFO] profit: 0.000754 USD with volume: 0.001100 BTC - buy at 599.4501 (KrakenEUR) sell at 599.5502 (PaymiumEUR) ~0.11% 2014-08-01 15:39:53,489 [INFO] profit: 0.000462 USD with volume: 0.001100 BTC - buy at 599.1300 (CampBXUSD) sell at 599.5502 (PaymiumEUR) ~0.07% 2014-08-01 15:39:53,537 [INFO] profit: 46.276497 USD with volume: 10.000000 BTC - buy at 596.6600 (BitfinexUSD) sell at 596.7817 (KrakenEUR) ~0.78% 2014-08-01 15:39:53,540 [INFO] profit: 4.380523 USD with volume: 5.002918 BTC - buy at 593.5000 (BitfinexUSD) sell at 593.5548 (PaymiumEUR) ~0.15% 2014-08-01 15:39:53,544 [INFO] profit: 10.110073 USD with volume: 5.793260 BTC - buy at 593.0400 (BitfinexUSD) sell at 593.1113 (Bitcoin24EUR) ~0.29% 2014-08-01 15:39:53,545 [INFO] profit: 5.981198 USD with volume: 10.000000 BTC - buy at 593.0000 (BitfinexUSD) sell at 593.0100 (BitstampUSD) ~0.10% 2014-08-01 15:39:53,545 [INFO] profit: 0.017143 USD with volume: 0.015000 BTC - buy at 596.4589 (KrakenUSD) sell at 596.4678 (KrakenEUR) ~0.19% 2014-08-01 15:39:53,546 [INFO] profit: 0.003400 USD with volume: 0.001100 BTC - buy at 597.9926 (KrakenUSD) sell at 599.5502 (PaymiumEUR) ~0.52% 2014-08-01 15:39:53,546 [INFO] profit: 0.001040 USD with volume: 0.015000 BTC - buy at 596.4589 (KrakenUSD) sell at 596.5282 (Bitcoin24EUR) ~0.01% 2014-08-01 15:39:53,552 [INFO] profit: 24.408122 USD with volume: 10.000000 BTC - buy at 596.5100 (BitstampUSD) sell at 596.7817 (KrakenEUR) ~0.41% 2014-08-01 15:39:53,555 [INFO] profit: 0.006105 USD with volume: 0.001100 BTC - buy at 599.5500 (BitstampUSD) sell at 599.5502 (PaymiumEUR) ~0.93% 2014-08-01 15:39:53,556 [INFO] profit: 4.367645 USD with volume: 3.399178 BTC - buy at 594.0000 (BitstampUSD) sell at 594.5345 (Bitcoin24EUR) ~0.22%

maxme commented 10 years ago

@Aaronman yes the bot will buy/sell at these prices too. The calculated profit comes from the full market depth, not only the max buy and min sell orders, see this example: https://bitcointalk.org/index.php?topic=153661.msg1647793#msg1647793

maxme commented 10 years ago

I think I should remove the buy and sell details from the default log output and add an explicit cli option to avoid any confusion.

DorsiaSucks commented 10 years ago

@maxme sorry im a newbie but trying my best to understand, so in the logs i posted above the bot has returned in excess of $350 arbitrage profit?

maxme commented 10 years ago

so in the logs i posted above the bot has returned in excess of $350 arbitrage profit?

No because arbitraging between 2 markets will move their price up (where you buy) and down (where you sell). So for instance if you execute these orders 2014-08-01 15:39:52,602 [INFO] profit: 52.259730 USD with volume: 9.692490 BTC - buy at 591.8500 (BtceUSD) sell at 591.8568 (Bitcoin24EUR) ~0.91%

You won't be able to execute these: 2014-08-01 15:39:53,488 [INFO] profit: 52.942016 USD with volume: 10.000000 BTC - buy at 592.9140 (BtceUSD) sell at 592.9900 (BitstampUSD) ~0.89%

The bot tries to maximize profits, so in this case it's going to execute the second line first (because 52.94 > 52.25), then it'll wait for update market depths and balances on BtceUSD and Bitcoin24EUR. If update shows there is still an opportunity, it's going to execute new orders (low probability here cause BtceUSD prices will go up).

DorsiaSucks commented 10 years ago

ok got it @maxme , originally i was looking at using the data to create a table to identify and alert me when arbitrage opportunities became available but im guessing its not possible due to the fact it displays limited cli info. I should just use the bot right?

maxme commented 10 years ago

if you don't know what you're doing, don't use the bot. If you want a better view to watch for arbitrage opportunities I encourage you to write your own observer.

See the logging observer which is pretty simple: https://github.com/maxme/bitcoin-arbitrage/blob/master/arbitrage/observers/logger.py

You could use the Emailer or XmppMessager for alerts: https://github.com/maxme/bitcoin-arbitrage/blob/master/arbitrage/observers/emailer.py https://github.com/maxme/bitcoin-arbitrage/blob/master/arbitrage/observers/xmppmessager.py

DorsiaSucks commented 10 years ago

just sent you an email @maxme

many thanks

aaron