coinbase-exchange 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -17
- data/lib/coinbase/exchange/api_client.rb +1 -1
- data/lib/coinbase/exchange/api_object.rb +1 -1
- data/lib/coinbase/exchange/version.rb +1 -1
- data/lib/coinbase/exchange/websocket.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54f04f4a12f214f1a37db3054e1031b1fd4a0bb0
|
4
|
+
data.tar.gz: bf46385ba9aedec7f1f1c4b9a1e0d534498d2442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e81e5e21f6f5c2c9d769cec76cd48193b5491ea619bd61029164ae14abac415af9aa4dfd42d7b3b2e98c8039616557387dc7f51c0b0641c2125d46db1d81fcd
|
7
|
+
data.tar.gz: 85ded1dfa7a5b7d3627b5867d6703a08e07945fec1607d65e5d882033f933b5f319bae3dca743bcc4141b333a29dc36650cd2243bc8e0a1bc5e054cbb9cec682
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# GDAX Ruby library
|
2
2
|
|
3
3
|
## REST Client
|
4
4
|
|
5
5
|
We provide an exchange client that is a thin wrapper over the exchange API. The purpose of this Readme is to provide context for using the gem effectively. For a detailed overview of the information that's available through the API, we recommend consulting the official documentation.
|
6
|
-
* https://docs.
|
6
|
+
* https://docs.gdax.com/#api
|
7
7
|
|
8
8
|
We provide a synchronous and asynchronous client. The only functional difference between the two clients is that the asynchronous client must be started inside the Eventmachine reactor loop.
|
9
9
|
|
@@ -42,7 +42,7 @@ EM.run {
|
|
42
42
|
### Initialization
|
43
43
|
|
44
44
|
To initialize the client, simply pass in an API Key, API Secret, and API Passphrase which you generate on the web interface:
|
45
|
-
* https://
|
45
|
+
* https://gdax.com/settings
|
46
46
|
|
47
47
|
```ruby
|
48
48
|
rest_api = Coinbase::Exchange::Client.new(api_key, api_secret, api_pass)
|
@@ -54,7 +54,7 @@ rest_api = Coinbase::Exchange::AsyncClient.new(api_key, api_secret, api_pass)
|
|
54
54
|
|
55
55
|
**Default Product**
|
56
56
|
|
57
|
-
|
57
|
+
GDAX supports trading bitcoin in several currencies. If you wish to trade a different currency, you can specify an alternative default currency.
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
gbp_client = Coinbase::Exchange::Client.new(api_key, api_secret, api_pass,
|
@@ -67,7 +67,7 @@ You can initialize a connection to the sandbox by specifying an alternative api
|
|
67
67
|
|
68
68
|
```ruby
|
69
69
|
sandbox = Coinbase::Exchange::Client.new(api_key, api_secret, api_pass,
|
70
|
-
api_url: "https://api-public.sandbox.
|
70
|
+
api_url: "https://api-public.sandbox.gdax.com")
|
71
71
|
```
|
72
72
|
|
73
73
|
### Methods
|
@@ -92,7 +92,7 @@ p "Spot Rate: $ %.2f" % BigDecimal(resp['price'])
|
|
92
92
|
The gem will automatically encode any additional parameters you pass to method calls. For instance to get the full orderbook, you must explicitly set the level parameter to 3.
|
93
93
|
|
94
94
|
```ruby
|
95
|
-
rest_api.orderbook(
|
95
|
+
rest_api.orderbook(level: 3) do |resp|
|
96
96
|
p "There are #{resp['bids'].count} open bids on the orderbook"
|
97
97
|
p "There are #{resp['asks'].count} open asks on the orderbook"
|
98
98
|
end
|
@@ -100,9 +100,9 @@ end
|
|
100
100
|
|
101
101
|
### Return Values
|
102
102
|
|
103
|
-
Data format is a sensitive issue when writing financial software. The exchange API represents monetary data in string format. This is a good intermediary data format for the user to apply their own data format, but is not
|
103
|
+
Data format is a sensitive issue when writing financial software. The exchange API represents monetary data in string format. This is a good intermediary data format for the user to apply their own data format, but is not especially useful on its own.
|
104
104
|
|
105
|
-
For representing monetary data in ruby, we
|
105
|
+
For representing monetary data in ruby, we recommend using the [BigDecimal] (http://ruby-doc.org/stdlib-2.1.1/libdoc/bigdecimal/rdoc/BigDecimal.html) library. If you access data by calling response items as though they were methods on the response itself. If you access data this way, any numerical data will be converted to BigDecimal format.
|
106
106
|
|
107
107
|
```ruby
|
108
108
|
rest_api.orders(before: Time.now - 60*60) do |resp|
|
@@ -140,7 +140,7 @@ end
|
|
140
140
|
|
141
141
|
## Endpoints
|
142
142
|
|
143
|
-
### [Market Data] (https://docs.
|
143
|
+
### [Market Data] (https://docs.gdax.com/#market-data)
|
144
144
|
|
145
145
|
Coinbase supports trading in multiple currencies. When interacting with market data, you can get information about a product other than your default by setting the product_id parameter.
|
146
146
|
|
@@ -209,7 +209,7 @@ Downloads recent trades. Please be aware that if you don't explicitly pass a be
|
|
209
209
|
|
210
210
|
```ruby
|
211
211
|
rest_api.trade_history(before: Time.now - 10*60) do |resp|
|
212
|
-
p "#{resp.count} trades have
|
212
|
+
p "#{resp.count} trades have occurred in the past 10 minutes."
|
213
213
|
end
|
214
214
|
```
|
215
215
|
|
@@ -234,7 +234,7 @@ rest_api.daily_stats do |resp|
|
|
234
234
|
end
|
235
235
|
```
|
236
236
|
|
237
|
-
### [Accounts] (https://docs.
|
237
|
+
### [Accounts] (https://docs.gdax.com/#accounts)
|
238
238
|
|
239
239
|
**accounts**
|
240
240
|
|
@@ -260,7 +260,7 @@ end
|
|
260
260
|
|
261
261
|
**account_history**
|
262
262
|
|
263
|
-
Downloads a ledger of transfers, matches, and fees associated with an account. You must pass the account id as the first
|
263
|
+
Downloads a ledger of transfers, matches, and fees associated with an account. You must pass the account id as the first parameter.
|
264
264
|
|
265
265
|
```ruby
|
266
266
|
rest_api.account_history(account_id) do |resp|
|
@@ -278,7 +278,7 @@ rest_api.account_holds(account_id) do |resp|
|
|
278
278
|
end
|
279
279
|
```
|
280
280
|
|
281
|
-
### [Orders] (https://docs.
|
281
|
+
### [Orders] (https://docs.gdax.com/#orders)
|
282
282
|
|
283
283
|
**bid**
|
284
284
|
|
@@ -332,7 +332,7 @@ end
|
|
332
332
|
|
333
333
|
**orders**
|
334
334
|
|
335
|
-
Downloads a list of all
|
335
|
+
Downloads a list of all your orders. Most likely, you'll only care about your open orders when using this.
|
336
336
|
|
337
337
|
```ruby
|
338
338
|
rest_api.orders(status: open) do |resp|
|
@@ -360,7 +360,7 @@ rest_api.fills do |resp|
|
|
360
360
|
end
|
361
361
|
```
|
362
362
|
|
363
|
-
### [Transfers] (https://docs.
|
363
|
+
### [Transfers] (https://docs.gdax.com/#transfer-funds)
|
364
364
|
|
365
365
|
**deposit**
|
366
366
|
|
@@ -398,9 +398,9 @@ end
|
|
398
398
|
|
399
399
|
We recommend reading the official websocket documentation before proceeding.
|
400
400
|
|
401
|
-
* https://docs.
|
401
|
+
* https://docs.gdax.com/#websocket-feed
|
402
402
|
|
403
|
-
We provide a websocket interface in the gem for convenience. This is typically used to build a real-time orderbook, although it can also be used for simpler purposes such as tracking the market rate, or tracking when your orders fill. Like the asynchronous client, this depends Eventmachine for
|
403
|
+
We provide a websocket interface in the gem for convenience. This is typically used to build a real-time orderbook, although it can also be used for simpler purposes such as tracking the market rate, or tracking when your orders fill. Like the asynchronous client, this depends Eventmachine for asynchronous processing.
|
404
404
|
|
405
405
|
Please consider setting the keepalive flag to true when initializing the websocket. This will cause the websocket to proactively refresh the connection whenever it closes.
|
406
406
|
|
@@ -3,7 +3,7 @@ module Coinbase
|
|
3
3
|
# Net-http client for Coinbase Exchange API
|
4
4
|
class APIClient
|
5
5
|
def initialize(api_key = '', api_secret = '', api_pass = '', options = {})
|
6
|
-
@api_uri = URI.parse(options[:api_url] || "https://api.
|
6
|
+
@api_uri = URI.parse(options[:api_url] || "https://api.gdax.com")
|
7
7
|
@api_pass = api_pass
|
8
8
|
@api_key = api_key
|
9
9
|
@api_secret = api_secret
|
@@ -3,7 +3,7 @@ module Coinbase
|
|
3
3
|
# Websocket client for Coinbase Exchange
|
4
4
|
class Websocket
|
5
5
|
def initialize(options = {})
|
6
|
-
@ws_url = options[:ws_url] || "wss://ws-feed.
|
6
|
+
@ws_url = options[:ws_url] || "wss://ws-feed.gdax.com"
|
7
7
|
@product = options[:product_id] || 'BTC-USD'
|
8
8
|
@keepalive = options[:keepalive] || false
|
9
9
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinbase-exchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Duhamel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.5.1
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Client library for Coinbase Exchange
|