Skip to content

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

Notifications You must be signed in to change notification settings

nolim1t/btcmarkets-gem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 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
puts b.post_order_open( {"currency":"AUD","instrument":"BTC","limit":10,"since":0})

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)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages