cryptum 0.0.355 → 0.0.357

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. metadata +13 -116
  3. data/.github/workflows/main.yml +0 -16
  4. data/.gitignore +0 -30
  5. data/.rspec +0 -3
  6. data/.rspec_status +0 -0
  7. data/.rubocop.yml +0 -31
  8. data/.rubocop_todo.yml +0 -32
  9. data/.ruby-gemset +0 -1
  10. data/.ruby-version +0 -1
  11. data/CODE_OF_CONDUCT.md +0 -84
  12. data/Gemfile +0 -38
  13. data/LICENSE +0 -674
  14. data/README.md +0 -87
  15. data/Rakefile +0 -19
  16. data/bin/cryptum +0 -73
  17. data/bin/cryptum-forecast +0 -200
  18. data/bin/cryptum-repl +0 -73
  19. data/bin/cryptum_autoinc_version +0 -38
  20. data/build_cryptum_gem.sh +0 -58
  21. data/cryptum.gemspec +0 -52
  22. data/cryptum_container.sh +0 -1
  23. data/docker/cryptum.json +0 -60
  24. data/docker/cryptum_container.sh +0 -59
  25. data/docker/packer_secrets.json.EXAMPLE +0 -7
  26. data/docker/provisioners/cryptum.sh +0 -11
  27. data/docker/provisioners/docker_bashrc.sh +0 -2
  28. data/docker/provisioners/docker_rvm.sh +0 -22
  29. data/docker/provisioners/init_image.sh +0 -28
  30. data/docker/provisioners/post_install.sh +0 -6
  31. data/docker/provisioners/ruby.sh +0 -16
  32. data/docker/provisioners/upload_globals.sh +0 -49
  33. data/etc/bot_confs/.gitkeep +0 -0
  34. data/etc/bot_confs/BOT_CONF.TEMPLATE +0 -10
  35. data/etc/coinbase_pro.yaml.EXAMPLE +0 -8
  36. data/etc/open_ai.yaml.EXAMPLE +0 -1
  37. data/git_commit.sh +0 -22
  38. data/lib/cryptum/api.rb +0 -688
  39. data/lib/cryptum/bot_conf.rb +0 -197
  40. data/lib/cryptum/event/bot_conf.rb +0 -34
  41. data/lib/cryptum/event/buy.rb +0 -145
  42. data/lib/cryptum/event/cancel.rb +0 -35
  43. data/lib/cryptum/event/exit.rb +0 -35
  44. data/lib/cryptum/event/gtfo.rb +0 -36
  45. data/lib/cryptum/event/history.rb +0 -105
  46. data/lib/cryptum/event/key_press.rb +0 -64
  47. data/lib/cryptum/event/order_book.rb +0 -34
  48. data/lib/cryptum/event/pane.rb +0 -65
  49. data/lib/cryptum/event/parse.rb +0 -181
  50. data/lib/cryptum/event/scroll.rb +0 -200
  51. data/lib/cryptum/event/sell.rb +0 -124
  52. data/lib/cryptum/event.rb +0 -27
  53. data/lib/cryptum/log.rb +0 -34
  54. data/lib/cryptum/matrix.rb +0 -181
  55. data/lib/cryptum/open_ai.rb +0 -156
  56. data/lib/cryptum/option/choice.rb +0 -28
  57. data/lib/cryptum/option.rb +0 -206
  58. data/lib/cryptum/order_book/generate.rb +0 -114
  59. data/lib/cryptum/order_book/indicator.rb +0 -15
  60. data/lib/cryptum/order_book/market_trend.rb +0 -137
  61. data/lib/cryptum/order_book/profit_margin.rb +0 -55
  62. data/lib/cryptum/order_book.rb +0 -19
  63. data/lib/cryptum/portfolio/balance.rb +0 -123
  64. data/lib/cryptum/portfolio.rb +0 -15
  65. data/lib/cryptum/ui/command.rb +0 -314
  66. data/lib/cryptum/ui/key_press_event.rb +0 -33
  67. data/lib/cryptum/ui/market_trend.rb +0 -74
  68. data/lib/cryptum/ui/order_execute_details.rb +0 -297
  69. data/lib/cryptum/ui/order_execution.rb +0 -573
  70. data/lib/cryptum/ui/order_plan.rb +0 -503
  71. data/lib/cryptum/ui/order_plan_details.rb +0 -240
  72. data/lib/cryptum/ui/order_timer.rb +0 -121
  73. data/lib/cryptum/ui/portfolio.rb +0 -221
  74. data/lib/cryptum/ui/signal_engine.rb +0 -109
  75. data/lib/cryptum/ui/terminal_window.rb +0 -111
  76. data/lib/cryptum/ui/ticker.rb +0 -319
  77. data/lib/cryptum/ui.rb +0 -343
  78. data/lib/cryptum/version.rb +0 -5
  79. data/lib/cryptum/web_sock/coinbase.rb +0 -102
  80. data/lib/cryptum/web_sock/event_machine.rb +0 -274
  81. data/lib/cryptum/web_sock.rb +0 -16
  82. data/lib/cryptum.rb +0 -120
  83. data/order_books/.gitkeep +0 -0
  84. data/reinstall_cryptum_gemset.sh +0 -29
  85. data/spec/lib/cryptum/api_spec.rb +0 -10
  86. data/spec/lib/cryptum/event_spec.rb +0 -10
  87. data/spec/lib/cryptum/log_spec.rb +0 -10
  88. data/spec/lib/cryptum/option_spec.rb +0 -10
  89. data/spec/lib/cryptum/order_book/generate_spec.rb +0 -10
  90. data/spec/lib/cryptum/order_book/market_trend_spec.rb +0 -10
  91. data/spec/lib/cryptum/order_book_spec.rb +0 -10
  92. data/spec/lib/cryptum/ui/command_spec.rb +0 -10
  93. data/spec/lib/cryptum/ui/ticker_spec.rb +0 -10
  94. data/spec/lib/cryptum/ui_spec.rb +0 -10
  95. data/spec/lib/cryptum/web_sock_spec.rb +0 -10
  96. data/spec/lib/cryptum_spec.rb +0 -10
  97. data/spec/spec_helper.rb +0 -3
  98. data/upgrade_Gemfile_gems.sh +0 -20
  99. data/upgrade_cryptum.sh +0 -13
  100. data/upgrade_gem.sh +0 -4
  101. data/upgrade_ruby.sh +0 -45
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Switch through Order Plan / Order History
5
- # Window Panes when the TAB Key is Pressed.
6
- module Event
7
- module Pane
8
- # Supported Method Parameters::
9
- # Cryptum::Event::Pane.switch(
10
- # )
11
- public_class_method def self.switch(opts = {})
12
- terminal_win = opts[:terminal_win]
13
- event_history = opts[:event_history]
14
-
15
- terminal_win.key_press_event.key_tab = false
16
-
17
- if event_history.order_plan_win_active
18
- event_history.order_plan_win_active = false
19
- event_history.order_execute_win_active = true
20
- else
21
- event_history.order_plan_win_active = true
22
- event_history.order_execute_win_active = false
23
- end
24
- rescue StandardError => e
25
- raise e
26
- end
27
-
28
- # Supported Method Parameters::
29
- # Cryptum::Event::Pane.toggle_details(
30
- # )
31
- public_class_method def self.toggle_details(opts = {})
32
- terminal_win = opts[:terminal_win]
33
- event_history = opts[:event_history]
34
-
35
- terminal_win.key_press_event.key_enter = false
36
-
37
- if event_history.order_plan_win_active
38
- unless event_history.red_pill
39
- if event_history.order_plan_details_win_active
40
- event_history.order_plan_details_win_active = false
41
- else
42
- event_history.order_plan_details_win_active = true
43
- end
44
- end
45
- elsif event_history.order_execute_win_active
46
- if event_history.order_execute_details_win_active
47
- event_history.order_execute_details_win_active = false
48
- else
49
- event_history.order_execute_details_win_active = true
50
- end
51
- end
52
- rescue StandardError => e
53
- raise e
54
- end
55
-
56
- # Display Usage for this Module
57
- public_class_method def self.help
58
- puts "USAGE:
59
- #{self}.switch()
60
- #{self}.toggle_details()
61
- "
62
- end
63
- end
64
- end
65
- end
@@ -1,181 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to parse Coinbase Pro Web Socket Events in the HTTP Response
5
- module Event
6
- module Parse
7
- # Supported Method Parameters::
8
- # Cryptum::Event::Pane.websocket_msg(
9
- # )
10
- public_class_method def self.websocket_msg(opts = {})
11
- env = opts[:env]
12
- terminal_win = opts[:terminal_win]
13
- option_choice = opts[:option_choice]
14
- event_history = opts[:event_history]
15
- indicator_status = opts[:indicator_status]
16
- bot_conf = opts[:bot_conf]
17
-
18
- this_product = event_history.order_book[:this_product]
19
- fiat = this_product[:quote_currency]
20
- fiat_portfolio_file = "#{option_choice.session_root}/order_books/#{fiat}_PORTFOLIO.json"
21
-
22
- # Determine if Summary UI needs updated data
23
- event_history = Cryptum::Portfolio::Balance.refresh(
24
- env: env,
25
- option_choice: option_choice,
26
- terminal_win: terminal_win,
27
- event_history: event_history,
28
- fiat_portfolio_file: fiat_portfolio_file
29
- )
30
-
31
- # If the Terminal Window has been Resized, Resize the UI
32
- if Curses.cols != terminal_win.cols
33
- terminal_win.cols = Curses.cols
34
- terminal_win.ticker_ui_resize = true
35
- terminal_win.market_trend_ui_resize = true
36
- end
37
-
38
- event_history = Cryptum::UI::Portfolio.refresh(
39
- option_choice: option_choice,
40
- portfolio_win: terminal_win.portfolio_section,
41
- event_history: event_history,
42
- key_press_event: terminal_win.key_press_event,
43
- indicator_status: indicator_status,
44
- bot_conf: bot_conf,
45
- fiat_portfolio_file: fiat_portfolio_file
46
- )
47
-
48
- if event_history.event_type == :ticker ||
49
- terminal_win.ticker_ui_resize
50
-
51
- ticker_event = event_history.ticker_event = event_history.event if event_history.event_type == :ticker
52
- ticker_event = event_history.ticker_event if terminal_win.ticker_ui_resize
53
- event_history = Cryptum::UI::Ticker.refresh(
54
- option_choice: option_choice,
55
- start_time: event_history.start_time,
56
- ticker_win: terminal_win.ticker_section,
57
- key_press_event: terminal_win.key_press_event,
58
- event_history: event_history,
59
- event: ticker_event
60
- )
61
- end
62
-
63
- Cryptum::UI::OrderTimer.refresh(
64
- option_choice: option_choice,
65
- event_history: event_history,
66
- order_timer_win: terminal_win.order_timer_section,
67
- indicator_status: indicator_status,
68
- key_press_event: terminal_win.key_press_event
69
- )
70
-
71
- if event_history.event_type == :l2update ||
72
- terminal_win.market_trend_ui_resize
73
-
74
- market_trend_event = event_history.market_trend_event = event_history.event if event_history.event_type == :l2update
75
- market_trend_event = event_history.market_trend_event if terminal_win.market_trend_ui_resize
76
- event_history = Cryptum::UI::MarketTrend.refresh(
77
- option_choice: option_choice,
78
- market_trend_win: terminal_win.market_trend_section,
79
- event_history: event_history,
80
- key_press_event: terminal_win.key_press_event,
81
- event: market_trend_event,
82
- indicator_status: indicator_status,
83
- bot_conf: bot_conf
84
- )
85
- end
86
-
87
- indicator_status = Cryptum::UI::SignalEngine.refresh(
88
- option_choice: option_choice,
89
- signal_engine_win: terminal_win.signal_engine_section,
90
- event_history: event_history,
91
- key_press_event: terminal_win.key_press_event,
92
- indicator_status: indicator_status,
93
- bot_conf: bot_conf,
94
- fiat_portfolio_file: fiat_portfolio_file
95
- )
96
-
97
- unless event_history.order_plan_details_win_active
98
- event_history = Cryptum::UI::OrderPlan.refresh(
99
- option_choice: option_choice,
100
- order_plan_win: terminal_win.order_plan_section,
101
- env: env,
102
- event_history: event_history,
103
- key_press_event: terminal_win.key_press_event,
104
- indicator_status: indicator_status,
105
- bot_conf: bot_conf,
106
- fiat_portfolio_file: fiat_portfolio_file
107
- )
108
- recalc_op = event_history.recalculate_order_plan
109
- order_plan = event_history.order_book[:order_plan]
110
- terminal_win.key_press_event.key_w = true if (recalc_op || order_plan.empty?) &&
111
- !event_history.red_pill
112
- event_history.recalculate_order_plan = false
113
- end
114
-
115
- if event_history.order_plan_details_win_active
116
- event_history = Cryptum::UI::OrderPlanDetails.refresh(
117
- option_choice: option_choice,
118
- order_plan_details_win: terminal_win.order_plan_details_section,
119
- event_history: event_history,
120
- key_press_event: terminal_win.key_press_event
121
- )
122
- end
123
-
124
- unless event_history.order_execute_details_win_active
125
- event_history = Cryptum::UI::OrderExecution.refresh(
126
- option_choice: option_choice,
127
- order_execute_win: terminal_win.order_execute_section,
128
- env: env,
129
- event_history: event_history,
130
- key_press_event: terminal_win.key_press_event,
131
- indicator_status: indicator_status,
132
- bot_conf: bot_conf,
133
- fiat_portfolio_file: fiat_portfolio_file
134
- )
135
- end
136
-
137
- if event_history.order_execute_details_win_active
138
- event_history = Cryptum::UI::OrderExecuteDetails.refresh(
139
- option_choice: option_choice,
140
- order_execute_details_win: terminal_win.order_execute_details_section,
141
- event_history: event_history,
142
- key_press_event: terminal_win.key_press_event
143
- )
144
- end
145
-
146
- # Refresh Command Section for Cryptum Session Usage
147
- Cryptum::UI::Command.refresh(
148
- command_win: terminal_win.command_section,
149
- key_press_event: terminal_win.key_press_event
150
- )
151
-
152
- event_history
153
- rescue Interrupt
154
- # Exit Gracefully if CTRL+C is Pressed During Session
155
- Cryptum.exit_gracefully(
156
- which_self: self,
157
- event_history: event_history,
158
- option_choice: option_choice,
159
- env: env
160
- )
161
- rescue StandardError => e
162
- raise e
163
- end
164
-
165
- # Display Usage for this Module
166
- public_class_method def self.help
167
- puts "USAGE:
168
- #{self}.websocket_msg(
169
- env: env,
170
- terminal_win: terminal_win,
171
- option_choice: option_choice,
172
- event_history: event_history,
173
- indicator_status: indicator_status,
174
- bot_conf: bot_conf,
175
- ai_enabled: ai_enabled
176
- )
177
- "
178
- end
179
- end
180
- end
181
- end
@@ -1,200 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Scroll through Order Plan
5
- # Order Plan and Order History Window Panes
6
- # to File When the "w" Key is Pressed
7
- module Event
8
- module Scroll
9
- # Supported Method Parameters::
10
- # Cryptum::Event::Scroll.up(
11
- # )
12
- public_class_method def self.up(opts = {})
13
- terminal_win = opts[:terminal_win]
14
- event_history = opts[:event_history]
15
-
16
- terminal_win.key_press_event.key_ansi = false
17
- terminal_win.key_press_event.key_esc = false
18
- terminal_win.key_press_event.key_up_arrow = false
19
-
20
- if event_history.order_plan_win_active
21
- event_history.order_plan_row_to_select -= 1
22
- event_history.order_plan_index_offset -= 1 if event_history.order_plan_row_to_select.negative?
23
- event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
24
- event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
25
- end
26
-
27
- if event_history.order_execute_win_active
28
- event_history.order_execute_row_to_select -= 1
29
- event_history.order_execute_index_offset -= 1 if event_history.order_execute_row_to_select.negative?
30
- event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
31
- event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
32
- end
33
- rescue StandardError => e
34
- raise e
35
- end
36
-
37
- # Supported Method Parameters::
38
- # Cryptum::Event::Scroll.down(
39
- # )
40
- public_class_method def self.down(opts = {})
41
- terminal_win = opts[:terminal_win]
42
- event_history = opts[:event_history]
43
-
44
- terminal_win.key_press_event.key_ansi = false
45
- terminal_win.key_press_event.key_esc = false
46
- terminal_win.key_press_event.key_down_arrow = false
47
-
48
- order_book = event_history.order_book
49
-
50
- if event_history.order_plan_win_active
51
- order_plan_length = order_book[:order_plan].length
52
- last_row = order_plan_length - 1
53
- event_history.order_plan_max_records_available_to_display = last_row if last_row < event_history.order_plan_max_rows_to_display
54
-
55
- event_history.order_plan_row_to_select += 1
56
- event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > event_history.order_plan_max_records_available_to_display
57
- event_history.order_plan_row_to_select = event_history.order_plan_max_records_available_to_display if event_history.order_plan_row_to_select > event_history.order_plan_max_records_available_to_display
58
- end
59
-
60
- if event_history.order_execute_win_active
61
- order_history_meta_length = order_book[:order_history_meta].length
62
- last_row = order_history_meta_length - 1
63
- event_history.order_execute_max_records_available_to_display = last_row if last_row < event_history.order_execute_max_rows_to_display
64
-
65
- event_history.order_execute_row_to_select += 1
66
- event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > event_history.order_execute_max_records_available_to_display
67
- event_history.order_execute_row_to_select = event_history.order_execute_max_records_available_to_display if event_history.order_execute_row_to_select > event_history.order_execute_max_records_available_to_display
68
- end
69
- rescue StandardError => e
70
- raise e
71
- end
72
-
73
- # Supported Method Parameters::
74
- # Cryptum::Event::Scroll.page_up(
75
- # )
76
- public_class_method def self.page_up(opts = {})
77
- terminal_win = opts[:terminal_win]
78
- event_history = opts[:event_history]
79
-
80
- terminal_win.key_press_event.key_ansi = false
81
- terminal_win.key_press_event.key_esc = false
82
- terminal_win.key_press_event.key_page_up = false
83
-
84
- if event_history.order_plan_win_active
85
- event_history.order_plan_row_to_select = 0
86
- event_history.order_plan_index_offset -= event_history.order_plan_max_rows_to_display + 1
87
- event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
88
- event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
89
- end
90
-
91
- if event_history.order_execute_win_active
92
- event_history.order_execute_row_to_select = 0
93
- event_history.order_execute_index_offset -= event_history.order_execute_max_rows_to_display + 1
94
- event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
95
- event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
96
- end
97
- rescue StandardError => e
98
- raise e
99
- end
100
-
101
- # Supported Method Parameters::
102
- # Cryptum::Event::Scroll.page_down(
103
- # )
104
- public_class_method def self.page_down(opts = {})
105
- terminal_win = opts[:terminal_win]
106
- event_history = opts[:event_history]
107
-
108
- terminal_win.key_press_event.key_ansi = false
109
- terminal_win.key_press_event.key_esc = false
110
- terminal_win.key_press_event.key_page_down = false
111
-
112
- order_book = event_history.order_book
113
-
114
- if event_history.order_plan_win_active
115
- order_plan_length = order_book[:order_plan].length
116
- event_history.order_plan_row_to_select = 0
117
- event_history.order_plan_index_offset += event_history.order_plan_max_rows_to_display + 1 unless event_history.order_plan_index_offset > order_plan_length
118
- end
119
-
120
- if event_history.order_execute_win_active
121
- order_history_meta_length = order_book[:order_history_meta].length
122
- event_history.order_execute_row_to_select = 0
123
- event_history.order_execute_index_offset += event_history.order_execute_max_rows_to_display + 1 unless event_history.order_execute_index_offset > order_history_meta_length
124
- end
125
- rescue StandardError => e
126
- raise e
127
- end
128
-
129
- # Supported Method Parameters::
130
- # Cryptum::Event::Scroll.top(
131
- # )
132
- public_class_method def self.top(opts = {})
133
- terminal_win = opts[:terminal_win]
134
- event_history = opts[:event_history]
135
-
136
- terminal_win.key_press_event.key_ansi = false
137
- terminal_win.key_press_event.key_esc = false
138
- terminal_win.key_press_event.key_home = false
139
-
140
- if event_history.order_plan_win_active
141
- event_history.order_plan_row_to_select = 0
142
- event_history.order_plan_index_offset = 0
143
- end
144
-
145
- if event_history.order_execute_win_active
146
- event_history.order_execute_row_to_select = 0
147
- event_history.order_execute_index_offset = 0
148
- end
149
- rescue StandardError => e
150
- raise e
151
- end
152
-
153
- # Supported Method Parameters::
154
- # Cryptum::Event::Scroll.bottom(
155
- # )
156
- public_class_method def self.bottom(opts = {})
157
- terminal_win = opts[:terminal_win]
158
- event_history = opts[:event_history]
159
-
160
- terminal_win.key_press_event.key_ansi = false
161
- terminal_win.key_press_event.key_esc = false
162
- terminal_win.key_press_event.key_end = false
163
-
164
- order_book = event_history.order_book
165
-
166
- if event_history.order_plan_win_active
167
- order_plan_length = order_book[:order_plan].length
168
- last_row = order_plan_length - 1
169
- event_history.order_plan_max_records_available_to_display = last_row if last_row < event_history.order_plan_max_rows_to_display
170
-
171
- event_history.order_plan_row_to_select = event_history.order_plan_max_records_available_to_display
172
- event_history.order_plan_index_offset = order_plan_length - event_history.order_plan_max_records_available_to_display
173
- end
174
-
175
- if event_history.order_execute_win_active
176
- order_history_meta_length = order_book[:order_history_meta].length
177
- last_row = order_history_meta_length - 1
178
- event_history.order_execute_max_records_available_to_display = last_row if last_row < event_history.order_execute_max_rows_to_display
179
-
180
- event_history.order_execute_row_to_select = event_history.order_execute_max_records_available_to_display
181
- event_history.order_execute_index_offset = order_history_meta_length - event_history.order_execute_max_records_available_to_display
182
- end
183
- rescue StandardError => e
184
- raise e
185
- end
186
-
187
- # Display Usage for this Module
188
- public_class_method def self.help
189
- puts "USAGE:
190
- #{self}.up()
191
- #{self}.down()
192
- #{self}.page_up()
193
- #{self}.page_down()
194
- #{self}.top()
195
- #{self}.bottom()
196
- "
197
- end
198
- end
199
- end
200
- end
@@ -1,124 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Submit a Limit Order
5
- # to Sell Crypto Currency
6
-
7
- module Event
8
- module Sell
9
- # Supported Method Parameters::
10
- # Cryptum::Event::Sell.crypto(
11
- # )
12
- public_class_method def self.crypto(opts = {})
13
- option_choice = opts[:option_choice]
14
- env = opts[:env]
15
- bot_conf = opts[:bot_conf]
16
- stuck_in_pos_status = opts[:stuck_in_pos_status]
17
- event_history = opts[:event_history]
18
- order_type = opts[:order_type]
19
- fiat_smallest_decimal = opts[:fiat_smallest_decimal]
20
- crypto_smallest_decimal = opts[:crypto_smallest_decimal]
21
- # base_min_size = opts[:base_min_size]
22
- min_market_funds = this_product[:min_market_funds]
23
- indicator_status = opts[:indicator_status]
24
- quote_increment = opts[:quote_increment]
25
-
26
- # Initialize some bot_conf variables
27
- pie_in_sky_sell_percent = bot_conf[:pie_in_sky_sell_percent].to_f
28
-
29
- crypto_currency = option_choice.symbol.to_s.upcase.split('_').first
30
- portfolio = event_history.order_book[:portfolio]
31
- symbol_portfolio = portfolio.select do |this_portfolio|
32
- this_portfolio if this_portfolio[:currency] == crypto_currency
33
- end
34
-
35
- symbol_balance_available = format(
36
- '%0.8f',
37
- symbol_portfolio.first[:available].to_f
38
- ).to_f
39
-
40
- # 2. Calculate Price, Size, Fees
41
- # Get the middle of last 3 ticker prices
42
- # to avoid over purcase blips.
43
- last_three_prices_arr = []
44
- last_ticker_price = event_history.order_book[:ticker_price].to_f
45
- second_to_last_ticker_price = event_history.order_book[:ticker_price_second_to_last].to_f
46
- third_to_last_ticker_price = event_history.order_book[:ticker_price_third_to_last].to_f
47
- last_three_prices_arr.push(last_ticker_price)
48
- last_three_prices_arr.push(second_to_last_ticker_price)
49
- last_three_prices_arr.push(third_to_last_ticker_price)
50
- # limit_price = last_three_prices_arr.min
51
- # limit_price = last_three_prices_arr.max
52
-
53
- # Obtain our Target Price based on TPM configurations
54
- target_symbol_price = stuck_in_pos_status[:target_symbol_price].to_f
55
-
56
- case order_type
57
- when :pie
58
- pie_in_sky_sell_percent_cast_as_decimal = format(
59
- '%0.2f',
60
- pie_in_sky_sell_percent * 0.01
61
- ).to_f
62
-
63
- target_profit = target_symbol_price * pie_in_sky_sell_percent_cast_as_decimal
64
- limit_price = target_symbol_price + target_profit
65
-
66
- when :tpm
67
- limit_price = target_symbol_price
68
- # TODO: Ensure previous order price
69
- # on last _open order_ if applicable
70
- # is greater than this one.
71
- order_type = :tpm
72
- when :gtfo
73
- # Attempt to get in front of falling price.
74
- limit_price = last_three_prices_arr.sort[1]
75
- gtfo_price = limit_price -= quote_increment.to_f
76
- limit_price = gtfo_price if gtfo_price.positive?
77
- else
78
- raise "ERROR: Unknown order_type: #{order_type}"
79
- end
80
-
81
- price = format("%0.#{fiat_smallest_decimal}f", limit_price)
82
-
83
- # Selling Available Crytpo Balance in its Entirety
84
- # We Will Likely Want to Change this in the Future.
85
- size = format(
86
- "%0.#{crypto_smallest_decimal}f",
87
- symbol_balance_available.floor(crypto_smallest_decimal)
88
- )
89
-
90
- size = symbol_balance_available if min_market_funds.to_i == 1
91
-
92
- if size.to_f >= min_market_funds.to_f &&
93
- price.to_f.positive?
94
-
95
- # SUBMIT SELL ORDER
96
- event_history.order_submitted = true
97
- event_history.event_notes = "{ \"event_type\": \"#{event_history.event_type}\", \"cancel\": \"#{event_history.order_canceled}\", \"submitted\": \"#{event_history.order_submitted}\" }" if option_choice.proxy
98
-
99
- event_history = Cryptum::API.submit_limit_order(
100
- option_choice: option_choice,
101
- env: env,
102
- price: price,
103
- size: size,
104
- buy_or_sell: :sell,
105
- order_type: order_type,
106
- event_history: event_history,
107
- indicator_status: indicator_status
108
- )
109
- end
110
-
111
- event_history
112
- rescue StandardError => e
113
- raise e
114
- end
115
-
116
- # Display Usage for this Module
117
- public_class_method def self.help
118
- puts "USAGE:
119
- order_book = #{self}.crypto()
120
- "
121
- end
122
- end
123
- end
124
- end
data/lib/cryptum/event.rb DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- module Cryptum
6
- # This plugin is used to parse Coinbase Pro Web Socket Events in the HTTP Response
7
- module Event
8
- require 'cryptum/event/bot_conf'
9
- require 'cryptum/event/buy'
10
- require 'cryptum/event/cancel'
11
- require 'cryptum/event/exit'
12
- require 'cryptum/event/gtfo'
13
- require 'cryptum/event/history'
14
- require 'cryptum/event/key_press'
15
- require 'cryptum/event/order_book'
16
- require 'cryptum/event/pane'
17
- require 'cryptum/event/parse'
18
- require 'cryptum/event/scroll'
19
- require 'cryptum/event/sell'
20
-
21
- # Display Usage for this Module
22
-
23
- public_class_method def self.help
24
- constants.sort
25
- end
26
- end
27
- end
data/lib/cryptum/log.rb DELETED
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- module Cryptum
6
- # This plugin is used to instantiate a Cryptum logger with a custom message format
7
- module Log
8
- # Supported Method Parameters::
9
- # Cryptum::Log.create(
10
- # )
11
- public_class_method def self.create
12
- logger = Logger.new($stdout)
13
- logger.level = Logger::INFO
14
- logger.datetime_format = '%Y-%m-%d %H:%M:%S'
15
-
16
- logger.formatter = proc do |severity, _datetime, _progname, msg|
17
- # TODO: Include datetime & progname vars
18
- "[#{severity}] #{msg}\n"
19
- end
20
-
21
- logger
22
- rescue StandardError => e
23
- raise e
24
- end
25
-
26
- # Display Usage for this Module
27
-
28
- public_class_method def self.help
29
- puts "USAGE:
30
- logger = #{self}.create()
31
- "
32
- end
33
- end
34
- end