deribit-api 0.1.5 → 2.0.0
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/.travis.yml +6 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +71 -48
- data/README.md +63 -76
- data/TODOs.org +8 -2
- data/bin/auth.sh +18 -0
- data/bin/trades.py +24 -0
- data/bin/trades.rb +43 -0
- data/bin/whales-watching.rb +25 -0
- data/deribit.gemspec +8 -5
- data/lib/deribit.rb +21 -8
- data/lib/deribit/authentication.rb +9 -14
- data/lib/deribit/client.rb +203 -350
- data/lib/deribit/http.rb +20 -13
- data/lib/deribit/naming.rb +82 -0
- data/lib/deribit/version.rb +1 -1
- data/lib/deribit/websocket.rb +73 -54
- metadata +55 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 422e81fb17f6553ba4134eccd91c60a0302382f8d4fee41612dbbf3776611dcf
|
4
|
+
data.tar.gz: 310376552ad707248f101f9a725a40cf44e1ba2a7b2fa50f1a0086df79f571a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bbc05068ec6091bea20b1e17225473522ed098ea4a8a4805f8f26e6a016a6262e68a79f900752fc6768d7bf4b5cf88265156980e53361ce5285dc5b2cf8877b
|
7
|
+
data.tar.gz: ae453b99dea64befcff8eac0a0349a4189cc2a62d62957262575a500f0bf8a161bdc4e09e271ae4483147438b8e990b27ea6b28f1e14719973b4326f08163c03
|
data/.travis.yml
CHANGED
@@ -3,8 +3,7 @@ sudo: false
|
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.7.0
|
6
|
+
- 2.7
|
8
7
|
|
9
8
|
env:
|
10
9
|
global:
|
@@ -12,11 +11,14 @@ env:
|
|
12
11
|
|
13
12
|
before_install:
|
14
13
|
- gem install bundler
|
15
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
-
- chmod +x ./cc-test-reporter
|
17
14
|
|
18
15
|
before_script:
|
16
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
17
|
+
- chmod +x ./cc-test-reporter
|
19
18
|
- ./cc-test-reporter before-build
|
20
19
|
|
20
|
+
script:
|
21
|
+
- bundle exec rake test
|
22
|
+
|
21
23
|
after_script:
|
22
24
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [2.0.0] - 2020-04-23
|
9
|
+
### Added
|
10
|
+
- implementation for API 2.0
|
11
|
+
### Changed
|
12
|
+
- all tests
|
13
|
+
### Removed
|
14
|
+
- old 1.0 related code
|
15
|
+
|
8
16
|
## [0.1.5] - 2020-01-09
|
9
17
|
### Added
|
10
18
|
- latest Ruby 2.7 in Travis
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,80 +1,100 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deribit-api (0.
|
4
|
+
deribit-api (2.0.0)
|
5
5
|
faraday
|
6
6
|
faraday-detailed_logger
|
7
7
|
faraday_middleware
|
8
|
-
faye-websocket
|
9
8
|
hashie
|
9
|
+
websocket-client-simple
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
14
|
ast (2.4.0)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
19
|
-
bump (0.8.0)
|
20
|
-
codeclimate-engine-rb (0.4.1)
|
21
|
-
virtus (~> 1.0)
|
15
|
+
backport (1.1.2)
|
16
|
+
benchmark (0.1.0)
|
17
|
+
bump (0.9.0)
|
22
18
|
coderay (1.1.2)
|
23
|
-
coercible (1.0.0)
|
24
|
-
descendants_tracker (~> 0.0.1)
|
25
|
-
descendants_tracker (0.0.4)
|
26
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
27
19
|
docile (1.3.2)
|
28
20
|
dotenv (2.7.5)
|
29
|
-
|
30
|
-
|
31
|
-
faraday (0.
|
21
|
+
e2mmap (0.1.0)
|
22
|
+
event_emitter (0.2.6)
|
23
|
+
faraday (1.0.1)
|
32
24
|
multipart-post (>= 1.2, < 3)
|
33
|
-
faraday-detailed_logger (2.
|
25
|
+
faraday-detailed_logger (2.3.0)
|
34
26
|
faraday (>= 0.8, < 2)
|
35
|
-
faraday_middleware (0.
|
36
|
-
faraday (
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
json (2.3.0)
|
27
|
+
faraday_middleware (1.0.0)
|
28
|
+
faraday (~> 1.0)
|
29
|
+
hashie (4.1.0)
|
30
|
+
io-console (0.5.6)
|
31
|
+
irb (1.2.3)
|
32
|
+
reline (>= 0.0.1)
|
33
|
+
jaro_winkler (1.5.4)
|
43
34
|
kwalify (0.7.2)
|
44
|
-
|
45
|
-
|
35
|
+
maruku (0.7.3)
|
36
|
+
method_source (1.0.0)
|
37
|
+
mini_portile2 (2.4.0)
|
38
|
+
minitest (5.14.0)
|
46
39
|
multipart-post (2.1.1)
|
47
|
-
|
40
|
+
nokogiri (1.10.9)
|
41
|
+
mini_portile2 (~> 2.4.0)
|
42
|
+
parallel (1.19.1)
|
43
|
+
parser (2.7.1.1)
|
48
44
|
ast (~> 2.4.0)
|
49
|
-
pry (0.
|
50
|
-
coderay (~> 1.1
|
51
|
-
method_source (~>
|
52
|
-
pry-doc (1.
|
45
|
+
pry (0.13.1)
|
46
|
+
coderay (~> 1.1)
|
47
|
+
method_source (~> 1.0)
|
48
|
+
pry-doc (1.1.0)
|
53
49
|
pry (~> 0.11)
|
54
50
|
yard (~> 0.9.11)
|
55
51
|
psych (3.1.0)
|
56
52
|
rainbow (3.0.0)
|
57
53
|
rake (13.0.1)
|
58
|
-
reek (
|
59
|
-
codeclimate-engine-rb (~> 0.4.0)
|
54
|
+
reek (6.0.0)
|
60
55
|
kwalify (~> 0.7.0)
|
61
|
-
parser (>= 2.5.0.0, < 2.
|
56
|
+
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
62
57
|
psych (~> 3.1.0)
|
63
58
|
rainbow (>= 2.0, < 4.0)
|
64
|
-
|
59
|
+
reline (0.1.3)
|
60
|
+
io-console (~> 0.5)
|
61
|
+
reverse_markdown (1.4.0)
|
62
|
+
nokogiri
|
63
|
+
rexml (3.2.4)
|
64
|
+
rubocop (0.82.0)
|
65
|
+
jaro_winkler (~> 1.5.1)
|
66
|
+
parallel (~> 1.10)
|
67
|
+
parser (>= 2.7.0.1)
|
68
|
+
rainbow (>= 2.2.2, < 4.0)
|
69
|
+
rexml
|
70
|
+
ruby-progressbar (~> 1.7)
|
71
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
72
|
+
ruby-progressbar (1.10.1)
|
73
|
+
simplecov (0.18.5)
|
65
74
|
docile (~> 1.1)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
simplecov-html (~> 0.11)
|
76
|
+
simplecov-html (0.12.2)
|
77
|
+
solargraph (0.38.6)
|
78
|
+
backport (~> 1.1)
|
79
|
+
benchmark
|
80
|
+
bundler (>= 1.17.2)
|
81
|
+
e2mmap
|
82
|
+
jaro_winkler (~> 1.5)
|
83
|
+
maruku (~> 0.7, >= 0.7.3)
|
84
|
+
nokogiri (~> 1.9, >= 1.9.1)
|
85
|
+
parser (~> 2.3)
|
86
|
+
reverse_markdown (~> 1.0, >= 1.0.5)
|
87
|
+
rubocop (~> 0.52)
|
88
|
+
thor (~> 1.0)
|
89
|
+
tilt (~> 2.0)
|
90
|
+
yard (~> 0.9)
|
91
|
+
thor (1.0.1)
|
92
|
+
tilt (2.0.10)
|
93
|
+
unicode-display_width (1.7.0)
|
94
|
+
websocket (1.2.8)
|
95
|
+
websocket-client-simple (0.3.0)
|
96
|
+
event_emitter
|
97
|
+
websocket
|
78
98
|
yard (0.9.24)
|
79
99
|
|
80
100
|
PLATFORMS
|
@@ -85,12 +105,15 @@ DEPENDENCIES
|
|
85
105
|
bundler
|
86
106
|
deribit-api!
|
87
107
|
dotenv
|
108
|
+
irb
|
88
109
|
minitest
|
89
110
|
pry
|
90
111
|
pry-doc
|
91
112
|
rake
|
92
113
|
reek
|
114
|
+
rubocop
|
93
115
|
simplecov
|
116
|
+
solargraph
|
94
117
|
|
95
118
|
BUNDLED WITH
|
96
119
|
2.1.4
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
[](https://www.rubydoc.info/gems/deribit-api)
|
9
9
|
[](https://github.com/icostan/deribit-api-ruby/blob/master/LICENSE)
|
10
10
|
|
11
|
-
Ruby library for [Deribit API](https://docs.deribit.com)
|
11
|
+
Idiomatic Ruby library for [Deribit API 2.0](https://docs.deribit.com)
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -32,125 +32,112 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
require 'deribit-api'
|
35
|
+
|
36
|
+
# for public data
|
37
|
+
client = Deribit::Client.new testnet: true, debug: true
|
38
|
+
|
39
|
+
# pass KEY and SECRET to access private data
|
40
|
+
client = Deribit::Client.new key: 'KEY', secret: 'SECRET'
|
35
41
|
```
|
36
42
|
|
37
|
-
|
43
|
+
Get trades via HTTP APIs:
|
38
44
|
|
39
45
|
```ruby
|
40
|
-
|
41
|
-
trades = client.trades 'options', count: 3
|
46
|
+
trades = client.trades instrument_name: 'BTC-PERPETUAL', count: 3
|
42
47
|
trades.first
|
43
|
-
|
44
|
-
trades.first.
|
45
|
-
|
48
|
+
=> #<Hashie::Mash amount=770.0 direction="sell" index_price=7088.57 instrument_name="BTC-PERPETUAL" price=7088.5 tick_direction=3 timestamp=1587632258141 trade_id="73366505" trade_seq=45738005>
|
49
|
+
trades.first.instrument_name
|
50
|
+
=> "BTC-PERPETUAL"
|
46
51
|
```
|
47
52
|
|
48
|
-
|
53
|
+
Streaming trades via Websocket APIs:
|
49
54
|
|
50
55
|
```ruby
|
51
|
-
client
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
=> 9.999957896
|
56
|
+
client.trades(instrument_name: 'BTC-PERPETUAL') do |trade|
|
57
|
+
puts trade
|
58
|
+
end
|
59
|
+
=> #<Hashie::Mash amount=10.0 direction="sell" index_price=7076.01 instrument_name="BTC-PERPETUAL" price=7076.0 tick_direction=3 timestamp=1587632546493 trade_id="73366877" trade_seq=45738278>
|
56
60
|
```
|
57
61
|
|
58
|
-
|
59
|
-
|
60
|
-
Fetch all tradable instruments:
|
62
|
+
Place a buy limit order:
|
61
63
|
|
62
64
|
```ruby
|
63
|
-
|
64
|
-
|
65
|
+
result = client.buy 'BTC-PERPETUAL', 10, price: 2500
|
66
|
+
=> #<Hashie::Mash order=#<Hashie::Mash amount=10 api=true average_price=0.0 commission=0.0 creation_timestamp=1587644442494 direction="buy" filled_amount=0 instrument_name="BTC-PERPETUAL" is_liquidation=false label="" last_update_timestamp=1587644442494 max_show=10 order_id="3887469320" order_state="open" order_type="limit" post_only=false price=2500.0 profit_loss=0.0 reduce_only=false replaced=false time_in_force="good_til_cancelled" web=false> trades=#<Hashie::Array []>>
|
65
67
|
```
|
66
68
|
|
67
|
-
|
69
|
+
Access generic HTTP API endpoints: <https://docs.deribit.com/#market-data>
|
68
70
|
|
69
71
|
```ruby
|
70
|
-
|
71
|
-
|
72
|
+
result = client.http.get '/public/ping'
|
73
|
+
=> "pong"
|
72
74
|
```
|
73
75
|
|
74
|
-
|
76
|
+
Access generic Websocket API channels: <https://docs.deribit.com/#subscriptions>
|
75
77
|
|
76
78
|
```ruby
|
77
|
-
|
78
|
-
|
79
|
+
client.websocket.subscribe 'user.portofolio.BTC' do |data|
|
80
|
+
puts data
|
79
81
|
end
|
80
82
|
```
|
81
83
|
|
82
|
-
|
84
|
+
### Examples
|
85
|
+
|
86
|
+
Fetch all tradable instruments:
|
83
87
|
|
84
88
|
```ruby
|
85
|
-
|
86
|
-
|
89
|
+
instruments = client.instruments
|
90
|
+
instruments.first
|
91
|
+
=> #<Hashie::Mash base_currency="BTC" contract_size=1.0 creation_timestamp=1587024008000 expiration_timestamp=1588320000000 instrument_name="BTC-1MAY20-6750-C" is_active=true kind="option" maker_commission=0.0004 min_trade_amount=0.1 option_type="call" quote_currency="USD" settlement_period="week" strike=6750.0 taker_commission=0.0004 tick_size=0.0005>
|
87
92
|
```
|
88
93
|
|
89
|
-
|
94
|
+
Place a buy market order:
|
90
95
|
|
91
96
|
```ruby
|
92
|
-
|
93
|
-
|
97
|
+
result = client.buy 'BTC-PERPETUAL', 10, type: :market
|
98
|
+
=> #<Hashie::Mash order=#<Hashie::Mash amount=10 api=true average_price=7153.0 commission=1.05e-06 creation_timestamp=1587644532209 direction="buy" filled_amount=10 instrument_name="BTC-PERPETUAL" is_liquidation=false label="" last_update_timestamp=1587644532209 max_show=10 order_id="3887472638" order_state="filled" order_type="market" post_only=false price=7259.0 profit_loss=0.0 reduce_only=false replaced=false time_in_force="good_til_cancelled" web=false> trades=#<Hashie::Array [#<Hashie::Mash amount=10.0 direction="buy" fee=1.05e-06 fee_currency="BTC" index_price=7155.93 instrument_name="BTC-PERPETUAL" liquidity="T" matching_id=nil order_id="3887472638" order_type="market" post_only=false price=7153.0 reduce_only=false self_trade=false state="filled" tick_direction=1 timestamp=1587644532209 trade_id="45283496" trade_seq=27671015>]>>
|
94
99
|
```
|
95
100
|
|
96
|
-
|
101
|
+
Close a position:
|
102
|
+
```ruby
|
103
|
+
result = client.close 'BTC-PERPETUAL'
|
104
|
+
=> #<Hashie::Array [#<Hashie::Mash amount=10.0 direction="sell" fee=1.05e-06 fee_currency="BTC" index_price=7153.91 instrument_name="BTC-PERPETUAL" liquidity="T" matching_id=nil order_id="3887474840" order_type="market" post_only=false price=7148.0 reduce_only=true self_trade=false state="filled" tick_direction=2 timestamp=1587644595002 trade_id="45283521" trade_seq=27671036>]>
|
105
|
+
```
|
106
|
+
|
107
|
+
Orderbook for BTCUSD perpetual instrument:
|
97
108
|
|
98
109
|
```ruby
|
99
|
-
|
100
|
-
|
110
|
+
orderbook = client.book instrument_name: 'BTC-PERPETUAL', depth: 3
|
111
|
+
puts orderbook.asks.first
|
112
|
+
```
|
113
|
+
|
114
|
+
Orderbook streaming via websocket:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
client.book instrument_name: 'ETH-PERPETUAL', group: 1, depth: 3 do |book|
|
118
|
+
puts book
|
101
119
|
end
|
102
120
|
```
|
103
121
|
|
104
|
-
|
122
|
+
Place a BTCUSD limit buy order 100 contracts @ 2500:
|
105
123
|
|
106
124
|
```ruby
|
107
|
-
|
108
|
-
puts
|
125
|
+
response = client.buy 'BTC-PERPETUAL', 100, price: 2500
|
126
|
+
puts response.order.state
|
109
127
|
```
|
110
128
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
Cancelheartbeat || N/A | [X] ||
|
120
|
-
Test || [X] | [X] ||
|
121
|
-
Ping || [X] | [X] ||
|
122
|
-
Instruments || [X] | [X] ||
|
123
|
-
Currencies || [X] | [X] ||
|
124
|
-
Index || [X] | [X] ||
|
125
|
-
Orderbook || [X] | [X] ||
|
126
|
-
Trades || [X] | [X] ||
|
127
|
-
Summary || [X] | [X] ||
|
128
|
-
Announcements || [X] | [X] ||
|
129
|
-
Settlements || [X] | [X] ||
|
130
|
-
Account | YES | [X] | [X] ||
|
131
|
-
Buy | YES | [X] | [X] ||
|
132
|
-
Sell | YES | [X] | [X] ||
|
133
|
-
Edit | YES | [X] | [X] ||
|
134
|
-
Cancel | YES | [X] | [X] ||
|
135
|
-
Cancel all | YES | [X] | [X] ||
|
136
|
-
Orders | YES | [X] | [X] ||
|
137
|
-
Positions | YES | [X] | [X]||
|
138
|
-
Orders history | YES | [X] | [X] ||
|
139
|
-
Order | YES | [X] |[X]||
|
140
|
-
Trades history | YES | [X] | [X] ||
|
141
|
-
New announcements | YES | [X] | [X] ||
|
142
|
-
Logout | YES | N/A | [X] ||
|
143
|
-
Cancel on disconnect | YES | N/A | [X] ||
|
144
|
-
Get email lang | YES | [X] | [X] ||
|
145
|
-
Set email lang | YES | [X] | [X] ||
|
146
|
-
Set announcements read | YES | [X] | [X] ||
|
147
|
-
Settlements history | YES | [X] | [X] ||
|
148
|
-
Subscribe | | N/A | ||
|
149
|
-
Unsubscribe | | N/A | ||
|
129
|
+
Account info:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
account = client.account
|
133
|
+
=> #<Hashie::Mash available_funds=9.99958335 available_withdrawal_funds=9.99958335 balance=9.99958335 currency="BTC" delta_total=0.0 deposit_address="2N9KizxwYNrKgd22QfSz9zxT4EPR4uAsWYr" equity=9.99958335 futures_pl=0.0 futures_session_rpl=0.0 futures_session_upl=0.0 initial_margin=0.0 limits=#<Hashie::Mash matching_engine=2 matching_engine_burst=20 non_matching_engine=200 non_matching_engine_burst=300> maintenance_margin=0.0 margin_balance=9.99958335 options_delta=0.0 options_gamma=0.0 options_pl=0.0 options_session_rpl=0.0 options_session_upl=0.0 options_theta=0.0 options_value=0.0 options_vega=0.0 portfolio_margining_enabled=false session_funding=0.0 session_rpl=0.0 session_upl=0.0 total_pl=0.0>
|
134
|
+
account.equity
|
135
|
+
=> 9.99958335
|
136
|
+
```
|
150
137
|
|
151
138
|
## Development
|
152
139
|
|
153
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
140
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
154
141
|
|
155
142
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
156
143
|
|
data/TODOs.org
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
* Tasks :DERIBIT:
|
2
|
+
:PROPERTIES:
|
3
|
+
:CATEGORY: deribit
|
4
|
+
:CREATED: 20200309
|
5
|
+
:END:
|
2
6
|
** DONE Initial deribit gem release
|
3
7
|
CLOSED: [2019-01-04 Fri] SCHEDULED: <2019-01-04 Fri>
|
4
8
|
** DONE public HTTP API
|
@@ -31,11 +35,13 @@
|
|
31
35
|
** research async websocket implementation
|
32
36
|
** cleanup 'params' for both http and websocket
|
33
37
|
** update buy/sell endpoints with new params
|
38
|
+
** DONE initial 2.0 API implementaion
|
34
39
|
** TODO deribit-api-ruby maintenance
|
35
|
-
SCHEDULED: <2020-
|
40
|
+
SCHEDULED: <2020-05-09 Sat +1m>
|
36
41
|
:PROPERTIES:
|
37
|
-
:LAST_REPEAT: [2020-
|
42
|
+
:LAST_REPEAT: [2020-04-23 Thu 13:25]
|
38
43
|
:END:
|
44
|
+
- State "DONE" from "TODO" [2020-04-23 Thu 13:25]
|
39
45
|
- State "DONE" from "TODO" [2020-01-09 Thu 18:00]
|
40
46
|
- State "DONE" from "TODO" [2019-10-21 Mon 14:43]
|
41
47
|
- State "DONE" from "TODO" [2019-07-02 Tue 13:01]
|
data/bin/auth.sh
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
source .env
|
4
|
+
|
5
|
+
ClientId=$API_KEY
|
6
|
+
ClientSecret=$API_SECRET
|
7
|
+
Timestamp=$( date +%s000 )
|
8
|
+
Nonce=$( cat /dev/urandom | tr -dc 'a-z0-9' | head -c8 )
|
9
|
+
URI="/api/v2/private/get_account_summary?currency=BTC"
|
10
|
+
HttpMethod=GET
|
11
|
+
Body=""
|
12
|
+
|
13
|
+
Data="${Timestamp}\n${Nonce}\n${HttpMethod}\n${URI}\n${Body}\n"
|
14
|
+
echo $Data
|
15
|
+
Signature=$( echo -ne $Data | openssl sha256 -r -hmac "$ClientSecret" | cut -f1 -d' ' )
|
16
|
+
echo $Signature
|
17
|
+
|
18
|
+
curl -s -X ${HttpMethod} -H "Authorization: deri-hmac-sha256 id=${ClientId},ts=${Timestamp},nonce=${Nonce},sig=${Signature}" "https://test.deribit.com${URI}"
|