Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nolim1t/btcmarkets-gem

BTCMarkets Ruby Gem for querying Market API data (Trading coming soon)
https://github.com/nolim1t/btcmarkets-gem

api-client bitcoin btcmarkets exchanges trading

Last synced: 2 days ago
JSON representation

BTCMarkets Ruby Gem for querying Market API data (Trading coming soon)

Awesome Lists containing this project

README

        

# BTC Markets Ruby Gem
[![Gem Version](https://badge.fury.io/rb/nl-btcmarkets.svg)](https://badge.fury.io/rb/nl-btcmarkets)

## About / Why
Decided its time to create a ruby interface for the BTCMarkets.net API.

Currently it only supports querying data. API may change if we support trading.

## Building

```bash
# Assuming you are installing 0.0.1
gem build nl-btcmarkets.gemspec
gem install nl-btcmarkets-0.0.1.gem
```

## installing
```bash
gem install nl-btcmarkets
```

### Or add the following to your Gemfile
```text
source 'https://rubygems.org'

gem 'httparty'
gem 'nl-btcmarkets'
```

## Usage
### Environment Variables
The following environment variables need to be set up
* btcm_access_key
* btcm_access_secret

### Sample Code
```ruby
require 'nl-btcmarkets'

b = BTCMarkets.new
puts b.get_market_BTC_AUD_tick # Get the spot quote
puts b.get_market_BTC_AUD_orderbook # Get orderbook
puts b.get_account_balance # Get account balance
puts b.post_order_open( {"currency":"AUD","instrument":"BTC","limit":10,"since":0})
```

#### Get Account Balance if not 0
```ruby
require 'nl-btcmarkets'
require 'json'
b = BTCMarkets.new
JSON.parse(b.get_account_balance).each{|bal|
if bal['balance'] > 0 then
if bal['currency'] == 'AUD' or bal['currency'] == 'USD'
puts "Balance: #{bal['currency']}$#{(bal['balance'].to_f / 100000000).to_s} / Trading Balance: #{bal['currency']}$#{(bal['pendingFunds'].to_f / 100000000).to_s}"
end
end
}
```

## Disclaimer
* This is an early stage pre-release. Use at your own risk.
* Pull Requests are appreciated