Bitstampede is a gem for accessing the Bitstamp API
Add this line to your application's Gemfile:
gem 'bitstampede'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bitstampede
First, look at this picture:
Second, stop writing api clients that are configured with class ivars ಠ_ಠ
Third, this stuff:
client = Bitstampede::Client.new
client.key = 'YOUR_API_KEY'
client.secret = 'YOUR_API_SECRET'
client.client_id = 'YOUR_CLIENT_ID'
# Alternatively, you can configure the client on initialization with:
client = Bitstampede::Client.new(key: 'YOUR_API_KEY', secret: 'YOUR_API_SECRET', client_id: 'YOUR_CLIENT_ID')
# Fetch your balance
client.balance
# => #<Bitstampede::Entities::Balance:0x0000000259f338 @usd_balance=#<BigDecimal:259e898,'0.0',9(9)>, @btc_balance=#<BigDecimal:2726698,'0.0',9(9)>, @usd_reserved=#<BigDecimal:2726328,'0.0',9(9)>, @btc_reserved=#<BigDecimal:2725fb8,'0.0',9(9)>, @usd_available=#<BigDecimal:2725c48,'0.0',9(9)>, @btc_available=#<BigDecimal:27258b0,'0.0',9(9)>, @fee=#<BigDecimal:2725540,'0.0',9(9)>>
client.orders
#=> [
#<Bitstampede::Entities::Order:0x000000027302d8 @id=0, @datetime=0, @type=:buy, @price=#<BigDecimal:272f428,'0.0',9(9)>, @amount=#<BigDecimal:272f130,'0.0',9(9)>>
]
# Place a limit order to buy one bitcoin for $100.00 USD
client.buy!(BigDecimal('1'), BigDecimal('100'))
# Place a limit order to sell one bitcoin for $101.00 USD
client.sell!(BigDecimal('1'), BigDecimal('101'))
# Cancel order #1234
client.cancel 1234
You can run any of the examples in the example
dir by just executing the script (except example/example.rb
, which is the base example class). For instance, to see your balance, do the following:
ruby example/balance.rb
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
This software is licensed under the MIT License.
These people have contributed to the gem. Many thanks!:
- Josh Adams
- Robert Jackson
- Seth Messer
- James Cook