Module: Coinbot::UI::ActionProbability
- Defined in:
- lib/coinbot/ui/action_probability.rb
Overview
This plugin is used to Refresh the Coinbot Status Section UI
Class Method Summary collapse
-
.help ⇒ Object
Display Usage for this Module.
-
.refresh(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::UI::ActionProbability.refresh( action_probability_status: 'required - Instatiated Coinbot::OrderBook::Probabilities Object' ).
Class Method Details
.help ⇒ Object
Display Usage for this Module
166 167 168 169 170 171 172 |
# File 'lib/coinbot/ui/action_probability.rb', line 166 public_class_method def self.help puts "USAGE: #{self}.refresh( probability_status: 'required - Instatiated Coinbot::OrderBook::Probabilities Object' ) " end |
.refresh(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::UI::ActionProbability.refresh(
action_probability_status: 'required - Instatiated Coinbot::OrderBook::Probabilities Object'
)
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/coinbot/ui/action_probability.rb', line 14 public_class_method def self.refresh(opts = {}) option_choice = opts[:option_choice] probability_win = opts[:probability_win] candle_length = opts[:candle_length] ema_high = opts[:ema_high] key_press_event = opts[:key_press_event] action_probability_status = opts[:action_probability_status] ai_enabled = opts[:ai_enabled] recommendation_key = action_probability_status.sort_by { |_k, v| v[:weight] }.reverse.to_h.first.first action_probability_status[recommendation_key][:color] = :cyan buy = format('%1i', action_probability_status[:buy][:weight]) buy_color = action_probability_status[:buy][:color] cancel = format('%1i', action_probability_status[:cancel][:weight]) cancel_color = action_probability_status[:cancel][:color] sell = format('%1i', action_probability_status[:sell][:weight]) sell_color = action_probability_status[:sell][:color] hold = format('%1i', action_probability_status[:hold][:weight]) hold_color = action_probability_status[:hold][:color] skip = format('%1i', action_probability_status[:skip][:weight]) skip_color = action_probability_status[:skip][:color] gtfo = format('%1i', action_probability_status[:gtfo][:weight]) gtfo_color = action_probability_status[:gtfo][:color] Coinbot::UI.detect_key_press_in_ui( key_press_event: key_press_event, ui_win: probability_win ) out_line_no = 0 Coinbot::UI.line( ui_win: probability_win, out_line_no: out_line_no ) out_line_no += 1 probability_win.setpos(out_line_no, Coinbot::UI.col_first) probability_win.clrtoeol if option_choice.autotrade && ai_enabled if candle_length < ema_high Coinbot::UI.colorize( ui_win: probability_win, color: :yellow, style: :bold, string: "* AI LEARNING >>> " ) else Coinbot::UI.colorize( ui_win: probability_win, color: :red, style: :bold, string: "* AI AUTOTRADING >>> " ) end elsif option_choice.autotrade Coinbot::UI.colorize( ui_win: probability_win, color: :cyan, style: :bold, string: "* AUTOTRADING >>> " ) else Coinbot::UI.colorize( ui_win: probability_win, color: :green, string: "* PROBABILITY >>> " ) end Coinbot::UI.colorize( ui_win: probability_win, color: buy_color, string: "BUY:#{buy}" ) Coinbot::UI.colorize( ui_win: probability_win, color: :white, string: ' | ' ) Coinbot::UI.colorize( ui_win: probability_win, color: sell_color, string: "SELL:#{sell}" ) Coinbot::UI.colorize( ui_win: probability_win, color: :white, string: ' | ' ) Coinbot::UI.colorize( ui_win: probability_win, color: hold_color, string: "HOLD:#{hold}" ) Coinbot::UI.colorize( ui_win: probability_win, color: :white, string: ' | ' ) Coinbot::UI.colorize( ui_win: probability_win, color: cancel_color, string: "CANCEL:#{cancel}" ) Coinbot::UI.colorize( ui_win: probability_win, color: :white, string: ' | ' ) Coinbot::UI.colorize( ui_win: probability_win, color: skip_color, string: "SKIP:#{skip}" ) Coinbot::UI.colorize( ui_win: probability_win, color: :white, string: ' | ' ) Coinbot::UI.colorize( ui_win: probability_win, color: gtfo_color, string: "GTFO:#{gtfo}" ) probability_win.refresh rescue Interrupt # Exit Gracefully if CTRL+C is Pressed During Session Coinbot.exit_gracefully(which_self: self) rescue StandardError => e raise e end |