RbtcArbitrage

A Ruby gem for executing arbitrage between the MtGox and Bitstamp bitcoin exchanges.

Meta

Explanation of bitcoin arbitrage

Why I open sourced a bitcoin arbitrate bot

I'm also creating a course on creating your own bitcoin arbitrage bot

Donations accepted: 16BMcqf93eEpb2aWgMkJCSQQH85WzrpbdZ

Build Status Coverage Status Code Climate

Installation

Install it yourself as:

$ gem install rbtc_arbitrage

Usage

After installing the gem, simply run rbtc in the command line.

Options

  • Live: whether you want to actually execute trades. You must have configured your API keys and bitcoin addresses through the following environment variables:

    1. MTGOX_KEY
    2. MTGOX_SECRET
    3. MTGOX_ADDRESS
    4. BITSTAMP_KEY
    5. BITSTAMP_SECRET
    6. BITSTAMP_ADDRESS
    7. BITSTAMP_CLIENT_ID
  • Cutoff: the minimum profit percentage required to execute a trade. Defaults to %2.00.

  • Volume: The amount of bitcoins to trade per transaction. Defaults to 0.01 (the minimum transaction size).

  • Buyer: The exchange you'd like to buy bitcoins from during arbitrage. "mtgox" or "bitstamp". Default is bitstamp

  • Seller: The exchange you'd like to sell bitcoins from during arbitrage. "mtgox" or "bitstamp". Default is mtgox

Examples

$ rbtc --live --cutoff 4
$ rbtc --cutoff 0.5
$ rbtc --cutoff 3 --volume 0.05
$ rbtc --seller bitstamp --buyer mtgox
$ rbtc

The output will look like this:

07/08/2013 at 10:41AM
Retrieving market information and balances
Bitstamp: $74.0
MtGox: $76.89
buying 0.01 btc from Bitstamp for $0.74
selling 0.01 btc on MtGox for $0.76
profit: $0.02 (2.77%)

Changelog

See releases.

Contributing

Pull Requests are welcome!

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Adding an exchange

Right now there is support for only MtGox and Bitstamp, but adding support for other exchanges is dead simple. First, you'll need to create a new client in lib/rbtc_arbitrage/clients. Follow the example from the mtgox client. You'll need to provide custom implementations of the following methods:

  • validate_env
  • balance
  • price
  • trade
  • exchange
  • transfer

Make sure that the methods accept the same arguments and return similar objects. At the same time, make sure you copy the mtgox_cient_spec and change it to test your client.