Module: Cryptum::UI::MarketTrend

Defined in:
lib/cryptum/ui/market_trend.rb

Overview

Update the Cryptum MarketTrend Section UI

Class Method Summary collapse

Class Method Details

.helpObject

Display Usage for this Module



63
64
65
66
67
68
69
70
# File 'lib/cryptum/ui/market_trend.rb', line 63

public_class_method def self.help
  puts "USAGE:
   #{self}.refresh(
     order_book: 'required - Order Book Data Structure',
     event: 'required - Event from Coinbase Web Socket'
   )
  "
end

.refresh(opts = {}) ⇒ Object

Supported Method Parameters

Cryptum::UI::Candle.refresh(

order_book: 'required - Order Book Data Structure',
event: 'required - Event from Coinbase Web Socket'

)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cryptum/ui/market_trend.rb', line 14

public_class_method def self.refresh(opts = {})
  market_trend_win = opts[:market_trend_win]
  event_history = opts[:event_history]
  event = opts[:event]
  indicator_status = opts[:indicator_status]

  indicator_hash = Cryptum::OrderBook::MarketTrend.status(
    event_history: event_history,
    event: event,
    indicator_status: indicator_status
  )

  market_trend_color = indicator_hash[:color]
  market_trend_out = indicator_hash[:ui]

  # UI
  # ROW 1
  out_line_no = 0
  Cryptum::UI.line(
    ui_win: market_trend_win,
    out_line_no: out_line_no
  )

  # ROW 2
  out_line_no += 1
  market_trend_win.setpos(out_line_no, Cryptum::UI.col_first)
  market_trend_win.clrtoeol

  market_trend_win.setpos(
    out_line_no,
    Cryptum::UI.col_center(str: market_trend_out)
  )

  Cryptum::UI.colorize(
    ui_win: market_trend_win,
    color: market_trend_color,
    style: :bold,
    string: market_trend_out
  )

  market_trend_win.refresh

  event_history
rescue Interrupt, StandardError => e
  Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
end