deribit-api 0.1.3 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a62314b7e75414635ba071509257b3351fc60ad480be229c244cc35dd546887e
4
- data.tar.gz: f40fa635d14dbe3547f37cca66fcc8f5752ae73f4e1f0a4eb061c85e4e2a7f3c
3
+ metadata.gz: 9190274b8e9a8685d94a7795e36e5d02824acdfe97417923dcf12e0c2685caf2
4
+ data.tar.gz: a7dcd9a94ce0f80627f100b27f79e6f03cd0e4d07655c16837f3c444c6d516dc
5
5
  SHA512:
6
- metadata.gz: 41939581f1de76212b2a7b621fc004078edfada5cd732ff660e2d292ed915f9c376ce7a3eff9510a2daa30e9e1a8821a03cd02e7ece147635334b9867ef5a6f5
7
- data.tar.gz: 3e3e2a78c651293ec0a0e6cddf8caefc68890cf37599242ac917708687a6cca2bf7d513616c3e2a70875c5f8982c3bab22f08a575c29a99f8bdd9512099cfd1f
6
+ metadata.gz: cbb94007ede87a6c332ff98e0628084598a0c9ae06aa23482ab8a49ac309e2c87fce4f82b664bf390765d6bb0fc62be90f1fec0ae51ff59111be3674c6dcb089
7
+ data.tar.gz: 375beeb4e635832e442074b6f97a79d1abb7af72cfb81be16b5fb699039ae9df5c2d0a4768772f3975bbb298d7de7bf042772428949899daa127930116e56502
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.7.1
@@ -3,7 +3,7 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.3
6
+ - 2.7
7
7
 
8
8
  env:
9
9
  global:
@@ -11,11 +11,14 @@ env:
11
11
 
12
12
  before_install:
13
13
  - gem install bundler
14
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
- - chmod +x ./cc-test-reporter
16
14
 
17
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
18
18
  - ./cc-test-reporter before-build
19
19
 
20
+ script:
21
+ - bundle exec rake test
22
+
20
23
  after_script:
21
24
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -5,6 +5,43 @@
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.2] - 2020-06-10
9
+ ### Changed
10
+ - update all gems
11
+ - update Ruby to 2.7.1
12
+ - refactor Naming module
13
+
14
+ ## [2.0.1] - 2020-05-13
15
+ ### Added
16
+ - client#orders supports filtering by both currency and instrument name
17
+ - customisable *raise_error* param
18
+ ### Changed
19
+ - update all gems
20
+ - rdocs for all client#* methods
21
+ - fix namespace for Naming module
22
+
23
+ ## [2.0.0] - 2020-04-23
24
+ ### Added
25
+ - implementation for API 2.0
26
+ ### Changed
27
+ - all tests
28
+ ### Removed
29
+ - old 1.0 related code
30
+
31
+ ## [0.1.5] - 2020-01-09
32
+ ### Added
33
+ - latest Ruby 2.7 in Travis
34
+ ### Changed
35
+ - update all gems
36
+
37
+ ## [0.1.4] - 2019-10-21
38
+ ### Added
39
+ - detailed logger
40
+ ### Changed
41
+ - update gems
42
+ - disable history tests
43
+ - enable announcements tests
44
+
8
45
  ## [0.1.3] - 2019-07-02
9
46
  ### Changed
10
47
  - extract HTTP class
data/Gemfile CHANGED
@@ -4,3 +4,6 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in deribit.gemspec
6
6
  gemspec
7
+
8
+ # workaround to remove tons of warnings since RUBYOPT=-W0 env var seems to be ignored
9
+ $VERBOSE=nil
@@ -1,78 +1,105 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deribit-api (0.1.3)
4
+ deribit-api (2.0.2)
5
5
  faraday
6
+ faraday-detailed_logger
6
7
  faraday_middleware
7
- faye-websocket
8
8
  hashie
9
+ websocket-client-simple
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
14
  ast (2.4.0)
14
- axiom-types (0.1.1)
15
- descendants_tracker (~> 0.0.4)
16
- ice_nine (~> 0.11.0)
17
- thread_safe (~> 0.3, >= 0.3.1)
18
- bump (0.8.0)
19
- codeclimate-engine-rb (0.4.1)
20
- virtus (~> 1.0)
21
- coderay (1.1.2)
22
- coercible (1.0.0)
23
- descendants_tracker (~> 0.0.1)
24
- descendants_tracker (0.0.4)
25
- thread_safe (~> 0.3, >= 0.3.1)
15
+ backport (1.1.2)
16
+ benchmark (0.1.0)
17
+ bump (0.9.0)
18
+ coderay (1.1.3)
26
19
  docile (1.3.2)
