Module: Cryptum::Event::Parse

Defined in:
lib/cryptum/event/parse.rb

Class Method Summary collapse

Class Method Details

.helpObject

Display Usage for this Module



166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/cryptum/event/parse.rb', line 166

public_class_method def self.help
  puts "USAGE:
    #{self}.websocket_msg(
      env: env,
      terminal_win: terminal_win,
      option_choice: option_choice,
      event_history: event_history,
      indicator_status: indicator_status,
      bot_conf: bot_conf,
      ai_enabled: ai_enabled
    )
  "
end

.websocket_msg(opts = {}) ⇒ Object

Supported Method Parameters

Cryptum::Event::Pane.websocket_msg( )



10
11
12
13
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
# File 'lib/cryptum/event/parse.rb', line 10

public_class_method def self.websocket_msg(opts = {})
  env = opts[:env]
  terminal_win = opts[:terminal_win]
  option_choice = opts[:option_choice]
  event_history = opts[:event_history]
  indicator_status = opts[:indicator_status]
  bot_conf = opts[:bot_conf]

  this_product = event_history.order_book[:this_product]
  fiat = this_product[:quote_currency]
  fiat_portfolio_file = "#{option_choice.session_root}/order_books/#{fiat}_PORTFOLIO.json"

  # Determine if Summary UI needs updated data
  event_history = Cryptum::Portfolio::Balance.refresh(
    env: env,
    option_choice: option_choice,
    terminal_win: terminal_win,
    event_history: event_history,
    fiat_portfolio_file: fiat_portfolio_file
  )

  # If the Terminal Window has been Resized, Resize the UI
  if Curses.cols != terminal_win.cols
    terminal_win.cols = Curses.cols
    terminal_win.ticker_ui_resize = true
    terminal_win.market_trend_ui_resize = true
  end

  event_history = Cryptum::UI::Portfolio.refresh(
    option_choice: option_choice,
    portfolio_win: terminal_win.portfolio_section,
    event_history: event_history,
    key_press_event: terminal_win.key_press_event,
    indicator_status: indicator_status,
    bot_conf: bot_conf,
    fiat_portfolio_file: fiat_portfolio_file
  )

  if event_history.event_type == :ticker ||
     terminal_win.ticker_ui_resize

    ticker_event = event_history.ticker_event = event_history.event if event_history.event_type == :ticker
    ticker_event = event_history.ticker_event if terminal_win.ticker_ui_resize
    event_history = Cryptum::UI::Ticker.refresh(
      option_choice: option_choice,
      start_time: event_history.start_time,
      ticker_win: terminal_win.ticker_section,
      key_press_event: terminal_win.key_press_event,
      event_history: event_history,
      event: ticker_event
    )
  end

  Cryptum::UI::OrderTimer.refresh(
    option_choice: option_choice,
    event_history: event_history,
    order_timer_win: terminal_win.order_timer_section,
    indicator_status: indicator_status,
    key_press_event: terminal_win.key_press_event
  )

  if event_history.event_type == :l2update ||
     terminal_win.market_trend_ui_resize

    market_trend_event = event_history.market_trend_event = event_history.event if event_history.event_type == :l2update
    market_trend_event = event_history.market_trend_event if terminal_win.market_trend_ui_resize
    event_history = Cryptum::UI::MarketTrend.refresh(
      option_choice: option_choice,
      market_trend_win: terminal_win.market_trend_section,
      event_history: event_history,
      key_press_event: terminal_win.key_press_event,
      event: market_trend_event,
      indicator_status: indicator_status,
      bot_conf: bot_conf
    )
  end

  indicator_status = Cryptum::UI::SignalEngine.refresh(
    option_choice: option_choice,
    signal_engine_win: terminal_win.signal_engine_section,
    event_history: event_history,
    key_press_event: terminal_win.key_press_event,
    indicator_status: indicator_status,
    bot_conf: bot_conf,
    fiat_portfolio_file: fiat_portfolio_file
  )

  unless event_history.order_plan_details_win_active
    event_history = Cryptum::UI::OrderPlan.refresh(
      option_choice: option_choice,
      order_plan_win: terminal_win.order_plan_section,
      env: env,
      event_history: event_history,
      key_press_event: terminal_win.key_press_event,
      indicator_status: indicator_status,
      bot_conf: bot_conf,
      fiat_portfolio_file: fiat_portfolio_file
    )
    recalc_op = event_history.recalculate_order_plan
    order_plan = event_history.order_book[:order_plan]
    terminal_win.key_press_event.key_w = true if (recalc_op || order_plan.empty?) &&
                                                 !event_history.red_pill
    event_history.recalculate_order_plan = false
  end

  if event_history.order_plan_details_win_active
    event_history = Cryptum::UI::OrderPlanDetails.refresh(
      option_choice: option_choice,
      order_plan_details_win: terminal_win.order_plan_details_section,
      event_history: event_history,
      key_press_event: terminal_win.key_press_event
    )
  end

  unless event_history.order_execute_details_win_active
    event_history = Cryptum::UI::OrderExecution.refresh(
      option_choice: option_choice,
      order_execute_win: terminal_win.order_execute_section,
      env: env,
      event_history: event_history,
      key_press_event: terminal_win.key_press_event,
      indicator_status: indicator_status,
      bot_conf: bot_conf,
      fiat_portfolio_file: fiat_portfolio_file
    )
  end

  if event_history.order_execute_details_win_active
    event_history = Cryptum::UI::OrderExecuteDetails.refresh(
      option_choice: option_choice,
      order_execute_details_win: terminal_win.order_execute_details_section,
      event_history: event_history,
      key_press_event: terminal_win.key_press_event
    )
  end

  # Refresh Command Section for Cryptum Session Usage
  Cryptum::UI::Command.refresh(
    command_win: terminal_win.command_section,
    key_press_event: terminal_win.key_press_event
  )

  event_history
rescue Interrupt
  # Exit Gracefully if CTRL+C is Pressed During Session
  Cryptum.exit_gracefully(
    which_self: self,
    event_history: event_history,
    option_choice: option_choice,
    env: env
  )
rescue StandardError => e
  raise e
end