Module: Cryptum::UI::OrderPlanDetails
- Defined in:
- lib/cryptum/ui/order_plan_details.rb
Overview
This plugin is used to Display Order Plan Details selected from the Order Plan Window Pane.
Class Method Summary collapse
-
.help ⇒ Object
Display Usage for this Module.
-
.refresh(opts = {}) ⇒ Object
- Supported Method Parameters
-
Cryptum::UI::OrderPlanDetails.refresh( ).
Class Method Details
.help ⇒ Object
Display Usage for this Module
232 233 234 235 236 237 |
# File 'lib/cryptum/ui/order_plan_details.rb', line 232 public_class_method def self.help puts "USAGE: #{self}.refresh( ) " end |
.refresh(opts = {}) ⇒ Object
- Supported Method Parameters
-
Cryptum::UI::OrderPlanDetails.refresh( )
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/cryptum/ui/order_plan_details.rb', line 14 public_class_method def self.refresh(opts = {}) event_history = opts[:event_history] order_plan_details_win = opts[:order_plan_details_win] order = event_history.order_plan_selected_data tpm = order[:tpm] autotrade_percent = order[:autotrade_percent] order_color = order[:color] fiat_avail_out = Cryptum.beautify_large_number( value: order[:fiat_available] ) risk_alloc_out = Cryptum.beautify_large_number( value: order[:risk_alloc] ) slice_alloc_out = Cryptum.beautify_large_number( value: order[:slice_alloc] ) previous_slice_invest_out = Cryptum.beautify_large_number( value: order[:previous_slice_invest] ) invest_out = Cryptum.beautify_large_number( value: order[:invest] ) profit_out = Cryptum.beautify_large_number( value: order[:profit] ) tpm_out = format('%0.2f', tpm) return_out = Cryptum.beautify_large_number( value: order[:return] ) autotrade_ln1_details = "1. Autotrade is set to #{autotrade_percent}% of $#{fiat_avail_out}, making $#{risk_alloc_out} available for this slice in" autotrade_ln2_details = ' the order plan.' if order[:last_slice] slice_alloc_ln1_details = "2. Since $#{risk_alloc_out} is the remaining amount within the criteria defined in the Autotrade % above," slice_alloc_ln2_details = " $#{invest_out} will be allocated for this slice." else slice_alloc_ln1_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} plus the previous" slice_alloc_ln2_details = " slice of $#{previous_slice_invest_out} results in $#{invest_out} being allocated for this slice." end profit_ln1_details = "3. With a slice allocation of $#{invest_out}, plus a TPM equal to #{tpm_out}%, $#{return_out} will be returned" profit_ln2_details = " once sold. With $#{invest_out} invested, the gross profit equals $#{profit_out}, minus any Maker &" profit_ln3_details = ' Taker (transaction) fees.' # UI col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1 # ROW 1 out_line_no = 0 line_color = order_color header_color = order_color header_style = :bold style = :bold header_style = :reverse if event_history.order_plan_details_win_active Cryptum::UI.line( ui_win: order_plan_details_win, out_line_no: out_line_no, color: line_color ) # ROW 2 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: header_color, style: header_style, string: ''.ljust(col_just1, ' ') ) header_str = "- ORDER SLICE ##{order[:plan_no]} DETAILS -" order_plan_details_win.setpos( out_line_no, Cryptum::UI.col_center(str: header_str) ) Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: header_style, string: header_str ) # ROW 3 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: autotrade_ln1_details.ljust(col_just1, ' ') ) # ROW 4 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: autotrade_ln2_details.ljust(col_just1, ' ') ) # ROW 5 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: slice_alloc_ln1_details.ljust(col_just1, ' ') ) # ROW 6 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: slice_alloc_ln2_details.ljust(col_just1, ' ') ) # ROW 7 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: profit_ln1_details.ljust(col_just1, ' ') ) # ROW 8 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: profit_ln2_details.ljust(col_just1, ' ') ) # ROW 9 out_line_no += 1 order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: style, string: profit_ln3_details.ljust(col_just1, ' ') ) # Clear to OK ROW ok_row = 9 out_line_no += 1 to_ok_row = ok_row - 1 (out_line_no..to_ok_row).each do |clr_line| order_plan_details_win.setpos(clr_line, Cryptum::UI.col_first) Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: :normal, string: ''.ljust(col_just1, ' ') ) end # OK ROW out_line_no = ok_row order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first) order_plan_details_win.clrtoeol Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, string: ''.ljust(col_just1, ' ') ) header_str = '- OK -' order_plan_details_win.setpos( out_line_no, Cryptum::UI.col_center(str: header_str) ) Cryptum::UI.colorize( ui_win: order_plan_details_win, color: order_color, style: :reverse, string: header_str ) order_plan_details_win.refresh event_history rescue Interrupt # Exit Gracefully if CTRL+C is Pressed During Session Cryptum.exit_gracefully(which_self: self) rescue StandardError => e raise e end |