27
- dotenv (2.7.4)
28
- equalizer (0.0.11)
29
- eventmachine (1.2.7)
30
- faraday (0.15.4)
20
+ dotenv (2.7.5)
21
+ e2mmap (0.1.0)
22
+ event_emitter (0.2.6)
23
+ faraday (1.0.1)
31
24
  multipart-post (>= 1.2, < 3)
32
- faraday_middleware (0.13.1)
33
- faraday (>= 0.7.4, < 1.0)
34
- faye-websocket (0.10.9)
35
- eventmachine (>= 0.12.0)
36
- websocket-driver (>= 0.5.1)
37
- hashie (3.6.0)
38
- ice_nine (0.11.2)
39
- json (2.2.0)
25
+ faraday-detailed_logger (2.3.0)
26
+ faraday (>= 0.8, < 2)
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.4)
32
+ reline (>= 0.0.1)
33
+ jaro_winkler (1.5.4)
40
34
  kwalify (0.7.2)
41
- method_source (0.9.2)
42
- minitest (5.11.3)
35
+ maruku (0.7.3)
36
+ method_source (1.0.0)
37
+ mini_portile2 (2.4.0)
38
+ minitest (5.14.1)
43
39
  multipart-post (2.1.1)
44
- parser (2.6.3.0)
40
+ nokogiri (1.10.9)
41
+ mini_portile2 (~> 2.4.0)
42
+ parallel (1.19.1)
43
+ parser (2.7.1.3)
45
44
  ast (~> 2.4.0)
46
- pry (0.12.2)
47
- coderay (~> 1.1.0)
48
- method_source (~> 0.9.0)
49
- pry-doc (1.0.0)
45
+ pry (0.13.1)
46
+ coderay (~> 1.1)
47
+ method_source (~> 1.0)
48
+ pry-doc (1.1.0)
50
49
  pry (~> 0.11)
51
50
  yard (~> 0.9.11)
52
51
  psych (3.1.0)
53
52
  rainbow (3.0.0)
54
- rake (12.3.2)
55
- reek (5.4.0)
56
- codeclimate-engine-rb (~> 0.4.0)
53
+ rake (13.0.1)
54
+ reek (6.0.1)
57
55
  kwalify (~> 0.7.0)
58
- parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
56
+ parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
59
57
  psych (~> 3.1.0)
60
58
  rainbow (>= 2.0, < 4.0)
61
- simplecov (0.17.0)
59
+ regexp_parser (1.7.1)
60
+ reline (0.1.4)
61
+ io-console (~> 0.5)
62
+ reverse_markdown (2.0.0)
63
+ nokogiri
64
+ rexml (3.2.4)
65
+ rubocop (0.85.1)
66
+ parallel (~> 1.10)
67
+ parser (>= 2.7.0.1)
68
+ rainbow (>= 2.2.2, < 4.0)
69
+ regexp_parser (>= 1.7)
70
+ rexml
71
+ rubocop-ast (>= 0.0.3)
72
+ ruby-progressbar (~> 1.7)
73
+ unicode-display_width (>= 1.4.0, < 2.0)
74
+ rubocop-ast (0.0.3)
75
+ parser (>= 2.7.0.1)
76
+ ruby-progressbar (1.10.1)
77
+ simplecov (0.18.5)
62
78
  docile (~> 1.1)
63
- json (>= 1.8, < 3)
64
- simplecov-html (~> 0.10.0)
65
- simplecov-html (0.10.2)
66
- thread_safe (0.3.6)
67
- virtus (1.0.5)
68
- axiom-types (~> 0.1)
69
- coercible (~> 1.0)
70
- descendants_tracker (~> 0.0, >= 0.0.3)
71
- equalizer (~> 0.0, >= 0.0.9)
72
- websocket-driver (0.7.1)
73
- websocket-extensions (>= 0.1.0)
74
- websocket-extensions (0.1.4)
75
- yard (0.9.20)
79
+ simplecov-html (~> 0.11)
80
+ simplecov-html (0.12.2)
81
+ solargraph (0.39.8)
82
+ backport (~> 1.1)
83
+ benchmark
84
+ bundler (>= 1.17.2)
85
+ e2mmap
86
+ jaro_winkler (~> 1.5)
87
+ maruku (~> 0.7, >= 0.7.3)
88
+ nokogiri (~> 1.9, >= 1.9.1)
89
+ parser (~> 2.3)
90
+ reverse_markdown (>= 1.0.5, < 3)
91
+ rubocop (~> 0.52)
92
+ thor (~> 1.0)
93
+ tilt (~> 2.0)
94
+ yard (~> 0.9, >= 0.9.24)
95
+ thor (1.0.1)
96
+ tilt (2.0.10)
97
+ unicode-display_width (1.7.0)
98
+ websocket (1.2.8)
99
+ websocket-client-simple (0.3.0)
100
+ event_emitter
101
+ websocket
102
+ yard (0.9.25)
76
103
 
