waves_ruby_client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -2
- data/lib/waves_ruby_client.rb +2 -0
- data/lib/waves_ruby_client/api.rb +5 -0
- data/lib/waves_ruby_client/data_feed.rb +18 -0
- data/lib/waves_ruby_client/order.rb +1 -0
- data/lib/waves_ruby_client/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0609f848a6ff3450ed867e659805f853a22217d5'
|
4
|
+
data.tar.gz: b8090c0b342154555b30fbf859749a16096420a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02b4404e59aef17963ce24f319938aebb99d3d5b8dfe2443b4869b6913da316f7841ef29e84a376bb70f61156fb9ced598d443b844ebacae8ed9c4c73abcd4a7
|
7
|
+
data.tar.gz: fc1fb405768692c14274d332c33bb9a5932f6e95c0cfd56ca0838170209b760d86e45947412883a0754abd5383bee8da7f1aeb656796d6ff18945f13ecced949
|
data/README.md
CHANGED
@@ -30,15 +30,17 @@ The gem requires the following environment variables
|
|
30
30
|
* WAVES_PRIVATE_KEY: your waves private key, necessary for signing requests
|
31
31
|
* WAVES_ADDRESS: your waves address
|
32
32
|
|
33
|
+
|
33
34
|
Optionally you can override the waves API URL (https://nodes.wavesnodes.com) and
|
34
35
|
the matcher public key (7kPFrHDiGw1rCm7LPszuECwWYL3dMf6iMifLRDJQZMzy) by setting the following environement variables:
|
35
36
|
|
36
37
|
* WAVES_API_URL
|
37
38
|
* WAVES_MATCHER_PUBLIC_KEY
|
38
39
|
|
40
|
+
|
39
41
|
### Order book
|
40
42
|
|
41
|
-
Shows
|
43
|
+
Shows the current order book
|
42
44
|
|
43
45
|
```ruby
|
44
46
|
book = WavesRubyClient::OrderBook.btc_waves
|
@@ -97,7 +99,7 @@ order.pending?
|
|
97
99
|
### Transaction
|
98
100
|
|
99
101
|
WavesRubyClient can list unconfirmed transactions. This can be used to wait for
|
100
|
-
the transaction of a filled order
|
102
|
+
the transaction of a filled order before placing the next order.
|
101
103
|
|
102
104
|
```ruby
|
103
105
|
# order was filled
|
@@ -114,6 +116,26 @@ WavesRubyClient::Wallet.balance
|
|
114
116
|
=> { waves: 5002.3, btc: 1200.3 }
|
115
117
|
```
|
116
118
|
|
119
|
+
### DataFeed
|
120
|
+
|
121
|
+
#### Current price
|
122
|
+
|
123
|
+
Returns the last traded price as a float number
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
WavesRubyClient::DataFeed.current_price
|
127
|
+
=> 0.000726
|
128
|
+
```
|
129
|
+
|
130
|
+
#### Trade history
|
131
|
+
|
132
|
+
Returns a list of filled Orders representing the last n trades
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
WavesRubyClient::DataFeed.trade_history(10)
|
136
|
+
=> [<WavesRubyClient::Order:0x0055d4746715d0, ...]
|
137
|
+
```
|
138
|
+
|
117
139
|
## Development
|
118
140
|
|
119
141
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/waves_ruby_client.rb
CHANGED
@@ -17,6 +17,7 @@ require 'waves_ruby_client/version'
|
|
17
17
|
require 'waves_ruby_client/asset'
|
18
18
|
require 'waves_ruby_client/conversion'
|
19
19
|
require 'waves_ruby_client/api'
|
20
|
+
require 'waves_ruby_client/data_feed'
|
20
21
|
require 'waves_ruby_client/order_book'
|
21
22
|
require 'waves_ruby_client/order_data/place'
|
22
23
|
require 'waves_ruby_client/order_data/cancel'
|
@@ -32,6 +33,7 @@ module WavesRubyClient
|
|
32
33
|
API_URL = ENV['WAVES_API_URL'] || 'https://nodes.wavesnodes.com'
|
33
34
|
MATCHER_PUBLIC_KEY = ENV['WAVES_MATCHER_PUBLIC_KEY'] ||
|
34
35
|
'7kPFrHDiGw1rCm7LPszuECwWYL3dMf6iMifLRDJQZMzy'
|
36
|
+
DATA_FEED_URL = 'http://marketdata.wavesplatform.com/api'
|
35
37
|
|
36
38
|
BTC_ASSET_ID = '8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'
|
37
39
|
WAVES_ASSET_ID = 'WAVES'
|
@@ -11,6 +11,11 @@ module WavesRubyClient
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def call_data_feed(path)
|
15
|
+
response = HTTParty.get(WavesRubyClient::DATA_FEED_URL + path)
|
16
|
+
JSON.parse(response.body)
|
17
|
+
end
|
18
|
+
|
14
19
|
def call(path, method = :get, args = {})
|
15
20
|
response = HTTParty.send(method, WavesRubyClient::API_URL + path, args)
|
16
21
|
JSON.parse(response.body)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module WavesRubyClient
|
2
|
+
# query data feed
|
3
|
+
class DataFeed
|
4
|
+
def self.current_price
|
5
|
+
trade_history(1).first.price
|
6
|
+
end
|
7
|
+
|
8
|
+
# get history from data feed
|
9
|
+
def self.trade_history(count = 10)
|
10
|
+
WavesRubyClient::Api.instance.call_data_feed("/trades/WAVES/BTC/#{count}").map do |order|
|
11
|
+
order['price'] = order['price'].to_f
|
12
|
+
order['timestamp'] = order['timestamp'] / 1000
|
13
|
+
order['amount'] = order['amount'].to_f
|
14
|
+
WavesRubyClient::Order.new(order)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -8,6 +8,7 @@ module WavesRubyClient
|
|
8
8
|
JSON_HEADERS = { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.freeze
|
9
9
|
|
10
10
|
attr_accessor :type, :amount, :id, :timestamp, :status, :price
|
11
|
+
attr_accessor :confirmed, :buyer, :seller, :matcher
|
11
12
|
attr_writer :filled
|
12
13
|
|
13
14
|
# get all orders for WAVES_PUBLIC_KEY
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waves_ruby_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Großelfinger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/waves_ruby_client/api.rb
|
136
136
|
- lib/waves_ruby_client/asset.rb
|
137
137
|
- lib/waves_ruby_client/conversion.rb
|
138
|
+
- lib/waves_ruby_client/data_feed.rb
|
138
139
|
- lib/waves_ruby_client/order.rb
|
139
140
|
- lib/waves_ruby_client/order_book.rb
|
140
141
|
- lib/waves_ruby_client/order_data/cancel.rb
|
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
167
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.6.
|
168
|
+
rubygems_version: 2.6.11
|
168
169
|
signing_key:
|
169
170
|
specification_version: 4
|
170
171
|
summary: Ruby Client for Waves Platform API
|