Class: RTCBX
- Inherits:
-
Object
- Object
- RTCBX
- Defined in:
- lib/rtcbx/version.rb,
lib/rtcbx.rb,
lib/rtcbx/trader.rb,
lib/rtcbx/candles.rb,
lib/rtcbx/orderbook.rb,
lib/rtcbx/candles/candle.rb,
lib/rtcbx/orderbook/book_methods.rb,
lib/rtcbx/orderbook/book_analysis.rb
Overview
This class represents the current state of the CoinBase Exchange orderbook.
Defined Under Namespace
Classes: Candles, Orderbook, Trader
Constant Summary collapse
- PING_INTERVAL =
seconds in between pinging the connection.
15- VERSION =
'0.0.2'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_passphrase ⇒ Object
readonly
Returns the value of attribute api_passphrase.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#last_pong ⇒ Object
readonly
Returns the value of attribute last_pong.
-
#message_callbacks ⇒ Object
readonly
Returns the value of attribute message_callbacks.
-
#product_id ⇒ Object
readonly
Returns the value of attribute product_id.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#websocket ⇒ Object
readonly
Returns the value of attribute websocket.
-
#websocket_thread ⇒ Object
readonly
Returns the value of attribute websocket_thread.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ RTCBX
constructor
A new instance of RTCBX.
- #reset! ⇒ Object
- #start! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ RTCBX
Returns a new instance of RTCBX.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rtcbx.rb', line 26 def initialize( = {}, &block) @product_id = .fetch(:product_id, 'BTC-USD') @start = .fetch(:start, true) @api_key = .fetch(:api_key, '') @api_secret = .fetch(:api_secret, '') @api_passphrase = .fetch(:api_passphrase, '') @message_callbacks = [] @message_callbacks << block @client = Coinbase::Exchange::Client.new( api_key, api_secret, api_passphrase, product_id: product_id ) @websocket = Coinbase::Exchange::Websocket.new( keepalive: true, product_id: product_id ) @queue = Queue.new start! if start end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/rtcbx.rb', line 15 def api_key @api_key end |
#api_passphrase ⇒ Object (readonly)
Returns the value of attribute api_passphrase.
17 18 19 |
# File 'lib/rtcbx.rb', line 17 def api_passphrase @api_passphrase end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
16 17 18 |
# File 'lib/rtcbx.rb', line 16 def api_secret @api_secret end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
21 22 23 |
# File 'lib/rtcbx.rb', line 21 def client @client end |
#last_pong ⇒ Object (readonly)
Returns the value of attribute last_pong.
23 24 25 |
# File 'lib/rtcbx.rb', line 23 def last_pong @last_pong end |
#message_callbacks ⇒ Object (readonly)
Returns the value of attribute message_callbacks.
19 20 21 |
# File 'lib/rtcbx.rb', line 19 def @message_callbacks end |
#product_id ⇒ Object (readonly)
Returns the value of attribute product_id.
13 14 15 |
# File 'lib/rtcbx.rb', line 13 def product_id @product_id end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
22 23 24 |
# File 'lib/rtcbx.rb', line 22 def queue @queue end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
14 15 16 |
# File 'lib/rtcbx.rb', line 14 def start @start end |
#websocket ⇒ Object (readonly)
Returns the value of attribute websocket.
20 21 22 |
# File 'lib/rtcbx.rb', line 20 def websocket @websocket end |
#websocket_thread ⇒ Object (readonly)
Returns the value of attribute websocket_thread.
24 25 26 |
# File 'lib/rtcbx.rb', line 24 def websocket_thread @websocket_thread end |
Instance Method Details
#reset! ⇒ Object
57 58 59 60 |
# File 'lib/rtcbx.rb', line 57 def reset! stop! start! end |
#start! ⇒ Object
48 49 50 |
# File 'lib/rtcbx.rb', line 48 def start! start_websocket_thread end |
#stop! ⇒ Object
52 53 54 55 |
# File 'lib/rtcbx.rb', line 52 def stop! websocket_thread.kill websocket.stop! end |