77
104
  PLATFORMS
78
105
  ruby
@@ -82,12 +109,15 @@ DEPENDENCIES
82
109
  bundler
83
110
  deribit-api!
84
111
  dotenv
112
+ irb
85
113
  minitest
86
114
  pry
87
115
  pry-doc
88
116
  rake
89
117
  reek
118
+ rubocop
90
119
  simplecov
120
+ solargraph
91
121
 
92
122
  BUNDLED WITH
93
- 2.0.2
123
+ 2.1.4
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/deribit-api)
9
9
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](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, raise_error: 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
- Create a simple client to access public APIs
43
+ Get trades via HTTP APIs:
38
44
 
39
45
  ```ruby
40
- client = Deribit::Client.new
41
- trades = client.trades 'options', count: 3
46
+ trades = client.trades instrument_name: 'BTC-PERPETUAL', count: 3
42
47
  trades.first
43
- => #<Hashie::Mash amount=3.0 direction="buy" indexPrice=3817.31 instrument="BTC-29MAR19-4500-C" iv=60.33 price=0.016 quantity=3.0 tickDirection=0 timeStamp=1551274556589 tradeId=16055937 tradeSeq=712>
44
- trades.first.instrument
45
- => "BTC-29MAR19-4500-C"
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
- Pass key and secret to access private APIs
53
+ Streaming trades via Websocket APIs:
49
54
 
50
55
  ```ruby
51
- client = Deribit::Client.new key: 'KEY', secret: 'SECRET'
52
- account = client.account
53
- => #<Hashie::Mash PNL=0.0 SRPL=0.0 SUPL=0.0 availableFunds=9.99995789 balance=9.99995789 currency="BTC" deltaTotal=0.0 depositAddress="2N6SU5Yjn7AfYcT89QyeeHvHyZoqTt2GLyi" equity=9.999957896 futuresPNL=0.0 futuresSRPL=0.0 futuresSUPL=0.0 initialMargin=0.0 maintenanceMargin=0.0 marginBalance=9.99995789 optionsD=0.0 optionsG=0.0 optionsPNL=0.0 optionsSRPL=0.0 optionsSUPL=0.0 optionsTh=0.0 optionsV=0.0 sessionFunding=0.0>
54
- account.equity
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
- ### Examples
59
-
60
- Fetch all tradable instruments:
62
+ Place a buy limit order:
61
63
 
62
64
  ```ruby
63
- instruments = client.instruments
64
- puts instruments.first
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
- Orderbook for BTCUSD perpetual instrument:
69
+ Direct access to any HTTP API endpoints: <https://docs.deribit.com/#market-data>
68
70
 
69
71
  ```ruby
70
- orderbook = client.orderbook 'BTC-PERPETUAL', depth: 3
71
- puts orderbook.asks.first
72
+ result = client.http.get '/public/ping'
73
+ => "pong"
72
74
  ```
73
75
 
74
- Orderbook streaming via websocket:
76
+ Direct access to any Websocket API channels: <https://docs.deribit.com/#subscriptions>
75
77
 
76
78
  ```ruby
77
- @client.orderbook 'ETH-PERPETUAL' do |orderbook|
78
- puts orderbook
79
+ client.websocket.subscribe 'user.portofolio.BTC' do |data|
80
+ puts data
79
81
  end
80
82
  ```
81
83
 
82
- Place a BTCUSD limit buy order 100 contracts @ 2500:
84
+ ### Examples
85
+
86
+ Fetch all tradable instruments:
83
87
 
84
88
  ```ruby
85
- response = client.buy 'BTC-PERPETUAL', 100, price: 2500
86
- puts response.order.state
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
- Get last 10 option trades via HTTP:
94
+ Place a buy market order:
90
95
 
91
96
  ```ruby
92
- trades = client.trades 'options', count: 10
93
- puts trades.first
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
- Stream ongoing trades via websocket:
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
- @client.trades do |trade|
100
- puts trade
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
- Options trading summary:
122
+ Place a BTCUSD limit buy order 100 contracts @ 2500:
105
123
 
106
124
  ```ruby
107
- summaries = client.summary :options
108
- puts summaries.first
125
+ response = client.buy 'BTC-PERPETUAL', 100, price: 2500
126
+ puts response.order.state
109
127
  ```
110
128
 
111
- ## API Endpoints
112
-
113
- All endpoints marked with [X] are fully implemented and ready to use, see the features table below:
114
-
115
- API endpoints | Private? | HTTP API | Websocket API | FIX API |
116
- --------------|----------|----------|---------------|---------|
117
- Time || [X] | [X] ||
118
- Setheartbeat || N/A | [X] ||
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 spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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