hitbtc-uberamd 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +6 -0
- data/README.md +254 -0
- data/hitbtc.gemspec +27 -0
- data/key.yml.example +2 -0
- data/lib/hitbtc.rb +2 -0
- data/lib/hitbtc/client.rb +163 -0
- data/lib/hitbtc/version.rb +3 -0
- metadata +135 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6eabee57d5f0a0c57bcfd862c48e9c3d72f93fde
|
|
4
|
+
data.tar.gz: 507c241e78303ccb0db37bda803ecc9ce414d929
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7fb0ef5d98084e8a9d767b1e1899ffed2e29033cab34b978ab2d86219f165441215c820b032a43518f90098766d5a31a93defd354172c4d6e1967ffc04d1f7cb
|
|
7
|
+
data.tar.gz: 9bb609484ea0b3a5b28d0a494219954c9130eedc92bb2b0c54fb192036e961b6a194131120680e4ba91458049d71a2f8bf141ed255fa6279ee090af08eedfb08
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
This document provides the complete reference for [hitbtc](https://hitbtc.com) API in the wrapper.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
The following symbols are traded on hitbtc exchange.
|
|
7
|
+
|
|
8
|
+
| Symbol | Lot size | Price step
|
|
9
|
+
| --- | --- | --- |
|
|
10
|
+
| BTCUSD | 0.01 BTC | 0.01 |
|
|
11
|
+
| BTCEUR | 0.01 BTC | 0.01 |
|
|
12
|
+
| LTCBTC | 0.1 LTC | 0.00001 |
|
|
13
|
+
| LTCUSD | 0.1 LTC | 0.001 |
|
|
14
|
+
| LTCEUR | 0.1 LTC | 0.001 |
|
|
15
|
+
| EURUSD | 1 EUR | 0.0001 |
|
|
16
|
+
|
|
17
|
+
Size representation:
|
|
18
|
+
* Size values in streaming messages are represented in lots.
|
|
19
|
+
* Size values in RESTful market data are represented in money (e.g. in coins or in USD).
|
|
20
|
+
* Size values in RESTful trade are represented in lots (e.g. 1 means 0.01 BTC for BTCUSD)
|
|
21
|
+
|
|
22
|
+
### Pending Future Updates
|
|
23
|
+
|
|
24
|
+
- Solid trade execution functionality
|
|
25
|
+
- payment api
|
|
26
|
+
|
|
27
|
+
Don't hesitate to contribute.
|
|
28
|
+
If you liked it:
|
|
29
|
+
BTC: 1PizgAWLJbwEsNWG9Cf27skcbgbgZGgeyK
|
|
30
|
+
LTC: LQtM1t6BRd64scsdSBk8nnCLJuc8Qfhm53
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Add this line to your application's Gemfile:
|
|
35
|
+
|
|
36
|
+
gem 'hitbtc'
|
|
37
|
+
|
|
38
|
+
And then execute:
|
|
39
|
+
|
|
40
|
+
$ bundle
|
|
41
|
+
|
|
42
|
+
Or install it yourself as:
|
|
43
|
+
|
|
44
|
+
$ gem install hitbtc
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
Create a Kraken client:
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
API_KEY = '3bH+M/nLp......'
|
|
52
|
+
API_SECRET = 'wQG+7Lr9b.....'
|
|
53
|
+
|
|
54
|
+
hitbtc = Hitbtc::Client.new(API_KEY, API_SECRET)
|
|
55
|
+
|
|
56
|
+
time = hitbtc.server_time
|
|
57
|
+
time #=> 1393056191
|
|
58
|
+
```
|
|
59
|
+
### Public Data Methods
|
|
60
|
+
|
|
61
|
+
#### Server Time
|
|
62
|
+
```ruby
|
|
63
|
+
time = hitbtc.server_time
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
#### Symbol info
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
symbol = hitbtc.symbols("BTCEUR")
|
|
70
|
+
symbols = hitbtc.symbols(["BTCEUR", "BTCUSD"])
|
|
71
|
+
all_symbols = hitbtc.symbols
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Ticker
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
ticker_data = hitbtc.ticker('BTCEUR')
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
* 24h means last 24h + last incomplete minute
|
|
81
|
+
* high - highest trade price / 24 h
|
|
82
|
+
* low - lowest trade price / 24 h
|
|
83
|
+
* volume - volume / 24h
|
|
84
|
+
|
|
85
|
+
#### Order Book
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
order_book = hitbtc.order_book('BTCEUR')
|
|
89
|
+
order_book = hitbtc.order_book('BTCEUR', {format_amount_unit: "lot"})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Parameter | Type | Description |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| format_price | optional, "string" (default) or "number" | |
|
|
95
|
+
| format_amount | optional, "string" (default) or "number" | |
|
|
96
|
+
| format_amount_unit | optional, "currency" (default) or "lot" | |
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
#### Trades
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
trades = hitbtc.trades "BTCEUR" (default from 1 day ago, by timestamp, index 0, max_result 1000)
|
|
103
|
+
trades = hitbtc.trades 'BTCEUR', (Time.now - 1.day).to_i, "ts", 0, 1000)
|
|
104
|
+
trades = hitbtc.trades 'BTCEUR', (Time.now - 1.day).to_i, "ts", 0, 1000, {format_amount_unit: "lot"})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Parameters:
|
|
108
|
+
|
|
109
|
+
| Parameter | Type | Description |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| from | required, int, trade_id or timestamp | returns trades with trade_id > specified trade_id <br> returns trades with timestamp >= specified timestamp |
|
|
112
|
+
| till | optional, int, trade_id or timestamp | returns trades with trade_id < specified trade_id <br> returns trades with timestamp < specified timestamp |
|
|
113
|
+
| by | required, filter and sort by `trade_id` or `ts` (timestamp) | |
|
|
114
|
+
| sort | optional, `asc` (default) or `desc` | |
|
|
115
|
+
| start_index | required, int | zero-based |
|
|
116
|
+
| max_results | required, int, max value = 1000 | |
|
|
117
|
+
| format_item | optional, "array" (default) or "object" | |
|
|
118
|
+
| format_price | optional, "string" (default) or "number" | |
|
|
119
|
+
| format_amount | optional, "string" (default) or "number" | |
|
|
120
|
+
| format_amount_unit | optional, "currency" (default) or "lot" | |
|
|
121
|
+
| format_tid | optional, "string" or "number" (default) | |
|
|
122
|
+
| format_timestamp | optional, "millisecond" (default) or "second" | |
|
|
123
|
+
| format_wrap | optional, "true" (default) or "false" | |
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
### Private Data Methods
|
|
127
|
+
|
|
128
|
+
#### Error codes
|
|
129
|
+
|
|
130
|
+
RESTful Trading API can return the following errors:
|
|
131
|
+
|
|
132
|
+
| HTTP code | Text | Description |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| 403 | Invalid apikey | API key doesn't exist or API key is currently used on another endpoint (max last 15 min) |
|
|
135
|
+
| 403 | Nonce has been used | nonce is not monotonous |
|
|
136
|
+
| 403 | Nonce is not valid | too big number or not a number |
|
|
137
|
+
| 403 | Wrong signature | |
|
|
138
|
+
|
|
139
|
+
#### Execution reports
|
|
140
|
+
|
|
141
|
+
The API uses `ExecutionReport` as an object that represents change of order status.
|
|
142
|
+
|
|
143
|
+
The following fields are used in this object:
|
|
144
|
+
|
|
145
|
+
| Field | Description | Type / Enum | Required |
|
|
146
|
+
| --- | --- | --- | --- |
|
|
147
|
+
| orderId | Order ID on the Exchange | string | required |
|
|
148
|
+
| clientOrderId | clientOrderId sent in NewOrder message | string | required |
|
|
149
|
+
| execReportType | execution report type | `new` <br> `canceled` <br> `rejected` <br> `expired` <br> `trade` <br> `status` | required |
|
|
150
|
+
| orderStatus | order status | `new` <br> `partiallyFilled` <br> `filled` <br> `canceled` <br> `rejected` <br> `expired` | required |
|
|
151
|
+
| orderRejectReason | Relevant only for the orders in rejected state | `unknownSymbol` <br> `exchangeClosed` <br>`orderExceedsLimit` <br> `unknownOrder` <br> `duplicateOrder` <br> `unsupportedOrder` <br> `unknownAccount` <br> `other`| for rejects |
|
|
152
|
+
| symbol | | string, e.g. `BTCUSD` | required |
|
|
153
|
+
| side | | `buy` or `sell` | required |
|
|
154
|
+
| timestamp | UTC timestamp in milliseconds | | |
|
|
155
|
+
| price | | decimal | |
|
|
156
|
+
| quantity | | integer | required |
|
|
157
|
+
| type | | only `limit` orders are currently supported | required |
|
|
158
|
+
| timeInForce | time in force | `GTC` - Good-Til-Canceled <br>`IOK` - Immediate-Or-Cancel<br>`FOK` - Fill-Or-Kill<br>`DAY` - day orders< | required |
|
|
159
|
+
| tradeId | Trade ID on the exchange | | for trades |
|
|
160
|
+
| lastQuantity | | integer | for trades |
|
|
161
|
+
| lastPrice | | decimal | for trades |
|
|
162
|
+
| leavesQuantity | | integer | |
|
|
163
|
+
| cumQuantity | | integer | |
|
|
164
|
+
| averagePrice | | decimal, will be 0 if 'cumQuantity'=0 | |
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
#### Balance
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
all_balance = hitbtc.balance
|
|
171
|
+
one_balance = hitbtc.balance("BTC")
|
|
172
|
+
many_balances = hitbtc.balance(["BTC", "EUR"])
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### List of active orders
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
all_active_orders = hitbtc.active_orders
|
|
179
|
+
symbol_specific_orders = hitbtc.active_orders({symbols: "BTCEUR"})
|
|
180
|
+
symbols_specific_orders = hitbtc.active_orders({symbols: "BTCEUR,BTCUSD"})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Parameters:
|
|
184
|
+
|
|
185
|
+
| Parameter | Type | Description |
|
|
186
|
+
| --- | --- | --- |
|
|
187
|
+
| symbols | string, comma-delimeted list of symbols, optional, default - all symbols | |
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
#### Create Order
|
|
191
|
+
|
|
192
|
+
price should be specified even for market execution (haven't tested on a real order yet)
|
|
193
|
+
|
|
194
|
+
```ruby
|
|
195
|
+
hitbtc.create_order({symbol: "BTCEUR", side: "buy", quantity: 1, type: "market", timeInForce: "GTC", price: 320.000})
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Parameters:
|
|
199
|
+
|
|
200
|
+
| Parameter | Type | Description |
|
|
201
|
+
| --- | --- | --- |
|
|
202
|
+
| symbol | string, required | e.g. `BTCUSD` |
|
|
203
|
+
| side | `buy` or `sell`, required | |
|
|
204
|
+
| price | decimal, required | order price, required for limit orders |
|
|
205
|
+
| quantity | int | order quantity in lots |
|
|
206
|
+
| type | `limit` or `market` | order type |
|
|
207
|
+
| timeInForce | `GTC` - Good-Til-Canceled <br>`IOK` - Immediate-Or-Cancel<br>`FOK` - Fill-Or-Kill<br>`DAY` - day | use `GTC` by default |
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
#### Cancel Order
|
|
212
|
+
|
|
213
|
+
You only need your order id (haven't been tested on real order yet)
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
hitbtc.cancel_order("1398804347")
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Trades History
|
|
220
|
+
|
|
221
|
+
```ruby
|
|
222
|
+
default = hitbtc.trade_history
|
|
223
|
+
custom = hitbtc.trade_history({by: "ts", start_index: 0, max_results: 10, symbols: "BTCEUR,BTCUSD"})
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Parameters:
|
|
227
|
+
|
|
228
|
+
| Parameter | Type | Description |
|
|
229
|
+
| --- | --- | --- |
|
|
230
|
+
| `by` | `trade_id` or `ts` (timestamp) | |
|
|
231
|
+
| `start_index` | int, optional, default(0) | zero-based index |
|
|
232
|
+
| `max_results` | int, required, <=1000 | |
|
|
233
|
+
| `symbols` | string, comma-delimited | |
|
|
234
|
+
| `sort` | `asc` (default) or `desc` | |
|
|
235
|
+
| `from` | optional | start `trade_id` or `ts`, see `by` |
|
|
236
|
+
| `till` | optional | end `trade_id` or `ts`, see `by` |
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
#### Recent Orders
|
|
240
|
+
|
|
241
|
+
```ruby
|
|
242
|
+
default = hitbtc.recent_orders
|
|
243
|
+
custom = hitbtc.trade_history({start_index: 0, max_results: 10, symbols: "BTCEUR,BTCUSD", statuses: "new,filled"})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Parameters:
|
|
247
|
+
|
|
248
|
+
| Parameter | Type | Description |
|
|
249
|
+
| --- | --- | --- |
|
|
250
|
+
| `start_index` | int, optional, default(0) | zero-based index |
|
|
251
|
+
| `max_results` | int, required, <=1000 | |
|
|
252
|
+
| `symbols` | string, comma-delimited | |
|
|
253
|
+
| `statuses` | string, comma-delimited, `new`, `partiallyFilled`, `filled`, `canceled`, `expired`, `rejected` | |
|
|
254
|
+
|
data/hitbtc.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'hitbtc/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "hitbtc-uberamd"
|
|
8
|
+
spec.version = HitbtcRuby::VERSION
|
|
9
|
+
spec.authors = ["Steve Morrissey"]
|
|
10
|
+
spec.email = ["uberamd@gmail.com"]
|
|
11
|
+
spec.description = %q{"Wrapper for hitbtc Exchange API"}
|
|
12
|
+
spec.summary = %q{"Wrapper for hitbtc Exchange API"}
|
|
13
|
+
spec.homepage = "https://github.com/uberamd/hitbtc_ruby"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files`.split($/)
|
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
spec.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
21
|
+
spec.add_development_dependency "rake"
|
|
22
|
+
spec.add_development_dependency "rspec"
|
|
23
|
+
|
|
24
|
+
spec.add_dependency "httparty"
|
|
25
|
+
spec.add_dependency "hashie"
|
|
26
|
+
spec.add_dependency "addressable"
|
|
27
|
+
end
|
data/key.yml.example
ADDED
data/lib/hitbtc.rb
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'base64'
|
|
3
|
+
require 'addressable/uri'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module Hitbtc
|
|
7
|
+
class Client
|
|
8
|
+
include HTTParty
|
|
9
|
+
|
|
10
|
+
def initialize(api_key=nil, api_secret=nil, options={})
|
|
11
|
+
@api_key = api_key || YAML.load_file("key.yml")["key"]
|
|
12
|
+
@api_secret = api_secret || YAML.load_file("key.yml")["secret"]
|
|
13
|
+
@api_version = options[:version] ||= '2'
|
|
14
|
+
@base_uri = options[:base_uri] ||= 'api.hitbtc.com'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
###########################
|
|
18
|
+
###### Public Data ########
|
|
19
|
+
###########################
|
|
20
|
+
|
|
21
|
+
def symbols
|
|
22
|
+
get_public 'symbol'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def ticker symbol
|
|
26
|
+
get_public("ticker/"+symbol.upcase)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def order_book symbol, opts={}
|
|
30
|
+
#opts parameter
|
|
31
|
+
#limit (number): Limit of orderbook levels, default 100. Set 0 to view full orderbook levels
|
|
32
|
+
get_public("orderbook/"+symbol.upcase, opts)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def trades symbol, from = (Time.now - 1.day).to_i, by = "ts", start_index = 0, max_results = 1000, opts={}
|
|
36
|
+
#Parameter Type Description
|
|
37
|
+
#from required int = trade_id or timestamp returns trades with trade_id > specified trade_id or returns trades with timestamp >= specified timestamp
|
|
38
|
+
#till optional int = trade_id or timestamp returns trades with trade_id < specified trade_id or returns trades with timestamp < specified timestamp
|
|
39
|
+
#by required filter and sort by trade_id or ts (timestamp)
|
|
40
|
+
#sort optional asc (default) or desc
|
|
41
|
+
#start_index required int zero-based
|
|
42
|
+
#max_results required int, max value = 1000
|
|
43
|
+
#format_item optional "array" (default) or "object"
|
|
44
|
+
#format_price optional "string" (default) or "number"
|
|
45
|
+
#format_amount optional "string" (default) or "number"
|
|
46
|
+
#format_amount_unit optional "currency" (default) or "lot"
|
|
47
|
+
#format_tid optional "string" or "number" (default)
|
|
48
|
+
#format_timestamp optional "millisecond" (default) or "second"
|
|
49
|
+
#format_wrap optional "true" (default) or "false"
|
|
50
|
+
if by != "trade_id" && by != "ts"
|
|
51
|
+
raise "3rd parameter by, should be 'trade_id' or 'ts'"
|
|
52
|
+
end
|
|
53
|
+
opts[:from] = from
|
|
54
|
+
opts[:start_index] = start_index
|
|
55
|
+
opts[:max_results] = max_results
|
|
56
|
+
opts[:by] = by
|
|
57
|
+
opts[:symbol] = symbol.upcase
|
|
58
|
+
mash= get_public('trades', opts)
|
|
59
|
+
mash.try(:trades)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def get_public(method, opts={})
|
|
63
|
+
url = 'https://'+ @base_uri + '/api/' + @api_version + '/public/' + method
|
|
64
|
+
r = self.class.get(url, query: opts)
|
|
65
|
+
JSON.parse(r.body)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
######################
|
|
69
|
+
##### Private Data ###
|
|
70
|
+
######################
|
|
71
|
+
|
|
72
|
+
def balance #array of string currency
|
|
73
|
+
get_private 'trading/balance'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def active_orders opts={}
|
|
77
|
+
#opts parameter
|
|
78
|
+
#symbol (string): Optional parameter to filter active orders by symbol
|
|
79
|
+
get_private 'order', opts
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def cancel_order client_order_id
|
|
83
|
+
delete_private 'order/'+client_order_id
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def trade_history opts={}
|
|
87
|
+
get_private 'history/trades', opts
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def recent_orders opts={}
|
|
91
|
+
get_private 'history/order', opts
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def create_order opts={}
|
|
95
|
+
# clientOrderId (String): Optional parameter, if skipped - will be generated by server. Uniqueness must be guaranteed within a single trading day, including all active orders.
|
|
96
|
+
# symbol (String): Trading symbol
|
|
97
|
+
# side (String): sell buy
|
|
98
|
+
# type (String): Optional. Default - limit. One of: limit, market, stopLimit, stopMarket
|
|
99
|
+
# timeInForce (String): Optional. Default - GDC. One of: GTC, IOC, FOK, Day, GTD
|
|
100
|
+
# quantity (Number): Order quantity
|
|
101
|
+
# price (Number): Order price. Required for limit types.
|
|
102
|
+
# stopPrice (Number): Required for stop types.
|
|
103
|
+
# expireTime (Datetime): Required for GTD timeInForce.
|
|
104
|
+
# strictValidate (Boolean): Price and quantity will be checked that they increment within tick size and quantity step. See symbol tickSize and quantityIncrement
|
|
105
|
+
post_private 'order', opts
|
|
106
|
+
end
|
|
107
|
+
######################
|
|
108
|
+
##### Payment Data ###
|
|
109
|
+
######################
|
|
110
|
+
|
|
111
|
+
# to be written
|
|
112
|
+
|
|
113
|
+
#######################
|
|
114
|
+
#### Generate Signed ##
|
|
115
|
+
##### Post Request ####
|
|
116
|
+
#######################
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def post_private(method, opts={})
|
|
121
|
+
post_data = encode_options(opts)
|
|
122
|
+
uri = "/api/"+ @api_version + "/" + method
|
|
123
|
+
url = "https://" + @base_uri + uri
|
|
124
|
+
|
|
125
|
+
r = self.class.post(url, {basic_auth: {username: @api_key, password: @api_secret}, body: post_data}).parsed_response
|
|
126
|
+
r
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def get_private(method, opts={})
|
|
130
|
+
opts = complete_opts(opts)
|
|
131
|
+
uri = "/api/"+ @api_version + "/" + method +"?" + encode_options(opts)
|
|
132
|
+
url = "https://" + @base_uri + uri
|
|
133
|
+
|
|
134
|
+
r = self.class.get(url, basic_auth: {username: @api_key, password: @api_secret})
|
|
135
|
+
JSON.parse(r.body)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def delete_private(method, opts={})
|
|
139
|
+
post_data = encode_options(opts)
|
|
140
|
+
uri = "/api/"+ @api_version + "/" + method
|
|
141
|
+
url = "https://" + @base_uri + uri
|
|
142
|
+
|
|
143
|
+
r = self.class.delete(url, basic_auth: {username: @api_key, password: @api_secret}).parsed_response
|
|
144
|
+
r
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def complete_opts opts
|
|
148
|
+
opts[:apikey] = @api_key
|
|
149
|
+
opts[:nonce] = nonce
|
|
150
|
+
opts
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def nonce
|
|
154
|
+
DateTime.now.strftime('%Q')
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def encode_options(opts)
|
|
158
|
+
uri = Addressable::URI.new
|
|
159
|
+
uri.query_values = opts
|
|
160
|
+
uri.query
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hitbtc-uberamd
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.4
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Steve Morrissey
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-06-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.3'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: httparty
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: hashie
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: addressable
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: '"Wrapper for hitbtc Exchange API"'
|
|
98
|
+
email:
|
|
99
|
+
- uberamd@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- Gemfile
|
|
106
|
+
- README.md
|
|
107
|
+
- hitbtc.gemspec
|
|
108
|
+
- key.yml.example
|
|
109
|
+
- lib/hitbtc.rb
|
|
110
|
+
- lib/hitbtc/client.rb
|
|
111
|
+
- lib/hitbtc/version.rb
|
|
112
|
+
homepage: https://github.com/uberamd/hitbtc_ruby
|
|
113
|
+
licenses: []
|
|
114
|
+
metadata: {}
|
|
115
|
+
post_install_message:
|
|
116
|
+
rdoc_options: []
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
|
+
requirements:
|
|
126
|
+
- - ">="
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0'
|
|
129
|
+
requirements: []
|
|
130
|
+
rubyforge_project:
|
|
131
|
+
rubygems_version: 2.6.11
|
|
132
|
+
signing_key:
|
|
133
|
+
specification_version: 4
|
|
134
|
+
summary: '"Wrapper for hitbtc Exchange API"'
|
|
135
|
+
test_files: []
|