coin_falcon 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +9 -1
- data/README.md +43 -5
- data/coin_falcon.gemspec +2 -0
- data/lib/coin_falcon/client.rb +1 -1
- data/lib/coin_falcon/version.rb +1 -1
- data/lib/coin_falcon/websocket_client.rb +62 -0
- data/lib/coin_falcon.rb +5 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cf549899440b504ac92dd7c53b25356ccc07443e21e424e685a56e2bf31a791
|
4
|
+
data.tar.gz: b1506d575d9dfce685b9dbf0fa7ec1841962e04a908abb6c3263875cd33c8b7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d3222b7e5561a48a760d08ea22a1b8f7cb285b769abb2d5c5cdfe4a698e89b173957fcd9b762f44ed6e02036479cce263018443cc1855e04aa0b25c51d4318a
|
7
|
+
data.tar.gz: 51ecc3d86a2bcb7ebd613331a6fddcc6352d541c599ce3488b9a962e8bad2a75a6d8c96cc4b952a09058866acb10887d34f6c51d4366fcf5e26afd8805cef042
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
coin_falcon (0.0.
|
4
|
+
coin_falcon (0.0.2)
|
5
|
+
faye-websocket
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -9,6 +10,10 @@ GEM
|
|
9
10
|
byebug (10.0.0)
|
10
11
|
coderay (1.1.2)
|
11
12
|
diff-lcs (1.3)
|
13
|
+
eventmachine (1.2.5)
|
14
|
+
faye-websocket (0.10.7)
|
15
|
+
eventmachine (>= 0.12.0)
|
16
|
+
websocket-driver (>= 0.5.1)
|
12
17
|
method_source (0.9.0)
|
13
18
|
pry (0.11.3)
|
14
19
|
coderay (~> 1.1.0)
|
@@ -30,6 +35,9 @@ GEM
|
|
30
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
36
|
rspec-support (~> 3.7.0)
|
32
37
|
rspec-support (3.7.1)
|
38
|
+
websocket-driver (0.7.0)
|
39
|
+
websocket-extensions (>= 0.1.0)
|
40
|
+
websocket-extensions (0.1.3)
|
33
41
|
|
34
42
|
PLATFORMS
|
35
43
|
ruby
|
data/README.md
CHANGED
@@ -20,7 +20,9 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
The
|
23
|
+
The client needs to be configured with your account's `key` and `secret` which is available in your CoinFalcon Dashboard:
|
24
|
+
|
25
|
+
## API Client
|
24
26
|
|
25
27
|
```ruby
|
26
28
|
require 'coin_falcon'
|
@@ -31,15 +33,13 @@ client = CoinFalcon::Client.new(key, secret)
|
|
31
33
|
It is also possible to set up an API `endpoint` and `version`:
|
32
34
|
|
33
35
|
```ruby
|
34
|
-
require 'coin_falcon'
|
35
|
-
|
36
36
|
client = CoinFalcon::Client.new(key, secret, endpoint, version)
|
37
37
|
```
|
38
38
|
|
39
39
|
Defaults:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
ENDPOINT = 'https://
|
42
|
+
ENDPOINT = 'https://coinfalcon.com'
|
43
43
|
VERSION = 1
|
44
44
|
```
|
45
45
|
|
@@ -72,7 +72,7 @@ client.my_orders
|
|
72
72
|
### List trades
|
73
73
|
|
74
74
|
```ruby
|
75
|
-
client.my_trades
|
75
|
+
client.my_trades(market: 'ETH-BTC')
|
76
76
|
```
|
77
77
|
|
78
78
|
### Deposit address
|
@@ -130,6 +130,44 @@ client.orderbook('ETH-BTC')
|
|
130
130
|
client.orderbook('ETH-BTC', level: 3)
|
131
131
|
```
|
132
132
|
|
133
|
+
## Websocket Client
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
require 'coin_falcon'
|
137
|
+
|
138
|
+
websocket_client = CoinFalcon::WebsocketClient.new(key, secret)
|
139
|
+
```
|
140
|
+
|
141
|
+
It is also possible to set up an `endpoint`:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
websocket_client = CoinFalcon::WebsocketClient.new(key, secret, endpoint)
|
145
|
+
```
|
146
|
+
|
147
|
+
Defaults:
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
ENDPOINT = 'wss://ws.coinfalcon.com'
|
151
|
+
```
|
152
|
+
|
153
|
+
### Set up channels
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
websocket_client.channels << { channel: 'TickerChannel' } << { channel: 'OrderbookChannel', market: 'ETH-BTC' }
|
157
|
+
```
|
158
|
+
|
159
|
+
### Run feed
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
websocket_client.feed
|
163
|
+
```
|
164
|
+
|
165
|
+
It is also possible to send a block
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
websocket_client.feed { |msg| puts msg }
|
169
|
+
```
|
170
|
+
|
133
171
|
## Contributing
|
134
172
|
|
135
173
|
Bug reports and pull requests are welcome on GitHub at https://github.com/thetonyrom/coin_falcon
|
data/coin_falcon.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
+
spec.add_dependency 'faye-websocket'
|
24
|
+
|
23
25
|
spec.add_development_dependency "bundler", "~> 1.16"
|
24
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/lib/coin_falcon/client.rb
CHANGED
@@ -2,7 +2,7 @@ module CoinFalcon
|
|
2
2
|
# Client executes requests against the CoinFalcon API.
|
3
3
|
#
|
4
4
|
class Client
|
5
|
-
ENDPOINT = 'https://
|
5
|
+
ENDPOINT = 'https://coinfalcon.com'.freeze
|
6
6
|
VERSION = 1
|
7
7
|
|
8
8
|
def initialize(key, secret, endpoint = ENDPOINT, version = VERSION)
|
data/lib/coin_falcon/version.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
module CoinFalcon
|
2
|
+
class WebsocketClient
|
3
|
+
ENDPOINT = 'wss://ws.coinfalcon.com'.freeze
|
4
|
+
AUTH_PATH = '/auth/feed'.freeze
|
5
|
+
|
6
|
+
attr_accessor :channels
|
7
|
+
|
8
|
+
def initialize(key = nil, secret = nil, endpoint = ENDPOINT)
|
9
|
+
@endpoint = endpoint
|
10
|
+
@channels = []
|
11
|
+
@cipher = Cipher.new(key, secret)
|
12
|
+
end
|
13
|
+
|
14
|
+
def feed
|
15
|
+
EM.run do
|
16
|
+
@ws = Faye::WebSocket::Client.new(@endpoint, nil, { headers: headers })
|
17
|
+
|
18
|
+
@ws.on :open do |event|
|
19
|
+
channels.each { |channel| subscribe(channel) }
|
20
|
+
end
|
21
|
+
|
22
|
+
@ws.on :message do |event|
|
23
|
+
data = JSON.parse(event.data)
|
24
|
+
|
25
|
+
if block_given?
|
26
|
+
yield data
|
27
|
+
else
|
28
|
+
p [:message, data]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@ws.on :close do |event|
|
33
|
+
p [:close, event.code, event.reason]
|
34
|
+
@ws = nil
|
35
|
+
EM.stop
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def subscribe(identifier)
|
41
|
+
request = { command: :subscribe, identifier: identifier.to_json }.to_json
|
42
|
+
|
43
|
+
@ws.send(request)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def request
|
49
|
+
@request ||= Request.new(:get, AUTH_PATH, nil)
|
50
|
+
end
|
51
|
+
|
52
|
+
def headers
|
53
|
+
@cipher.sign!(request)
|
54
|
+
|
55
|
+
{
|
56
|
+
'CF-API-KEY' => request['CF-API-KEY'],
|
57
|
+
'CF-API-TIMESTAMP' => request['CF-API-TIMESTAMP'],
|
58
|
+
'CF-API-SIGNATURE' => request['CF-API-SIGNATURE']
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/coin_falcon.rb
CHANGED
@@ -2,12 +2,17 @@ require 'net/http'
|
|
2
2
|
require 'openssl'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
+
require 'faye/websocket'
|
6
|
+
require 'eventmachine'
|
7
|
+
|
5
8
|
require 'coin_falcon/cipher'
|
6
9
|
require 'coin_falcon/client'
|
7
10
|
require 'coin_falcon/connection'
|
8
11
|
require 'coin_falcon/request'
|
9
12
|
require 'coin_falcon/response'
|
10
13
|
|
14
|
+
require 'coin_falcon/websocket_client'
|
15
|
+
|
11
16
|
require 'coin_falcon/version'
|
12
17
|
|
13
18
|
module CoinFalcon
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coin_falcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Rom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faye-websocket
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +105,7 @@ files:
|
|
91
105
|
- lib/coin_falcon/request.rb
|
92
106
|
- lib/coin_falcon/response.rb
|
93
107
|
- lib/coin_falcon/version.rb
|
108
|
+
- lib/coin_falcon/websocket_client.rb
|
94
109
|
homepage: https://github.com/thetonyrom/coin_falcon
|
95
110
|
licenses:
|
96
111
|
- MIT
|