Project

cobinhood

0.0
No commit activity in last 3 years
No release in over 3 years
Implements Cobinhood API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 10.0
~> 3.0

Runtime

 Project Readme

Cobinhood

This is an unofficial Ruby wrapper for the Cobinhood exchange REST and WebSocket APIs.

Notice
  • This is Alpha software. All issues should be aggressively reported for quick resolution!
  • RESTful interface is fully implemented.
  • Websocket is not done.
  • Pull Requests are very welcome!

Installation

Add this line to your application's Gemfile:

gem 'cobinhood'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cobinhood

Features

Current

  • Basic implementation of REST API
    • Easy to use authentication
    • Methods return parsed JSON
    • No need to generate timestamps
    • No need to generate signatures

Planned

  • Basic implementation of WebSocket API

    • Pass procs or lambdas to event handlers
    • Single and multiple streams supported
    • Runs on EventMachine
  • Exception handling with responses

  • High level abstraction

Getting Started

REST Client

Require Cobinhood:

require 'cobinhood'

Create a new instance of the REST Client:

# If you only plan on touching public API endpoints, you can forgo any arguments
client = Cobinhood::Client::REST.new

# Otherwise provide an api_key as keyword arguments
client = Cobinhood::Client::REST.new api_key: 'your.api_key'

ALTERNATIVELY, set your API key in exported environment variable:

export COBINHOOD_API_KEY=your.api_key

Then you can instantiate client without parameters as in first variation above.

Create various requests:

# Ping the server
client.time
  # => {"time"=>1527470756975}

# Get candle data
client.candles "ABT-BTC", timeframe: '1m'
  # => {"candles"=>[
  #   {"timeframe"=>"1m", "trading_pair_id"=>"ABT-BTC", "timestamp"=>1527384360000, "volume"=>"0",
  #     "open"=>"0.00012873", "close"=>"0.00012873", "high"=>"0.00012873", "low"=>"0.00012873"
  #   },
  #   {"timeframe"=>"1m", "trading_pair_id"=>"ABT-BTC", "timestamp"=>1527384420000, "volume"=>"0",
  #     "open"=>"0.00012873", "close"=>"0.00012873", "high"=>"0.00012873", "low"=>"0.00012873"
  #   },
  #   {"timeframe"=>"1m", "trading_pair_id"=>"ABT-BTC", ...


# Place an order
client.place_order 'ABT-BTC', side: :ask, type: :limit, price: 0.000127, size: 22
  # => {
  #   "order"=>{
  #     "id"=>"298e5465-7282-47ca-9a1f-377c56487f5f",
  #     "trading_pair_id"=>"ABT-BTC",
  #     "side"=>"ask",
  #     "type"=>"limit",
  #     "price"=>"0.000127",
  #     "size"=>"22",
  #     "filled"=>"0",
  #     "state"=>"queued",
  #     "timestamp"=>1527471152779,
  #     "eq_price"=>"0",
  #     "completed_at"=>nil,
  #     "source"=>"exchange"
  #     }
  #   }


# Get deposit address
client.get_deposit_addresses
  => { "deposit_addresses"=>[
    { "address"=>"0x8bdFCC26CaA363234528288471107D90525d6BF923",
      "blockchain_id"=>"ethereum",
      "created_at"=>1527263083623,
      "currency"=>"FXT",
      "type"=>"exchange"
      },
    ...

Required and optional parameters, as well as enum values, can currently be found on the Cobinhood GitHub Page. Parameters should always be passed to client methods as keyword arguments in snake_case form. trading_pair_id, when a required parameter is simply passed as first parameter for most API calls.

REST Endpoints

REST endpoints are in order as documented on the Cobinhood Github page (linked above). The following lists only the method names, aliases (if any) and parameters of the methods to access endpoints. For the most part, method names follow naming of the endpoint's URL and alias method follows the title/name given in Cobinhood API documentation. There were some deviations where there would otherwise be name clashes/overloading.

System Endpoints


time
  • required params: none

info
  • required params: none

Market Endpoints


currencies
  • alias: get_all_currencies
  • required params: none

trading_pairs
  • alias: get_all_trading_pairs
  • required params: none

order_book trading_pair_id
  • alias: get_order_book
  • required params: trading_pair_id

precisions trading_pair_id
  • alias: get_order_book_precisions
  • required params: trading_pair_id

stats
  • required params: none

tickers trading_pair_id
  • alias: get_ticker
  • required params: none

market_trades trading_pair_id
  • alias: get_recent_trades
  • required params: none

Chart Endpoints


candles trading_pair_id, options={}
  • required params: trading_pair_id, timeframe

Trading Endpoints


order order_id
  • alias: get_order
  • required params: order_id

order_trades order_id
  • alias: get_trades_of_an_order
  • required params: order_id

orders
  • alias: get_all_orders
  • required params: none

place_order trading_pair_id, options={}
  • required params: side, type, size, price (except market orders)

modify_order order_id, options={}
  • required params: order_id, size, price

cancel_order order_id
  • required params: order_id

order_history trading_pair_id=nil, options={}
  • alias: get_order_history
  • required params: none

get_trade trade_id
  • alias: trade
  • required params: trade_id

trades trading_pair_id, options={}
  • required params: trading_pair_id

Wallet Endpoints


balances
  • alias: get_wallet_balances
  • required params: none

ledger
  • alias: get_ledger_entries
  • required params: none

deposit_addresses
  • alias: get_deposit_addresses
  • required params: none

withdrawal_addresses
  • alias: get_withdrawal_addresses
  • required params: none

withdrawal withdrawal_id
  • alias: get_withdrawal
  • required params: withdrawal_id

withdrawals
  • alias: get_all_withdrawals
  • required params: none

deposit deposit_id
  • alias: get_deposit
  • required params: deposit_id

deposits
  • alias: get_all_deposits
  • required params: none

WebSocket Client

  • COMING SOON!

Development

  • RSPECs coming soon!

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mwlang/cobinhood.

Inspiration

The inspiration for architectural layout of this gem comes nearly one-for-one from the Binance gem by craysiii.

License

The gem is available as open source under the terms of the MIT License.