cryptum 0.0.355 → 0.0.356

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,197 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- module Cryptum
6
- # This plugin is used to read and update bot conf files.
7
- module BotConf
8
- # Deserialize Cryptum Bot Conf
9
- public_class_method def self.read(opts = {})
10
- option_choice = opts[:option_choice]
11
- event_history = opts[:event_history]
12
-
13
- session_root = option_choice.session_root
14
- symbol = option_choice.symbol
15
- bot_conf_file = "#{session_root}/etc/bot_confs/#{symbol}_bot_conf.yaml"
16
- unless File.exist?(bot_conf_file)
17
- FileUtils.cp(
18
- "#{session_root}/etc/bot_confs/BOT_CONF.TEMPLATE",
19
- bot_conf_file
20
- )
21
- end
22
-
23
- bot_conf = YAML.load_file(
24
- bot_conf_file,
25
- symbolize_names: true
26
- )
27
-
28
- ai_enabled = bot_conf[:artifical_intelligence]
29
- if ai_enabled && event_history
30
- bot_conf = Cryptum::BotConf.recalculate_tpm(
31
- option_choice: option_choice,
32
- event_history: event_history,
33
- bot_conf: bot_conf
34
- )
35
- end
36
-
37
- bot_conf
38
- rescue Errno::ENOENT, NoMethodError => e
39
- File.open('/tmp/cryptum-errors.txt', 'a') do |f|
40
- f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
41
- f.puts "Module: #{self}"
42
- f.puts "#{e}\n\n\n"
43
- end
44
-
45
- retry
46
- rescue Interrupt
47
- # Exit Gracefully if CTRL+C is Pressed During Session
48
- Cryptum.exit_gracefully(which_self: self)
49
- rescue StandardError => e
50
- # Produce a Stacktrace for anything else
51
- Curses.close_screen
52
- raise e
53
- end
54
-
55
- # SAUCE 1
56
- # Calculate Target Profit Margin Percent Based Upon
57
- # Observed Margins of Change in the Past 24hrs.
58
- public_class_method def self.recalculate_tpm(opts = {})
59
- option_choice = opts[:option_choice]
60
- event_history = opts[:event_history]
61
- bot_conf = opts[:bot_conf]
62
-
63
- # BE EXTREMELY CAREFUL CHANGING THIS VALUE AS IT DICTATES
64
- # THE TARGET PRICE AND SUBSEQUENT TIME IT TAKES FOR AN OPEN
65
- # SELL ORDER TO BE TRIGGERED!!! SHOULD NEVER BE > 1
66
- default_net_tpm = 1.0
67
- maker_rate = 0.4
68
- taker_rate = 0.6
69
-
70
- gross_tpm = bot_conf[:target_profit_margin_percent].to_f
71
-
72
- # Refactor TPM to be 1.0 > than fee tier,
73
- # particularly as fee tier goes up or down
74
- fees = event_history.order_book[:fees]
75
- maker_rate = fees[:maker_fee_rate].to_f unless fees.empty?
76
- # maker_fee = format('%0.2f', maker_rate * 100)
77
-
78
- taker_rate = fees[:taker_fee_rate].to_f unless fees.empty?
79
- # taker_fee = format('%0.2f', taker_rate * 100)
80
-
81
- # Set default_net_tpm if AI is true in bot_conf.
82
- low_24h = event_history.order_book[:low_24h].to_f
83
- high_24h = event_history.order_book[:high_24h].to_f
84
-
85
- case option_choice.market_trend_reset
86
- when 604_800
87
- # 1W Chart
88
- ai_net_tpm = ((1 - (low_24h / high_24h)) * 100) * 7
89
- when 86_400
90
- # 1D Chart
91
- ai_net_tpm = (1 - (low_24h / high_24h)) * 100
92
- when 14_400
93
- # 4H Chart
94
- ai_net_tpm = ((1 - (low_24h / high_24h)) * 100) / 6
95
- when 10_800
96
- # 3H Chart
97
- ai_net_tpm = ((1 - (low_24h / high_24h)) * 100) / 8
98
- when 7_200
99
- # 2H Chart
100
- ai_net_tpm = ((1 - (low_24h / high_24h)) * 100) / 12
101
- when 3_600
102
- # 1H Chart
103
- ai_net_tpm = ((1 - (low_24h / high_24h)) * 100) / 24
104
- when 2_700
105
- # 45m Chart
106
- ai_net_tpm = (((1 - (low_24h / high_24h)) * 100) / 24) * 0.75
107
- when 1_800
108
- # 30m Chart
109
- ai_net_tpm = (((1 - (low_24h / high_24h)) * 100) / 24) * 0.5
110
- when 900
111
- # 15m Chart
112
- ai_net_tpm = (((1 - (low_24h / high_24h)) * 100) / 24) * 0.25
113
- when 300
114
- # 5m Chart
115
- ai_net_tpm = (((1 - (low_24h / high_24h)) * 100) / 24) * 0.083
116
- when 180
117
- # 3m Chart
118
- ai_net_tpm = (((1 - (low_24h / high_24h)) * 100) / 24) * 0.05
119
- when 60
120
- # 1m Chart
121
- ai_net_tpm = (((1 - (low_24h / high_24h)) * 100) / 24) * 0.017
122
- end
123
-
124
- default_net_tpm = ai_net_tpm if ai_net_tpm > default_net_tpm
125
-
126
- min_gross_tpm = format(
127
- '%0.2f',
128
- (maker_rate.to_f + taker_rate.to_f) + default_net_tpm
129
- )
130
-
131
- if min_gross_tpm != gross_tpm.to_s
132
- bot_conf[:target_profit_margin_percent] = min_gross_tpm.to_f
133
- Cryptum::BotConf.update(
134
- option_choice: option_choice,
135
- bot_conf: bot_conf,
136
- key: :target_profit_margin_percent,
137
- value: min_gross_tpm.to_f
138
- )
139
- end
140
-
141
- bot_conf
142
- rescue Errno::ENOENT, NoMethodError => e
143
- File.open('/tmp/cryptum-errors.txt', 'a') do |f|
144
- f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
145
- f.puts "Module: #{self}"
146
- f.puts "#{e}\n\n\n"
147
- end
148
-
149
- retry
150
- rescue Interrupt
151
- # Exit Gracefully if CTRL+C is Pressed During Session
152
- Cryptum.exit_gracefully(which_self: self)
153
- rescue StandardError => e
154
- # Produce a Stacktrace for anything else
155
- Curses.close_screen
156
- raise e
157
- end
158
-
159
- # Update Key/Value Pair in Bot Conf and Serialize to YAML File
160
- public_class_method def self.update(opts = {})
161
- option_choice = opts[:option_choice]
162
- bot_conf = opts[:bot_conf]
163
- key = opts[:key].to_s.to_sym
164
- value = opts[:value]
165
-
166
- session_root = option_choice.session_root
167
- symbol = option_choice.symbol
168
- bot_conf_file = "#{session_root}/etc/bot_confs/#{symbol}_bot_conf.yaml"
169
-
170
- bot_conf[key] = value
171
- File.write(bot_conf_file, bot_conf.to_yaml)
172
- rescue Errno::ENOENT, NoMethodError => e
173
- File.open('/tmp/cryptum-errors.txt', 'a') do |f|
174
- f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
175
- f.puts "Module: #{self}"
176
- f.puts "#{e}\n\n\n"
177
- end
178
-
179
- retry
180
- rescue Interrupt
181
- # Exit Gracefully if CTRL+C is Pressed During Session
182
- Cryptum.exit_gracefully(which_self: self)
183
- rescue StandardError => e
184
- # Produce a Stacktrace for anything else
185
- Curses.close_screen
186
- raise e
187
- end
188
-
189
- # Display Usage for this Module
190
-
191
- public_class_method def self.help
192
- puts "USAGE:
193
- logger = #{self}.create()
194
- "
195
- end
196
- end
197
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Reload the Bot Conf When the "r" Key is Pressed
5
- module Event
6
- module BotConf
7
- # Supported Method Parameters::
8
- # Cryptum::Event::BotConf.reload(
9
- # )
10
- public_class_method def self.reload(opts = {})
11
- terminal_win = opts[:terminal_win]
12
- event_history = opts[:event_history]
13
- option_choice = opts[:option_choice]
14
-
15
- event_history.recalculate_order_plan = true
16
- terminal_win.key_press_event.key_r = false
17
-
18
- Cryptum::BotConf.read(
19
- option_choice: option_choice,
20
- event_history: event_history
21
- )
22
- rescue StandardError => e
23
- raise e
24
- end
25
-
26
- # Display Usage for this Module
27
- public_class_method def self.help
28
- puts "USAGE:
29
- bot_conf = #{self}.reload()
30
- "
31
- end
32
- end
33
- end
34
- end
@@ -1,145 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Submit a Limit Order
5
- # to Buy Crypto Currency
6
-
7
- module Event
8
- module Buy
9
- # Supported Method Parameters::
10
- # Cryptum::Event::Buy.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
- event_history = opts[:event_history]
17
- order_type = opts[:order_type]
18
- fiat_smallest_decimal = opts[:fiat_smallest_decimal]
19
- # fiat_portfolio_file = opts[:fiat_portfolio_file]
20
- order_history = opts[:order_history]
21
- crypto_smallest_decimal = opts[:crypto_smallest_decimal]
22
- # base_min_size = opts[:base_min_size]
23
- min_market_funds = this_product[:min_market_funds]
24
- indicator_status = opts[:indicator_status]
25
-
26
- # Initialize some bot_conf variables
27
- pie_in_sky_buy_percent = bot_conf[:pie_in_sky_buy_percent].to_f
28
- autotrade_portfolio_percent = bot_conf[:autotrade_portfolio_percent].to_f
29
- # target_profit_margin_percent = bot_conf[:target_profit_margin_percent].to_f
30
-
31
- crypto_currency = option_choice.symbol.to_s.upcase.split('_').first
32
- portfolio = event_history.order_book[:portfolio]
33
- symbol_portfolio = portfolio.select do |this_portfolio|
34
- this_portfolio if this_portfolio[:currency] == crypto_currency
35
- end
36
-
37
- symbol_balance = format(
38
- '%0.8f',
39
- symbol_portfolio.first[:balance].to_f
40
- ).to_f
41
-
42
- # 2. Calculate Price, Size, Fees
43
- # Get the middle of last 3 ticker prices
44
- # to avoid over purcase blips.
45
- last_three_prices_arr = []
46
- last_ticker_price = event_history.order_book[:ticker_price].to_f
47
- second_to_last_ticker_price = event_history.order_book[:ticker_price_second_to_last].to_f
48
- third_to_last_ticker_price = event_history.order_book[:ticker_price_third_to_last].to_f
49
- last_three_prices_arr.push(last_ticker_price)
50
- last_three_prices_arr.push(second_to_last_ticker_price)
51
- last_three_prices_arr.push(third_to_last_ticker_price)
52
-
53
- case order_type
54
- when :pie
55
- limit_price = last_three_prices_arr.sort[1]
56
- pie_in_sky_buy_percent_cast_as_decimal = format(
57
- '%0.2f',
58
- pie_in_sky_buy_percent * 0.01
59
- ).to_f
60
-
61
- limit_price -= (limit_price * pie_in_sky_buy_percent_cast_as_decimal)
62
- when :tpm
63
- limit_price = last_three_prices_arr.sort[1]
64
- when :gtfo
65
- # price = format("%0.#{fiat_smallest_decimal}f", limit_price)
66
- raise "ERROR: Why is a Buy Submitted for #{order_type}?"
67
- else
68
- raise "ERROR: Unknown order_type: #{order_type}"
69
- end
70
-
71
- price = format("%0.#{fiat_smallest_decimal}f", limit_price)
72
-
73
- # TODO: Determine if our N% Autotrade
74
- # Threshold has already been met
75
- # Buying Crypto w/ Fiat
76
- autotrade_portfolio_percent_cast_as_decimal = format(
77
- '%0.7f',
78
- autotrade_portfolio_percent * 0.01
79
- ).to_f
80
-
81
- fiat_portfolio = event_history.order_book[:fiat_portfolio]
82
- fiat_balance_available = format(
83
- "%0.#{fiat_smallest_decimal}f",
84
- fiat_portfolio.first[:available]
85
- ).to_f
86
-
87
- # Make sure size is within constraints
88
- # of autotrade_portfolio_percent
89
- total_limit_buy_orders_open = order_history.select do |orders|
90
- orders[:type] == 'limit' &&
91
- orders[:side] == 'buy' &&
92
- orders[:status] == 'open'
93
- end
94
-
95
- total_limit_buy_order_open_tot = total_limit_buy_orders_open.length
96
- total_limit_buy_orders_open_size = total_limit_buy_orders_open.inject(0) do |sum, hash|
97
- sum + hash[:size].to_f
98
- end.to_f
99
-
100
- fiat_to_autotrade = fiat_balance_available * autotrade_portfolio_percent_cast_as_decimal
101
- calc_fiat_to_buy = (fiat_to_autotrade / last_ticker_price) - symbol_balance
102
- size = format(
103
- "%0.#{crypto_smallest_decimal}f",
104
- calc_fiat_to_buy - total_limit_buy_orders_open_size
105
- )
106
-
107
- if min_market_funds.to_i >= 1
108
- size = (
109
- (calc_fiat_to_buy - total_limit_buy_orders_open_size).to_i - min_market_funds.to_i
110
- ).to_s
111
- end
112
-
113
- if size.to_f >= min_market_funds.to_f &&
114
- total_limit_buy_order_open_tot.zero? &&
115
- price.to_f.positive?
116
- # SUBMIT BUY ORDER
117
- event_history.order_submitted = true
118
- event_history.event_notes = "{ \"event_type\": \"#{event_history.event_type}\", \"cancel\": \"#{event_history.order_canceled}\", \"submitted\": \"#{event_history.order_submitted}\" }" if option_choice.proxy
119
-
120
- event_history = Cryptum::API.submit_limit_order(
121
- option_choice: option_choice,
122
- env: env,
123
- price: price,
124
- size: size,
125
- buy_or_sell: :buy,
126
- order_type: order_type,
127
- event_history: event_history,
128
- indicator_status: indicator_status
129
- )
130
- end
131
-
132
- event_history
133
- rescue StandardError => e
134
- raise e
135
- end
136
-
137
- # Display Usage for this Module
138
- public_class_method def self.help
139
- puts "USAGE:
140
- event_history = #{self}.crypto()
141
- "
142
- end
143
- end
144
- end
145
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Reload the Bot Conf When the "C" Key is Pressed
5
- module Event
6
- module Cancel
7
- # Supported Method Parameters::
8
- # Cryptum::Event::Cancel.open_orders(
9
- # )
10
- public_class_method def self.open_orders(opts = {})
11
- terminal_win = opts[:terminal_win]
12
- option_choice = opts[:option_choice]
13
- env = opts[:env]
14
- # event_history = opts[:event_history]
15
- # order_type = opts[:order_type]
16
- # order_action = opts[:order_action]
17
-
18
- terminal_win.key_press_event.key_c = false
19
- Cryptum::API.cancel_all_open_orders(
20
- env: env,
21
- option_choice: option_choice
22
- )
23
- rescue StandardError => e
24
- raise e
25
- end
26
-
27
- # Display Usage for this Module
28
- public_class_method def self.help
29
- puts "USAGE:
30
- #{self}.open_orders()
31
- "
32
- end
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Exit Cryptum Gracefully When the "x" Key is Pressed
5
- module Event
6
- module Exit
7
- # Supported Method Parameters::
8
- # Cryptum::Event::BotConf.gracefully(
9
- # )
10
- public_class_method def self.gracefully(opts = {})
11
- terminal_win = opts[:terminal_win]
12
- event_history = opts[:event_history]
13
- option_choice = opts[:option_choice]
14
- env = opts[:env]
15
-
16
- terminal_win.key_press_event.key_x = false
17
- Cryptum.exit_gracefully(
18
- which_self: self,
19
- event_history: event_history,
20
- option_choice: option_choice,
21
- env: env
22
- )
23
- rescue StandardError => e
24
- raise e
25
- end
26
-
27
- # Display Usage for this Module
28
- public_class_method def self.help
29
- puts "USAGE:
30
- #{self}.gracefully()
31
- "
32
- end
33
- end
34
- end
35
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Get the F* Out (GTFO) when the "G" Key is Pressed
5
- module Event
6
- module GTFO
7
- # Supported Method Parameters::
8
- # Cryptum::Event::GTFO.now(
9
- # )
10
- public_class_method def self.now(opts = {})
11
- terminal_win = opts[:terminal_win]
12
- option_choice = opts[:option_choice]
13
- env = opts[:env]
14
- event_history = opts[:event_history]
15
- bot_conf = opts[:bot_conf]
16
-
17
- terminal_win.key_press_event.key_g = false
18
- Cryptum::API.gtfo(
19
- option_choice: option_choice,
20
- env: env,
21
- event_history: event_history,
22
- bot_conf: bot_conf
23
- )
24
- rescue StandardError => e
25
- raise e
26
- end
27
-
28
- # Display Usage for this Module
29
- public_class_method def self.help
30
- puts "USAGE:
31
- bot_conf = #{self}.now()
32
- "
33
- end
34
- end
35
- end
36
- end
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Track Event History
5
- module Event
6
- # Keep Last Event History When Terminal Resize Occuers
7
- class History
8
- attr_accessor :bullish_trend,
9
- :event,
10
- :event_notes,
11
- :event_type,
12
- :first_event,
13
- :market_trend_event,
14
- :open_sell_orders,
15
- :open_sell_orders_max,
16
- :open_sell_orders_merge,
17
- :order_book,
18
- :order_canceled,
19
- :order_execute_win_active,
20
- :order_execute_details_win_active,
21
- :order_execute_index_offset,
22
- :order_execute_max_rows_to_display,
23
- :order_execute_max_records_available_to_display,
24
- :order_execute_row_to_select,
25
- :order_execute_selected_data,
26
- :order_plan_win_active,
27
- :order_plan_details_win_active,
28
- :order_plan_index_offset,
29
- :order_plan_max_rows_to_display,
30
- :order_plan_max_records_available_to_display,
31
- :order_plan_row_to_select,
32
- :order_plan_selected_data,
33
- :order_ready,
34
- :order_submitted,
35
- :plan_no,
36
- :reconnected,
37
- :red_pill,
38
- :start_time,
39
- :ticker_event,
40
- :time_between_orders,
41
- :time_between_orders_max,
42
- :time_between_orders_min,
43
- :time_between_orders_reset,
44
- :recalculate_order_plan
45
-
46
- def initialize(opts = {})
47
- # option_choice = opts[:option_choice]
48
- start_time = opts[:start_time]
49
- order_book = opts[:order_book]
50
-
51
- self.bullish_trend = true
52
- self.first_event = true
53
- self.open_sell_orders = 0
54
- self.open_sell_orders_max = 500
55
- self.open_sell_orders_merge = false
56
- self.order_book = order_book
57
- self.order_canceled = false
58
- self.order_execute_win_active = false
59
- self.order_execute_details_win_active = false
60
- self.order_execute_index_offset = 0
61
- self.order_execute_max_rows_to_display = 6
62
- self.order_execute_max_records_available_to_display = 6
63
- self.order_execute_row_to_select = order_execute_index_offset
64
- self.order_execute_selected_data = { color: :white }
65
- self.order_plan_win_active = true
66
- self.order_plan_details_win_active = false
67
- self.order_plan_index_offset = 0
68
- self.order_plan_max_rows_to_display = 6
69
- self.order_plan_max_records_available_to_display = 6
70
- self.order_plan_row_to_select = order_plan_index_offset
71
- self.order_plan_selected_data = { color: :white }
72
- self.order_ready = false
73
- self.order_submitted = false
74
- self.plan_no = 1
75
- self.reconnected = false
76
- self.red_pill = false
77
- self.recalculate_order_plan = false
78
- self.start_time = start_time
79
-
80
- # -------------------------------------------------- #
81
- # SAUCE 4
82
- # TODO: develop algorithm to calculate
83
- # FAST BUY && SLOW BUY values taking
84
- # market_trend_reset values into account
85
-
86
- # FAST BUY = 10 minutes
87
- self.time_between_orders = 600
88
- self.time_between_orders_reset = time_between_orders
89
-
90
- # SLOW BUY = 1 hour
91
- self.time_between_orders_max = 3_600
92
-
93
- # 5 seconds
94
- self.time_between_orders_min = 5
95
- # -------------------------------------------------- #
96
- end
97
- rescue Interrupt
98
- # Exit Gracefully if CTRL+C is Pressed During Session
99
- Cryptum.exit_gracefully(which_self: self)
100
- rescue StandardError => e
101
- # Produce a Stacktrace for anything else
102
- raise e
103
- end
104
- end
105
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Detect if any Keys were Pressed on the Keyboard
5
- module Event
6
- module KeyPress
7
- # Supported Method Parameters::
8
- # Cryptum::Event::KeyPress.detect(
9
- # )
10
- public_class_method def self.detect(opts = {})
11
- terminal_win = opts[:terminal_win]
12
-
13
- Cryptum::UI.detect_key_press_in_ui(
14
- key_press_event: terminal_win.key_press_event,
15
- ui_win: terminal_win.ticker_section
16
- )
17
-
18
- Cryptum::UI.detect_key_press_in_ui(
19
- key_press_event: terminal_win.key_press_event,
20
- ui_win: terminal_win.portfolio_section
21
- )
22
-
23
- Cryptum::UI.detect_key_press_in_ui(
24
- key_press_event: terminal_win.key_press_event,
25
- ui_win: terminal_win.order_plan_section
26
- )
27
-
28
- Cryptum::UI.detect_key_press_in_ui(
29
- key_press_event: terminal_win.key_press_event,
30
- ui_win: terminal_win.order_timer_section
31
- )
32
-
33
- Cryptum::UI.detect_key_press_in_ui(
34
- key_press_event: terminal_win.key_press_event,
35
- ui_win: terminal_win.market_trend_section
36
- )
37
-
38
- Cryptum::UI.detect_key_press_in_ui(
39
- key_press_event: terminal_win.key_press_event,
40
- ui_win: terminal_win.signal_engine_section
41
- )
42
-
43
- Cryptum::UI.detect_key_press_in_ui(
44
- key_press_event: terminal_win.key_press_event,
45
- ui_win: terminal_win.order_execute_section
46
- )
47
-
48
- Cryptum::UI.detect_key_press_in_ui(
49
- key_press_event: terminal_win.key_press_event,
50
- ui_win: terminal_win.command_section
51
- )
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
- order_book = #{self}.crypto()
60
- "
61
- end
62
- end
63
- end
64
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cryptum
4
- # This plugin is used to Write the Order Book from Memory
5
- # to File When the "w" Key is Pressed
6
- module Event
7
- module OrderBook
8
- # Supported Method Parameters::
9
- # Cryptum::Event::BotConf.write(
10
- # )
11
- public_class_method def self.write(opts = {})
12
- terminal_win = opts[:terminal_win]
13
- event_history = opts[:event_history]
14
-
15
- terminal_win.key_press_event.key_w = false
16
- order_book_file = event_history.order_book[:path]
17
-
18
- File.write(
19
- order_book_file,
20
- JSON.pretty_generate(event_history.order_book)
21
- )
22
- rescue StandardError => e
23
- raise e
24
- end
25
-
26
- # Display Usage for this Module
27
- public_class_method def self.help
28
- puts "USAGE:
29
- #{self}.write()
30
- "
31
- end
32
- end
33
- end
34
- end