Skip to content

Commit

Permalink
better README and CONTRIBUTING
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Apr 5, 2014
1 parent dfc7bd0 commit 758f0b5
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 38 deletions.
59 changes: 59 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Contributing

Pull Requests are welcome!

### Setup

~~~bash
git clone git@github.com:hstove/rbtc_arbitrage.git
cd rbtc_arbitrage
bundle install
~~~

To automatically run tests as you code, run `guard`.

### Adding an exchange

Create a new file called `lib/rbtc_arbitrage/clients/[exchange]_client.rb`. If the exchange is Bitstamp, the file will be `bitstamp_client.rb`.

Copy and paste this [template client](https://github.com/hstove/rbtc_arbitrage/blob/master/lib/rbtc_arbitrage/clients/client.rb.example) into your new file and replace class ExchangeClient with your exchange name. For Bitstamp, this would be **BitstampClient**.

Go through each method and implement it. You should use an already built and tested Ruby library for calling API methods. This part requires some programming and Ruby knowledge, so I won't go too into details about how to implement these methods. Feel free to look at the [other clients](https://github.com/hstove/rbtc_arbitrage/tree/master/lib/rbtc_arbitrage/clients) to see how they're done.

**Testing**

Once you've done that, create a new spec file in [spec/clients/](https://github.com/hstove/rbtc_arbitrage/tree/master/spec/clients) for your new trader. If you're a 'test first' type of developer like me, you might want to finish this step first.

While you're writing code, run guard in your terminal. This will run tests automatically as you edit code.

To test out your client, you'll first need to run `git add .`. You only need to do this one time after creating new files.

Then to test the new exchange in the command line, run rake install and then whatever command you'd like, such as:

~~~
rbtc --buyer mynewexchange
~~~

You'll need to re-run `rake install` anytime you make changes to your code and want to test the command line again.

### Submitting

When you're confident that your new exchange is fully functional, you just need to [submit a pull request](https://help.github.com/articles/using-pull-requests).

First, visit [rbtc_arbtirage](https://github.com/hstove/rbtc_arbitrage) and click the 'fork' button in the top-right. This will clone the repository in a new one under your account.

Then locate the ssh clone url on the right-hand side of your new repository. Copy that url, and in your terminal, run:

`git remote add github [url-you-just-copied]`

Then, push to that repository.

~~~
git add .
git commit -m 'added mynewexchange'
git push github master
~~~

Then go back to your repository on github. You should see a button that says 'Compare and pull request'. Click that button and enter a few details about your new code, then submit the pull request.

Your contributions are extremely thanked.
89 changes: 51 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
# RbtcArbitrage

A Ruby gem for executing arbitrage between the MtGox and Bitstamp bitcoin exchanges.
A Ruby gem for executing arbitrage between different Bitcoin exchanges. Supports:

- Bitstamp
- CampBX
- BTC-E
- Coinbase
- ~~MtGox~~ (deprecated)

## Meta

Please contribute! There are always new exchanges that could be easily supported.
Check out the [contribution guidelines](https://github.com/hstove/rbtc_arbitrage/blob/master/CONTRIBUTING.md)
for instructions. Earn Bitcoin for every commit:

[![tip for next commit](http://tip4commit.com/projects/698.svg)](http://tip4commit.com/projects/698)

[Explanation of bitcoin arbitrage](http://hankstoever.com/posts/13-Everything-you-need-to-know-about-Bitcoin-arbitrage)

[Why I open sourced a bitcoin arbitrate bot](http://hankstoever.com/posts/2-Why-I-open-sourced-a-bitcoin-arbitrage-bot)

I'm also creating a course on [creating your own bitcoin arbitrage bot](https://www.uludum.org/funds/2)

[CHANGELOG](https://github.com/hstove/rbtc_arbitrage/releases).

Donations accepted: **16BMcqf93eEpb2aWgMkJCSQQH85WzrpbdZ**

[![Build Status](https://travis-ci.org/hstove/rbtc_arbitrage.png?branch=master)](https://travis-ci.org/hstove/rbtc_arbitrage)
Expand All @@ -28,61 +42,60 @@ 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
2. MTGOX_ADDRESS
2. BITSTAMP_KEY
2. BITSTAMP_SECRET
3. BITSTAMP_ADDRESS
4. BITSTAMP_CLIENT_ID

- **Live**: whether you want to actually execute trades. See the 'Environment
Variable' section for the required keys.
- **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`
- **Buyer**: The exchange you'd like to buy bitcoins from during arbitrage. Default is `bitstamp`
- **Seller**: The exchange you'd like to sell bitcoins from during arbitrage. Default is `campbx`

Valid exchanges for the `--buyer` and `--seller` option are `bitstamp`, `campbx`,
`btce`,and `coinbase`.

#### Examples

~~~
$ rbtc --live --cutoff 4
$ rbtc --cutoff 0.5
$ rbtc --cutoff 3 --volume 0.05
$ rbtc --seller bitstamp --buyer mtgox
$ rbtc --seller bitstamp --buyer campbx
$ 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%)
~~~
I, [APR 5 2014 2:59:02 PM -0700#35172] INFO -- : Fetching exchange rates
I, [APR 5 2014 2:59:13 PM -0700#35172] INFO -- : Bitstamp: $455.51
I, [APR 5 2014 2:59:13 PM -0700#35172] INFO -- : Campbx: $446.27
I, [APR 5 2014 2:59:13 PM -0700#35172] INFO -- : buying 0.01 btc at Bitstamp for $4.58
I, [APR 5 2014 2:59:13 PM -0700#35172] INFO -- : selling 0.01 btc at Campbx for $4.44
I, [APR 5 2014 2:59:13 PM -0700#35172] INFO -- : profit: $-0.15 (-3.2%) is below cutoff of 2%.
~~~

### Environment Variables

## Changelog
You will need to configure the following environment variables
to trade with real accounts.

See [releases](https://github.com/hstove/rbtc_arbitrage/releases).
##### Bitstamp

## Contributing
* BITSTAMP_KEY
* BITSTAMP_SECRET
* BITSTAMP_ADDRESS
* BITSTAMP_CLIENT_ID

### Pull Requests are welcome!
##### CampBX

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
- CAMPBX_KEY
- CAMPBX_SECRET

## Adding an exchange
##### BTC-E

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](https://github.com/hstove/rbtc_arbitrage/blob/master/lib/rbtc_arbitrage/clients/mtgox_client.rb). You'll need to provide custom implementations of the following methods:
* BTCE_KEY
* BTCE_SECRET
* BTCE_ADDRESS

- `validate_env`
- `balance`
- `price`
- `trade`
- `exchange`
- `transfer`
##### Coinbase

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](https://github.com/hstove/rbtc_arbitrage/blob/master/spec/clients/mtgox_client_spec.rb) and change it to test your client.
* COINBASE_KEY

0 comments on commit 758f0b5

Please sign in to comment.