Module: Deribit::Naming
- Included in:
- Client
- Defined in:
- lib/deribit/naming.rb
Overview
Instance Method Summary collapse
- #book_channel(options) ⇒ Object
- #by_currency(options) ⇒ Object
- #by_instrument(options) ⇒ Object
- #cancel_uri(options) ⇒ Object
- #channel(prefix, options) ⇒ Object
- #channel_for_instrument(prefix, options) ⇒ Object
- #for_currency(options) ⇒ Object
- #for_instrument(options) ⇒ Object
- #instrument_with_interval(prefix, options) ⇒ Object
- #orders_uri(options) ⇒ Object
- #trades_channel(options) ⇒ Object
- #trades_uri(options) ⇒ Object
- #with_group_and_depth(options) ⇒ Object
- #with_interval(options) ⇒ Object
Instance Method Details
#book_channel(options) ⇒ Object
20 21 22 |
# File 'lib/deribit/naming.rb', line 20 def book_channel() 'book' + for_instrument() + with_group_and_depth() + with_interval() end |
#by_currency(options) ⇒ Object
52 53 54 |
# File 'lib/deribit/naming.rb', line 52 def by_currency() [:currency] ? '_by_currency' : '' end |
#by_instrument(options) ⇒ Object
48 49 50 |
# File 'lib/deribit/naming.rb', line 48 def by_instrument() [:instrument_name] ? '_by_instrument' : '' end |
#cancel_uri(options) ⇒ Object
40 41 42 |
# File 'lib/deribit/naming.rb', line 40 def cancel_uri() '/private/cancel_all' + by_instrument() + by_currency() end |
#channel(prefix, options) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/deribit/naming.rb', line 24 def channel(prefix, ) channel = prefix channel += for_instrument() if [:instrument_name] channel += for_currency() if [:currency] channel += with_interval() channel end |
#channel_for_instrument(prefix, options) ⇒ Object
32 33 34 |
# File 'lib/deribit/naming.rb', line 32 def channel_for_instrument(prefix, ) prefix + for_instrument() end |
#for_currency(options) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/deribit/naming.rb', line 62 def for_currency() raise 'currency param is required' unless [:currency] kind = [:kind] || 'any' ".#{kind}.#{[:currency]}" end |
#for_instrument(options) ⇒ Object
56 57 58 59 60 |
# File 'lib/deribit/naming.rb', line 56 def for_instrument() raise 'instrument_name param is required' unless [:instrument_name] ".#{[:instrument_name]}" end |
#instrument_with_interval(prefix, options) ⇒ Object
36 37 38 |
# File 'lib/deribit/naming.rb', line 36 def instrument_with_interval(prefix, ) prefix + for_instrument() + with_interval() end |
#orders_uri(options) ⇒ Object
44 45 46 |
# File 'lib/deribit/naming.rb', line 44 def orders_uri() '/private/get_open_orders' + by_instrument() + by_currency() end |
#trades_channel(options) ⇒ Object
6 7 8 9 10 |
# File 'lib/deribit/naming.rb', line 6 def trades_channel() private = .delete :private trades = private ? 'user.trades' : 'trades' channel trades, end |
#trades_uri(options) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/deribit/naming.rb', line 12 def trades_uri() private = .delete :private uri = private ? 'private/get_user_trades' : 'public/get_last_trades' uri += by_instrument() + by_currency() uri += [:end_timestamp] ? '_and_time' : '' uri end |
#with_group_and_depth(options) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/deribit/naming.rb', line 74 def with_group_and_depth() if [:group] || [:depth] group = [:group] || '5' depth = [:depth] || '10' ".#{group}.#{depth}" else '' end end |
#with_interval(options) ⇒ Object
69 70 71 72 |
# File 'lib/deribit/naming.rb', line 69 def with_interval() interval = [:interval] || '100ms' ".#{interval}" end |