Class: RTCBX::Candles

Inherits:
RTCBX
  • Object
show all
Defined in:
lib/rtcbx/candles.rb,
lib/rtcbx/candles/candle.rb

Defined Under Namespace

Classes: Candle

Constant Summary

Constants inherited from RTCBX

PING_INTERVAL, VERSION

Instance Attribute Summary collapse

Attributes inherited from RTCBX

#api_key, #api_passphrase, #api_secret, #client, #last_pong, #message_callbacks, #product_id, #queue, #start, #websocket, #websocket_thread

Instance Method Summary collapse

Methods inherited from RTCBX

#reset!, #stop!

Constructor Details

#initialize(options = {}, &block) ⇒ Candles



20
21
22
23
# File 'lib/rtcbx/candles.rb', line 20

def initialize(options = {}, &block)
  super(options, &block)
  @buckets_lock = Mutex.new
end

Instance Attribute Details

#bucket_lockObject (readonly)

Returns the value of attribute bucket_lock.



17
18
19
# File 'lib/rtcbx/candles.rb', line 17

def bucket_lock
  @bucket_lock
end

#bucket_threadObject (readonly)

Returns the value of attribute bucket_thread.



9
10
11
# File 'lib/rtcbx/candles.rb', line 9

def bucket_thread
  @bucket_thread
end

#bucketsObject (readonly)

Returns the value of attribute buckets.



6
7
8
# File 'lib/rtcbx/candles.rb', line 6

def buckets
  @buckets
end

#candle_threadObject (readonly)

Returns the value of attribute candle_thread.



10
11
12
# File 'lib/rtcbx/candles.rb', line 10

def candle_thread
  @candle_thread
end

#candlesObject (readonly)

Returns the value of attribute candles.



13
14
15
# File 'lib/rtcbx/candles.rb', line 13

def candles
  @candles
end

#current_bucketObject (readonly)

Returns the value of attribute current_bucket.



11
12
13
# File 'lib/rtcbx/candles.rb', line 11

def current_bucket
  @current_bucket
end

#first_bucketObject (readonly)

Returns the value of attribute first_bucket.



16
17
18
# File 'lib/rtcbx/candles.rb', line 16

def first_bucket
  @first_bucket
end

#history_queueObject (readonly)

Returns the value of attribute history_queue.



7
8
9
# File 'lib/rtcbx/candles.rb', line 7

def history_queue
  @history_queue
end

#initial_timeObject (readonly)

Returns the value of attribute initial_time.



15
16
17
# File 'lib/rtcbx/candles.rb', line 15

def initial_time
  @initial_time
end

#start_minuteObject (readonly)

Returns the value of attribute start_minute.



12
13
14
# File 'lib/rtcbx/candles.rb', line 12

def start_minute
  @start_minute
end

#update_threadObject (readonly)

Returns the value of attribute update_thread.



8
9
10
# File 'lib/rtcbx/candles.rb', line 8

def update_thread
  @update_thread
end

Instance Method Details

#start!Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rtcbx/candles.rb', line 25

def start!
  super
  #
  # Calculate the first minute to start relying on just the websocket for
  # data.
  #
  @initial_time = Time.now
  @first_bucket = initial_time.to_i + (60 - initial_time.sec)
  @history_queue = Queue.new

  start_bucket_thread
  start_candle_thread
end