Git Product home page Git Product logo

rbtc_arbitrage's Introduction

RbtcArbitrage

A Ruby gem for executing arbitrage between different Bitcoin exchanges. Supports:

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

Meta

Please contribute with code! There are always new exchanges that could be easily supported. Check out the contribution guidelines for instructions. Earn Bitcoin for every commit:

tip for next commit

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. 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. 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 campbx
	$ rbtc

The output will look like this:

I, [APR  6 2014  7:14:33 AM -0700#52261]  INFO -- : Fetching exchange rates
I, [APR  6 2014  7:14:37 AM -0700#52261]  INFO -- : Bitstamp (Ask): $455.0
I, [APR  6 2014  7:14:37 AM -0700#52261]  INFO -- : Campbx (Bid): $455.05
I, [APR  6 2014  7:14:37 AM -0700#52261]  INFO -- : buying 0.01 btc at Bitstamp for $4.58
I, [APR  6 2014  7:14:37 AM -0700#52261]  INFO -- : selling 0.01 btc at Campbx for $4.52
I, [APR  6 2014  7:14:37 AM -0700#52261]  INFO -- : profit: $-0.05 (-1.18%) is below cutoff of 2%.

Environment Variables

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

BitstampClient
  • BITSTAMP_KEY
  • BITSTAMP_SECRET
  • BITSTAMP_ADDRESS
  • BITSTAMP_CLIENT_ID
CampbxClient
  • CAMPBX_KEY
  • CAMPBX_SECRET
BtceClient
  • BTCE_KEY
  • BTCE_SECRET
  • BTCE_ADDRESS
CoinbaseClient
  • COINBASE_KEY
  • COINBASE_SECRET

Exchange Adapters

rbtc_arbtitrage also exposes a handy interface for interacting with different bitcoin clients. For example:

client = RbtcArbitrage::Clients::BitstampClient.new
client.price :buy
 => 462.88
client.price :sell
 => 462.88
client.balance
 => [0.0079, 1.41] # [btc, usd]
client.options[:volume] = 0.5 # default is 0.01
# client.trade uses market price
client.trade :buy
client.trade :sell
client.address # for deposits
 => "16rQQYMTTKb9cnnSX3xYkN4hcKXoYcXXXX"
# send btc to an address
coinbase = RbtcArbitrage::Clients::CoinbaseClient.new
client.transfer coinbase.address

License

Available here

rbtc_arbitrage's People

Contributors

benhc123 avatar blrhc avatar fanquake avatar hstove avatar jordoh avatar ukd1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rbtc_arbitrage's Issues

Doesn't install correctly

I tried this on 3 different machines (Linux server, Windows machine, Mac laptop), and they all got the same thing; the dependencies don't get installed properly. Since this happens on every machine I tested this on, I'm pretty sure you messed up.

Error is something like:
fatal: not a git repository
could not find minitest-4.7.5, etc.

If I install minitest 4.7.5 manually it'll just come up with something else, and something else, and something else until I just get tired and give up.

Still in development?

Hey, I'd be interested in helping develop if the project is still going. I'm working on something similar for a research project.

Environment Variables

Some of us would like to know where to put in the environmental variables where it says:


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

  • MTGOX_KEY
  • MTGOX_SECRET
  • MTGOX_ADDRESS
  • BITSTAMP_KEY
  • BITSTAMP_SECRET
  • BITSTAMP_ADDRESS

Thanks

Not enough funds …?!

I'm running this as a heroku app as you wrote in your course.

Everything works fine until the bot finds a profitable trade. It exits with a security error "Not enough funds".

Can't be. I'm using bitstamp and btc-e. Both are funded with dollars and bitcoins. So what's wrong here?

/app/lib/rbtc_arbitrage/trader.rb:129:in `buy_and_transfer!': Not enough funds. Exiting. (SecurityError)

Unusual behavior

After typing the command 'rbtc':
WARN: Unresolved specs during Gem::Specification.reset:
activemodel (>= 3.1)
activesupport (>= 3.1)
thor (>= 0)
multi_json (>= 1.3.4, ~> 1.3)
hashie (>= 1.2.0)
mime-types (< 3, >= 1.16)
tzinfo (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
fatal: Not a git repository (or any of the parent directories): .git
I, [AUG 21 2014 7:20:49 PM -0400#409] INFO -- : Fetching exchange rates
I, [AUG 21 2014 7:20:50 PM -0400#409] INFO -- : Bitstamp (Ask): $522.49
I, [AUG 21 2014 7:20:50 PM -0400#409] INFO -- : Campbx (Bid): $527.01
I, [AUG 21 2014 7:20:50 PM -0400#409] INFO -- : buying 0.01 btc at Bitstamp for $5.26
I, [AUG 21 2014 7:20:50 PM -0400#409] INFO -- : selling 0.01 btc at Campbx for $5.24
I, [AUG 21 2014 7:20:50 PM -0400#409] INFO -- : profit: $-0.02 (-0.34%) is below cutoff of 2%.

So it does work, but not before throwing those warnings.

how to add other coins?

First of all I congratulate you on this project.
but i have a question for other coins, what about ripple, litecoin or storj etc.
transfer on wallets and buy or sell ? i think it s possible...

Bitstamp error when 'bundle install'

When I run 'bundle install', it shows:

Could not find gem 'bitstamp (>= 0) ruby' in source at ./bitstamp.
Source does not contain any versions of 'bitstamp (>= 0) ruby'

More Exchanges

Hello Henk, it is possible to Add more Exchanges?

In Europe the most of your Supported Exchanges dont Work fine.

Woud it be Possible to Add Kraken as an Exchange too?
https://www.kraken.com/help/api

Greetz

Oliver

Digest::Digest is deprecated; use Digest

rbtc --seller bitstamp --buyer coinbase

I, [JUL 11 2014  7:21:44 PM +0000#15619]  INFO -- : Fetching exchange rates
Digest::Digest is deprecated; use Digest
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http/header.rb:17:in `block in initialize_http_header': undefined method `strip' for nil:NilClass (NoMethodError)
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http/header.rb:15:in `each'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http/header.rb:15:in `initialize_http_header'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty/request.rb:152:in `setup_raw_request'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty/request.rb:90:in `perform'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty.rb:521:in `perform_request'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty.rb:457:in `get'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/coinbase-1.3.0/lib/coinbase/client.rb:201:in `http_verb'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/coinbase-1.3.0/lib/coinbase/client.rb:174:in `get'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/coinbase-1.3.0/lib/coinbase/client.rb:133:in `buy_price'
        from /home/bitcoin/rbtc_arbitrage/lib/rbtc_arbitrage/clients/coinbase_client.rb:40:in `price'
        from /home/bitcoin/rbtc_arbitrage/lib/rbtc_arbitrage/trader.rb:78:in `fetch_prices'
        from /home/bitcoin/rbtc_arbitrage/lib/rbtc_arbitrage/trader.rb:38:in `trade'
        from /home/bitcoin/rbtc_arbitrage/lib/rbtc_arbitrage/cli.rb:14:in `trade'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
        from /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
        from ./bin/rbtc:5:in `<main>'

Error on running rbtc

$ rbtc
/home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/number_helper.rb:3:in <module:NumberHelper>': uninitialized constant ActiveSupport::Autoload (NameError) from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/number_helper.rb:2:inmodule:ActiveSupport'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/number_helper.rb:1:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext/numeric/conversions.rb:2:inrequire'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext/numeric/conversions.rb:2:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext/numeric.rb:3:inrequire'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext/numeric.rb:3:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext.rb:2:inrequire'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext.rb:2:in block in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext.rb:1:ineach'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/activesupport-4.1.0/lib/active_support/core_ext.rb:1:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/bitstamp-0.3.0/lib/bitstamp.rb:1:inrequire'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/bitstamp-0.3.0/lib/bitstamp.rb:1:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/rbtc_arbitrage-1.4.4/lib/rbtc_arbitrage.rb:4:inrequire'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/rbtc_arbitrage-1.4.4/lib/rbtc_arbitrage.rb:4:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/rbtc_arbitrage-1.4.4/bin/rbtc:4:inrequire'
from /home/user/.rvm/gems/ruby-2.1.0@demo/gems/rbtc_arbitrage-1.4.4/bin/rbtc:4:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0@demo/bin/rbtc:23:inload'
from /home/user/.rvm/gems/ruby-2.1.0@demo/bin/rbtc:23:in <main>' from /home/user/.rvm/gems/ruby-2.1.0@demo/bin/ruby_executable_hooks:15:ineval'
from /home/user/.rvm/gems/ruby-2.1.0@demo/bin/ruby_executable_hooks:15:in `

'

[BUG] Segmentation fault at 0x00000000000110 ?

Hey Guys,

Please forgive me if this is some silly oversite on my behalf as i suspect this is my error rather than a bug, but im a little confused what going wrong here...

rbtc works fine from the CLI.

I have bundled it from github source into Rails 4 app

When I call RbtcArbitrage::Trader.new(options).trade from Rails Console, providing all the options at default it crashes the console.

Again, sorry if i´m doing something stupid here but if you could point me in the right diraction I would much appreciate it!

Thanks in advance!

Here is the output from console...

https://gist.github.com/alexwiththescar/2914ea04554cf3a8cde6

Sanity check - All env variables set correctly

/Library/Ruby/Gems/2.0.0/gems/bitstamp-0.3.0/lib/bitstamp.rb:72:in sanity_check!': Bitstamp Gem not properly configured (Bitstamp::MissingConfigExeception) from /Library/Ruby/Gems/2.0.0/gems/bitstamp-0.3.0/lib/bitstamp.rb:49:inbalance'
from /Library/Ruby/Gems/2.0.0/gems/rbtc_arbitrage-0.1.0/lib/rbtc_arbitrage/trader.rb:102:in get_balance' from /Library/Ruby/Gems/2.0.0/gems/rbtc_arbitrage-0.1.0/lib/rbtc_arbitrage/trader.rb:30:inexecute_trade'
from /Library/Ruby/Gems/2.0.0/gems/rbtc_arbitrage-0.1.0/lib/rbtc_arbitrage/trader.rb:23:in trade' from /Library/Ruby/Gems/2.0.0/gems/rbtc_arbitrage-0.1.0/lib/rbtc_arbitrage/cli.rb:10:intrade'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in run' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:ininvoke_command'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in dispatch' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:instart'
from /Library/Ruby/Gems/2.0.0/gems/rbtc_arbitrage-0.1.0/bin/rbtc:4:in <top (required)>' from /usr/bin/rbtc:23:inload'
from /usr/bin/rbtc:23:in `

'

That happens when I try and do a live trade. All environment variables have been setup correctly with BITSTAMP_ADDRESS being my Bitstamp 'wallet id' for deposit, and MTGOX_ADDRESS being the Gox one.

price': uninitialized constant RbtcArbitrage::Clients::BitstampClient::Bitstamp (NameError)

@hstove - When I run rbtc I am getting the following error

    $ rbtc
    I, [MAR 24 2014 10:29:15 AM +0530#5206]  INFO -- : Fetching exchange rates

/home/user/.rvm/gems/ruby-2.0.0-p353@ui/gems/rbtc_arbitrage-2.0.1/lib/rbtc_arbitrage/clients/bitstamp_client.rb:31:in price': uninitialized constant RbtcArbitrage::Clients::BitstampClient::Bitstamp (NameError) from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/rbtc_arbitrage-2.0.1/lib/rbtc_arbitrage/trader.rb:82:infetch_prices'
from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/rbtc_arbitrage-2.0.1/lib/rbtc_arbitrage/trader.rb:35:in trade' from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/rbtc_arbitrage-2.0.1/lib/rbtc_arbitrage/cli.rb:14:intrade'
from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/thor-0.19.0/lib/thor/command.rb:27:in run' from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/thor-0.19.0/lib/thor/invocation.rb:126:ininvoke_command'
from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/thor-0.19.0/lib/thor.rb:359:in dispatch' from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/thor-0.19.0/lib/thor/base.rb:440:instart'
from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/gems/rbtc_arbitrage-2.0.1/bin/rbtc:5:in <top (required)>' from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/bin/rbtc:23:inload'
from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/bin/rbtc:23:in <main>' from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/bin/ruby_executable_hooks:15:ineval'
from /home/jefferson/.rvm/gems/ruby-2.0.0-p353@ui/bin/ruby_executable_hooks:15:in `

'

I have the following in my Gemfile and bundle install
Gemfile
gem 'rbtc_arbitrage', '~> 2.0.1'

Bundler::GemfileNotFound

Everytime I try to run rbtc on Ubuntu or Linux Mint, I get the following error:

$rbtc

/home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/shared_helpers.rb:24:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:248:in `default_gemfile'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:192:in `root'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:99:in `bundle_path'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:400:in `configure_gem_home_and_path'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:90:in `configure'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:151:in `definition'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:116:in `setup'
        from /home/user/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:132:in `require'
        from /home/user/.rvm/gems/ruby-2.1.1/gems/rbtc_arbitrage-2.0.2/lib/rbtc_arbitrage.rb:2:in `<top (required)>'
        from /home/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/gems/ruby-2.1.1/gems/rbtc_arbitrage-2.0.2/bin/rbtc:4:in `<top (required)>'
        from /home/user/.rvm/gems/ruby-2.1.1/bin/rbtc:23:in `load'
        from /home/user/.rvm/gems/ruby-2.1.1/bin/rbtc:23:in `<main>'
        from /home/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
        from /home/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'

I've uninstalled and reinstalled RVM and different versions of Ruby several times. Do you know what I'm doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.