Giter Club home page Giter Club logo

btcmrb's Introduction

Btcmrb (BTC Markets Ruby)

Description

Unofficial Ruby Gem for btcmarkets.net API and is still very much a work in progress.

Installation

Install the gem

Command line:

$ gem install btcmrb

Or in your application's Gemfile:

gem 'btcmrb', '~> 0.1.5'

Create some environment variables

https://btcmarkets.net/account/apikey

export BTCM_ACCESS_KEY="YOUR ACCESS KEY"
export BTCM_SECRET="YOUR SECRET"

Account Management API

https://github.com/BTCMarkets/API/wiki/Account-API

client = Btcmrb.new
balance_request = Btcmrb::Account.balance
client.send_request(balance_request)
# => [{"balance":1000000000,"pendingFunds":0,"currency":"AUD"},{"balance":1000000000,"pendingFunds":0,"currency":"BTC"},{"balance":1000000000,"pendingFunds":0,"currency":"LTC"}]

client = Btcmrb.new
tradingfee_request = Btcmrb::Account.tradingfee('BTC','AUD')
client.send_request(tradingfee_request)
# => [{"success"=>true, "errorCode"=>nil, "errorMessage"=>nil, "tradingFeeRate"=>749999, "volume30Day"=>396768299721}]

Market Data API

https://github.com/BTCMarkets/API/wiki/Market-data-API

client = Btcmrb.new
ticker_request = Btcmrb::Marketdata.tick('BTC','AUD')
client.send_request(ticker_request)
# => {"bestBid":844.0,"bestAsk":844.98,"lastPrice":845.0,"currency":"AUD","instrument":"BTC","timestamp":1476242958,"volume24h":172.60804}

client = Btcmrb.new
orderbook_request = Btcmrb::Marketdata.orderbook('BTC','AUD')
client.send_request(orderbook_request)
# => {"currency":"AUD","instrument":"BTC","timestamp":1476243360,"asks":[[844.98,0.45077821],[845.0,2.7069457],[848.68,2.58512],[848.76,0.29745]],"bids":[[844.0,0.00489636],[840.21,0.060724],[840.16,0.1180803],[840.1,0.32130103]]}

client = Btcmrb.new
trades_requst = Btcmrb::Marketdata.trades('BTC','AUD')
client.send_request(trades_requst)
# => [{"tid":4432702312,"amount":0.01959674,"price":845.0,"date":1378878093},{"tid":59861212129,"amount":1.21434000,"price":845.15,"date":1377840783}]

Trading API

https://github.com/BTCMarkets/API/wiki/Trading-API

client = Btcmrb.new
all_orders = Btcmrb::Order.all
client.send_request(all_orders)
# => {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}

client = Btcmrb.new
open_orders = Btcmrb::Order.open_orders
client.send_request(open_orders)
# => {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}

client = Btcmrb.new
trade_history = Btcmrb::Order.trade_history
client.send_request(trade_history)
# => TBC

# A single order
client = Btcmrb.new
order_detail = Btcmrb::Order.show(123456789)
client.send_request(order_detail)
# => TBC

# Multiple orders
client = Btcmrb.new
order_detail = Btcmrb::Order.show(123456789,987654321)
client.send_request(order_detail)
# => TBC

client = Btcmrb.new
order_detail = Btcmrb::Order.create('AUD','BTC',4000,1,'Bid','Limit')
client.send_request(order_detail)
# => TBC

client = Btcmrb.new
order_to_cancel = Btcmrb::Order.cancel(123456789)
client.send_request(order_to_cancel)
# =>  TBC

License

MIT - For terms refer to LICENSE.md

btcmrb's People

Contributors

tennantje avatar fab avatar

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.