Skip to content

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

Notifications You must be signed in to change notification settings

justin-ngin/btcmarkets-gem

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTC Markets Ruby Gem

Gem Version

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

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

installing

gem install nl-btcmarkets

Or add the following to your Gemfile

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

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

Get Account Balance if not 0

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%