This document provides the complete reference for hitbtc API in the wrapper.
The following symbols are traded on hitbtc exchange.
| Symbol | Lot size | Price step |
|---|---|---|
| BTCUSD | 0.01 BTC | 0.01 |
| BTCEUR | 0.01 BTC | 0.01 |
| LTCBTC | 0.1 LTC | 0.00001 |
| LTCUSD | 0.1 LTC | 0.001 |
| LTCEUR | 0.1 LTC | 0.001 |
| EURUSD | 1 EUR | 0.0001 |
Size representation:
- Size values in streaming messages are represented in lots.
- Size values in RESTful market data are represented in money (e.g. in coins or in USD).
- Size values in RESTful trade are represented in lots (e.g. 1 means 0.01 BTC for BTCUSD)
- Solid trade execution functionality
- payment api
Don't hesitate to contribute. If you liked it: BTC: 1PizgAWLJbwEsNWG9Cf27skcbgbgZGgeyK LTC: LQtM1t6BRd64scsdSBk8nnCLJuc8Qfhm53
Add this line to your application's Gemfile:
gem 'hitbtc' And then execute:
$ bundle Or install it yourself as:
$ gem install hitbtc Create a Kraken client:
API_KEY='3bH+M/nLp......'API_SECRET='wQG+7Lr9b.....'hitbtc=Hitbtc::Client.new(API_KEY,API_SECRET)time=hitbtc.server_timetime#=> 1393056191time=hitbtc.server_timesymbol=hitbtc.symbols("BTCEUR")symbols=hitbtc.symbols(["BTCEUR","BTCUSD"])all_symbols=hitbtc.symbolsticker_data=hitbtc.ticker('BTCEUR')- 24h means last 24h + last incomplete minute
- high - highest trade price / 24 h
- low - lowest trade price / 24 h
- volume - volume / 24h
order_book=hitbtc.order_book('BTCEUR')order_book=hitbtc.order_book('BTCEUR',{format_amount_unit: "lot"})| Parameter | Type | Description |
|---|---|---|
| format_price | optional, "string" (default) or "number" | |
| format_amount | optional, "string" (default) or "number" | |
| format_amount_unit | optional, "currency" (default) or "lot" |
trades=hitbtc.trades"BTCEUR"(defaultfrom1dayago,bytimestamp,index0,max_result1000)trades=hitbtc.trades'BTCEUR',(Time.now - 1.day).to_i,"ts",0,1000)trades=hitbtc.trades'BTCEUR',(Time.now - 1.day).to_i,"ts",0,1000,{format_amount_unit: "lot"})Parameters:
| Parameter | Type | Description |
|---|---|---|
| from | required, int, trade_id or timestamp | returns trades with trade_id > specified trade_id returns trades with timestamp >= specified timestamp |
| till | optional, int, trade_id or timestamp | returns trades with trade_id < specified trade_id returns trades with timestamp < specified timestamp |
| by | required, filter and sort by trade_id or ts (timestamp) | |
| sort | optional, asc (default) or desc | |
| start_index | required, int | zero-based |
| max_results | required, int, max value = 1000 | |
| format_item | optional, "array" (default) or "object" | |
| format_price | optional, "string" (default) or "number" | |
| format_amount | optional, "string" (default) or "number" | |
| format_amount_unit | optional, "currency" (default) or "lot" | |
| format_tid | optional, "string" or "number" (default) | |
| format_timestamp | optional, "millisecond" (default) or "second" | |
| format_wrap | optional, "true" (default) or "false" |
RESTful Trading API can return the following errors:
| HTTP code | Text | Description |
|---|---|---|
| 403 | Invalid apikey | API key doesn't exist or API key is currently used on another endpoint (max last 15 min) |
| 403 | Nonce has been used | nonce is not monotonous |
| 403 | Nonce is not valid | too big number or not a number |
| 403 | Wrong signature |
The API uses ExecutionReport as an object that represents change of order status.
The following fields are used in this object:
| Field | Description | Type / Enum | Required |
|---|---|---|---|
| orderId | Order ID on the Exchange | string | required |
| clientOrderId | clientOrderId sent in NewOrder message | string | required |
| execReportType | execution report type | newcanceledrejectedexpiredtradestatus | required |
| orderStatus | order status | newpartiallyFilledfilledcanceledrejectedexpired | required |
| orderRejectReason | Relevant only for the orders in rejected state | unknownSymbolexchangeClosedorderExceedsLimitunknownOrderduplicateOrderunsupportedOrderunknownAccountother | for rejects |
| symbol | string, e.g. BTCUSD | required | |
| side | buy or sell | required | |
| timestamp | UTC timestamp in milliseconds | ||
| price | decimal | ||
| quantity | integer | required | |
| type | only limit orders are currently supported | required | |
| timeInForce | time in force | GTC - Good-Til-Canceled IOK - Immediate-Or-CancelFOK - Fill-Or-KillDAY - day orders< | required |
| tradeId | Trade ID on the exchange | for trades | |
| lastQuantity | integer | for trades | |
| lastPrice | decimal | for trades | |
| leavesQuantity | integer | ||
| cumQuantity | integer | ||
| averagePrice | decimal, will be 0 if 'cumQuantity'=0 |
all_balance=hitbtc.balanceone_balance=hitbtc.balance("BTC")many_balances=hitbtc.balance(["BTC","EUR"])all_active_orders=hitbtc.active_orderssymbol_specific_orders=hitbtc.active_orders({symbols: "BTCEUR"})symbols_specific_orders=hitbtc.active_orders({symbols: "BTCEUR,BTCUSD"})Parameters:
| Parameter | Type | Description |
|---|---|---|
| symbols | string, comma-delimeted list of symbols, optional, default - all symbols |
price should be specified even for market execution (haven't tested on a real order yet)
hitbtc.create_order({symbol: "BTCEUR",side: "buy",quantity: 1,type: "market",timeInForce: "GTC",price: 320.000})Parameters:
| Parameter | Type | Description |
|---|---|---|
| symbol | string, required | e.g. BTCUSD |
| side | buy or sell, required | |
| price | decimal, required | order price, required for limit orders |
| quantity | int | order quantity in lots |
| type | limit or market | order type |
| timeInForce | GTC - Good-Til-Canceled IOK - Immediate-Or-CancelFOK - Fill-Or-KillDAY - day | use GTC by default |
You only need your order id (haven't been tested on real order yet)
hitbtc.cancel_order("1398804347")default=hitbtc.trade_historycustom=hitbtc.trade_history({by: "ts",start_index: 0,max_results: 10,symbols: "BTCEUR,BTCUSD"})Parameters:
| Parameter | Type | Description |
|---|---|---|
by | trade_id or ts (timestamp) | |
start_index | int, optional, default(0) | zero-based index |
max_results | int, required, <=1000 | |
symbols | string, comma-delimited | |
sort | asc (default) or desc | |
from | optional | start trade_id or ts, see by |
till | optional | end trade_id or ts, see by |
default=hitbtc.recent_orderscustom=hitbtc.trade_history({start_index: 0,max_results: 10,symbols: "BTCEUR,BTCUSD",statuses: "new,filled"})Parameters:
| Parameter | Type | Description |
|---|---|---|
start_index | int, optional, default(0) | zero-based index |
max_results | int, required, <=1000 | |
symbols | string, comma-delimited | |
statuses | string, comma-delimited, new, partiallyFilled, filled, canceled, expired, rejected |