Module: Cryptum::UI::SignalEngine

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

Overview

Update the SignalEngine Section of the UI

Class Method Summary collapse

Class Method Details

.helpObject

Display Usage for this Module



87
88
89
90
91
92
93
94
# File 'lib/cryptum/ui/signal_engine.rb', line 87

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'

)



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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cryptum/ui/signal_engine.rb', line 15

public_class_method def self.refresh(opts = {})
  signal_engine_win = opts[:signal_engine_win]
  indicator_status = opts[:indicator_status]

  color = :white
  color = indicator_status.market_trend[:color] if indicator_status.market_trend

  indicator_status.last_action_signal = indicator_status.action_signal

  case color
  when :green
    signal_color = :green
    action_signal = :sell
  when :yellow
    signal_color = :yellow
    action_signal = :hold
  when :red
    signal_color = :cyan
    action_signal = :buy
  else
    signal_color = :white
    action_signal = :skip
  end

  action_signal_out = "SIGNAL >>> #{action_signal.to_s.upcase} <<< ENGINE"
  # TODO: Everything Above this Line Needs to be Indicators ^

  # UI
  col_just1 = Curses.cols - Cryptum::UI.col_first

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

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

  Cryptum::UI.colorize(
    ui_win: signal_engine_win,
    color: signal_color,
    style: :reverse,
    string: ''.ljust(col_just1, ' ')
  )

  signal_engine_win.setpos(
    out_line_no,
    Cryptum::UI.col_center(str: action_signal_out)
  )

  Cryptum::UI.colorize(
    ui_win: signal_engine_win,
    color: signal_color,
    style: :reverse,
    string: action_signal_out
  )

  signal_engine_win.refresh

  indicator_status.action_signal = action_signal

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