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.
- checksums.yaml +4 -4
- metadata +13 -116
- data/.github/workflows/main.yml +0 -16
- data/.gitignore +0 -30
- data/.rspec +0 -3
- data/.rspec_status +0 -0
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -32
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/CODE_OF_CONDUCT.md +0 -84
- data/Gemfile +0 -38
- data/LICENSE +0 -674
- data/README.md +0 -87
- data/Rakefile +0 -19
- data/bin/cryptum +0 -73
- data/bin/cryptum-forecast +0 -200
- data/bin/cryptum-repl +0 -73
- data/bin/cryptum_autoinc_version +0 -38
- data/build_cryptum_gem.sh +0 -58
- data/cryptum.gemspec +0 -52
- data/cryptum_container.sh +0 -1
- data/docker/cryptum.json +0 -60
- data/docker/cryptum_container.sh +0 -59
- data/docker/packer_secrets.json.EXAMPLE +0 -7
- data/docker/provisioners/cryptum.sh +0 -11
- data/docker/provisioners/docker_bashrc.sh +0 -2
- data/docker/provisioners/docker_rvm.sh +0 -22
- data/docker/provisioners/init_image.sh +0 -28
- data/docker/provisioners/post_install.sh +0 -6
- data/docker/provisioners/ruby.sh +0 -16
- data/docker/provisioners/upload_globals.sh +0 -49
- data/etc/bot_confs/.gitkeep +0 -0
- data/etc/bot_confs/BOT_CONF.TEMPLATE +0 -10
- data/etc/coinbase_pro.yaml.EXAMPLE +0 -8
- data/etc/open_ai.yaml.EXAMPLE +0 -1
- data/git_commit.sh +0 -22
- data/lib/cryptum/api.rb +0 -688
- data/lib/cryptum/bot_conf.rb +0 -197
- data/lib/cryptum/event/bot_conf.rb +0 -34
- data/lib/cryptum/event/buy.rb +0 -145
- data/lib/cryptum/event/cancel.rb +0 -35
- data/lib/cryptum/event/exit.rb +0 -35
- data/lib/cryptum/event/gtfo.rb +0 -36
- data/lib/cryptum/event/history.rb +0 -105
- data/lib/cryptum/event/key_press.rb +0 -64
- data/lib/cryptum/event/order_book.rb +0 -34
- data/lib/cryptum/event/pane.rb +0 -65
- data/lib/cryptum/event/parse.rb +0 -181
- data/lib/cryptum/event/scroll.rb +0 -200
- data/lib/cryptum/event/sell.rb +0 -124
- data/lib/cryptum/event.rb +0 -27
- data/lib/cryptum/log.rb +0 -34
- data/lib/cryptum/matrix.rb +0 -181
- data/lib/cryptum/open_ai.rb +0 -156
- data/lib/cryptum/option/choice.rb +0 -28
- data/lib/cryptum/option.rb +0 -206
- data/lib/cryptum/order_book/generate.rb +0 -114
- data/lib/cryptum/order_book/indicator.rb +0 -15
- data/lib/cryptum/order_book/market_trend.rb +0 -137
- data/lib/cryptum/order_book/profit_margin.rb +0 -55
- data/lib/cryptum/order_book.rb +0 -19
- data/lib/cryptum/portfolio/balance.rb +0 -123
- data/lib/cryptum/portfolio.rb +0 -15
- data/lib/cryptum/ui/command.rb +0 -314
- data/lib/cryptum/ui/key_press_event.rb +0 -33
- data/lib/cryptum/ui/market_trend.rb +0 -74
- data/lib/cryptum/ui/order_execute_details.rb +0 -297
- data/lib/cryptum/ui/order_execution.rb +0 -573
- data/lib/cryptum/ui/order_plan.rb +0 -503
- data/lib/cryptum/ui/order_plan_details.rb +0 -240
- data/lib/cryptum/ui/order_timer.rb +0 -121
- data/lib/cryptum/ui/portfolio.rb +0 -221
- data/lib/cryptum/ui/signal_engine.rb +0 -109
- data/lib/cryptum/ui/terminal_window.rb +0 -111
- data/lib/cryptum/ui/ticker.rb +0 -319
- data/lib/cryptum/ui.rb +0 -343
- data/lib/cryptum/version.rb +0 -5
- data/lib/cryptum/web_sock/coinbase.rb +0 -102
- data/lib/cryptum/web_sock/event_machine.rb +0 -274
- data/lib/cryptum/web_sock.rb +0 -16
- data/lib/cryptum.rb +0 -120
- data/order_books/.gitkeep +0 -0
- data/reinstall_cryptum_gemset.sh +0 -29
- data/spec/lib/cryptum/api_spec.rb +0 -10
- data/spec/lib/cryptum/event_spec.rb +0 -10
- data/spec/lib/cryptum/log_spec.rb +0 -10
- data/spec/lib/cryptum/option_spec.rb +0 -10
- data/spec/lib/cryptum/order_book/generate_spec.rb +0 -10
- data/spec/lib/cryptum/order_book/market_trend_spec.rb +0 -10
- data/spec/lib/cryptum/order_book_spec.rb +0 -10
- data/spec/lib/cryptum/ui/command_spec.rb +0 -10
- data/spec/lib/cryptum/ui/ticker_spec.rb +0 -10
- data/spec/lib/cryptum/ui_spec.rb +0 -10
- data/spec/lib/cryptum/web_sock_spec.rb +0 -10
- data/spec/lib/cryptum_spec.rb +0 -10
- data/spec/spec_helper.rb +0 -3
- data/upgrade_Gemfile_gems.sh +0 -20
- data/upgrade_cryptum.sh +0 -13
- data/upgrade_gem.sh +0 -4
- data/upgrade_ruby.sh +0 -45
@@ -1,137 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Cryptum
|
4
|
-
# This plugin is used to indicate if the order trend
|
5
|
-
|
6
|
-
module OrderBook
|
7
|
-
module MarketTrend
|
8
|
-
# Supported Method Parameters::
|
9
|
-
# Cryptum::OrderBook::OrderTrend.status(
|
10
|
-
# )
|
11
|
-
|
12
|
-
public_class_method def self.status(opts = {})
|
13
|
-
event_history = opts[:event_history]
|
14
|
-
event = opts[:event]
|
15
|
-
indicator_status = opts[:indicator_status]
|
16
|
-
|
17
|
-
# Compatible w/ l2update websocket channel
|
18
|
-
# buy_or_sell = event[:changes].first[0].to_s.to_sym
|
19
|
-
# case buy_or_sell
|
20
|
-
# when :buy
|
21
|
-
# event_history.order_book[:market_trend][:buy] += 1
|
22
|
-
# when :sell
|
23
|
-
# event_history.order_book[:market_trend][:sell] += 1
|
24
|
-
# else
|
25
|
-
# raise "UNKNOWN Value in event[:changes] => #{buy_or_sell}"
|
26
|
-
# end
|
27
|
-
|
28
|
-
# Compatible w/ l2update_batch websocket channel
|
29
|
-
buy_count = event[:changes].select { |change| change.first == 'buy' }.length
|
30
|
-
sell_count = event[:changes].select { |change| change.first == 'sell' }.length
|
31
|
-
event_history.order_book[:market_trend][:buy] += buy_count
|
32
|
-
event_history.order_book[:market_trend][:sell] += sell_count
|
33
|
-
|
34
|
-
indicator_hash = {}
|
35
|
-
buy_total = event_history.order_book[:market_trend][:buy].to_i
|
36
|
-
indicator_hash[:buy] = buy_total
|
37
|
-
|
38
|
-
sell_total = event_history.order_book[:market_trend][:sell].to_i
|
39
|
-
indicator_hash[:sell] = sell_total
|
40
|
-
|
41
|
-
# order_difference = 0
|
42
|
-
if buy_total > sell_total
|
43
|
-
order_difference = buy_total - sell_total
|
44
|
-
motivation = 'BUYING THE DIP'
|
45
|
-
indicator_hash[:color] = :red
|
46
|
-
if event_history.bullish_trend
|
47
|
-
motivation = 'FOMO' if event_history.bullish_trend
|
48
|
-
indicator_hash[:color] = :green
|
49
|
-
end
|
50
|
-
trend = "BUYS #{Cryptum.up_arrow} BY #{order_difference.to_i}"
|
51
|
-
indicator_hash[:status] = "B#{Cryptum.up_arrow}"
|
52
|
-
elsif buy_total < sell_total
|
53
|
-
order_difference = sell_total - buy_total
|
54
|
-
motivation = 'REKT'
|
55
|
-
indicator_hash[:color] = :red
|
56
|
-
if event_history.bullish_trend
|
57
|
-
motivation = 'TAKING PROFITS' if event_history.bullish_trend
|
58
|
-
indicator_hash[:color] = :green
|
59
|
-
end
|
60
|
-
trend = "SELLS #{Cryptum.up_arrow} BY #{order_difference.to_i}"
|
61
|
-
indicator_hash[:status] = "S#{Cryptum.up_arrow}"
|
62
|
-
else
|
63
|
-
# This Condition is Met When candle_buy_tot == candle_sell_tot
|
64
|
-
motivation = 'FLAT'
|
65
|
-
indicator_hash[:color] = :yellow
|
66
|
-
trend = 'BUYS == SELLS'
|
67
|
-
indicator_hash[:status] = "F#{Cryptum.up_arrow}"
|
68
|
-
end
|
69
|
-
indicator_hash[:ui] = "Market is #{motivation} | #{trend}"
|
70
|
-
|
71
|
-
indicator_status.market_trend = indicator_hash
|
72
|
-
rescue StandardError => e
|
73
|
-
raise e
|
74
|
-
end
|
75
|
-
|
76
|
-
# public_class_method def self.reset(opts = {})
|
77
|
-
# # IT IS ABSOLUTELY CRITICAL THIS METHOD IS AS FAST AS POSSIBLE
|
78
|
-
# # TO AVOID TICKER PRICE SYNCING ISSUES.
|
79
|
-
# event_history = opts[:event_history]
|
80
|
-
|
81
|
-
# # order_history = event_history.order_book[:order_history]
|
82
|
-
# # order_history_meta = event_history.order_book[:order_history_meta]
|
83
|
-
|
84
|
-
# # Only retain past 24 hours of
|
85
|
-
# # order history meta for bought, sold, and expired
|
86
|
-
# # keep open limit sell orders indefintely
|
87
|
-
# # before_twenty_four_hrs_ago = Time.now - 86_400
|
88
|
-
# # order_history_meta.delete_if do |ohm|
|
89
|
-
# # order_history.find do |oh|
|
90
|
-
# # next unless oh[:done_at]
|
91
|
-
|
92
|
-
# # Time.parse(oh[:done_at]) < before_twenty_four_hrs_ago && (
|
93
|
-
# # oh[:id] == ohm[:buy_order_id] ||
|
94
|
-
# # oh[:id] == ohm[:sell_order_id]
|
95
|
-
# # ) && (
|
96
|
-
# # ohm[:color].to_sym == :white ||
|
97
|
-
# # ohm[:color].to_sym == :green ||
|
98
|
-
# # ohm[:color].to_sym == :cyan ||
|
99
|
-
# # ohm[:color].to_sym == :red
|
100
|
-
# # )
|
101
|
-
# # end
|
102
|
-
# # end
|
103
|
-
|
104
|
-
# # Only keep order history meta for those
|
105
|
-
# # hashes that exist in the last order history
|
106
|
-
# # response
|
107
|
-
# # order_history_meta.keep_if do |ohm|
|
108
|
-
# # order_history.find do |oh|
|
109
|
-
# # (oh[:id] == ohm[:buy_order_id] || oh[:id] == ohm[:sell_order_id]) && (
|
110
|
-
# # ohm[:color].to_sym == :white ||
|
111
|
-
# # ohm[:color].to_sym == :green ||
|
112
|
-
# # ohm[:color].to_sym == :yellow
|
113
|
-
# # )
|
114
|
-
# # end
|
115
|
-
# # end
|
116
|
-
# # event_history.order_book[:order_history_meta] = order_history_meta
|
117
|
-
|
118
|
-
# # Reset Market Trend Counter
|
119
|
-
# event_history.order_book[:market_trend][:buy] = 0
|
120
|
-
# event_history.order_book[:market_trend][:sell] = 0
|
121
|
-
# event_history.order_book[:last_trend_reset] = Time.now.strftime(
|
122
|
-
# '%Y-%m-%d %H:%M:%S.%N%z'
|
123
|
-
# )
|
124
|
-
# rescue StandardError => e
|
125
|
-
# raise e
|
126
|
-
# end
|
127
|
-
|
128
|
-
# Display Usage for this Module
|
129
|
-
|
130
|
-
public_class_method def self.help
|
131
|
-
puts "USAGE:
|
132
|
-
order_trend_indicator_hash = #{self}.status
|
133
|
-
"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Cryptum
|
4
|
-
# This plugin is used to indicate if the
|
5
|
-
# Projected Profit Margin is greater than
|
6
|
-
# the Target Profit Margin Outlined in the
|
7
|
-
# Respective Bot Conf
|
8
|
-
|
9
|
-
module OrderBook
|
10
|
-
module ProfitMargin
|
11
|
-
# Supported Method Parameters::
|
12
|
-
# Cryptum::OrderBook::ProfitMargin.status(
|
13
|
-
# )
|
14
|
-
|
15
|
-
public_class_method def self.status(opts = {})
|
16
|
-
indicator_hash = {}
|
17
|
-
target_profit_margin_percent = opts[:target_profit_margin_percent]
|
18
|
-
total_invested = opts[:total_invested]
|
19
|
-
total_projected_return = opts[:total_projected_return]
|
20
|
-
indicator_status = opts[:indicator_status]
|
21
|
-
invested = opts[:invested]
|
22
|
-
|
23
|
-
ave_profit_margin_percent = 100 - ((total_invested / total_projected_return) * 100)
|
24
|
-
|
25
|
-
if ave_profit_margin_percent > target_profit_margin_percent
|
26
|
-
indicator_hash[:color] = :green
|
27
|
-
pm_op = '>'
|
28
|
-
elsif ave_profit_margin_percent < target_profit_margin_percent
|
29
|
-
indicator_hash[:color] = :red
|
30
|
-
pm_op = '<'
|
31
|
-
else
|
32
|
-
indicator_hash[:color] = :yellow
|
33
|
-
pm_op = '=='
|
34
|
-
end
|
35
|
-
|
36
|
-
profit_margin_status_out = "Profit Margin #{pm_op} TPM"
|
37
|
-
indicator_hash[:invested] = invested
|
38
|
-
indicator_hash[:status] = profit_margin_status_out
|
39
|
-
|
40
|
-
indicator_status.profit_margin = indicator_hash
|
41
|
-
rescue StandardError => e
|
42
|
-
raise e
|
43
|
-
end
|
44
|
-
|
45
|
-
# Display Usage for this Module
|
46
|
-
|
47
|
-
public_class_method def self.help
|
48
|
-
puts "USAGE:
|
49
|
-
weighted_ave_indicator_hash = #{self}.status(
|
50
|
-
)
|
51
|
-
"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/cryptum/order_book.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require 'logger'
|
5
|
-
|
6
|
-
module Cryptum
|
7
|
-
# This module is used to define the Order Book Data Structure
|
8
|
-
module OrderBook
|
9
|
-
require 'cryptum/order_book/generate'
|
10
|
-
require 'cryptum/order_book/indicator'
|
11
|
-
require 'cryptum/order_book/market_trend'
|
12
|
-
require 'cryptum/order_book/profit_margin'
|
13
|
-
|
14
|
-
# Display Usage for this Module
|
15
|
-
public_class_method def self.help
|
16
|
-
constants.sort
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,123 +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 Portfolio
|
8
|
-
module Balance
|
9
|
-
# Supported Method Parameters::
|
10
|
-
# Cryptum::Event::Update.summary(
|
11
|
-
# )
|
12
|
-
public_class_method def self.refresh(opts = {})
|
13
|
-
option_choice = opts[:option_choice]
|
14
|
-
env = opts[:env]
|
15
|
-
terminal_win = opts[:terminal_win]
|
16
|
-
event_history = opts[:event_history]
|
17
|
-
fiat_portfolio_file = opts[:fiat_portfolio_file]
|
18
|
-
|
19
|
-
this_product = event_history.order_book[:this_product]
|
20
|
-
crypto = this_product[:base_currency]
|
21
|
-
fiat = this_product[:quote_currency]
|
22
|
-
|
23
|
-
if event_history.first_event ||
|
24
|
-
event_history.reconnected ||
|
25
|
-
event_history.event_type == :received ||
|
26
|
-
event_history.event_type == :open ||
|
27
|
-
event_history.event_type == :done ||
|
28
|
-
event_history.event_type == :match ||
|
29
|
-
event_history.event_type == :change ||
|
30
|
-
event_history.event_type == :activate ||
|
31
|
-
terminal_win.key_press_event.key_u
|
32
|
-
|
33
|
-
etype = event_history.event_type
|
34
|
-
manual_refresh = terminal_win.key_press_event.key_u
|
35
|
-
etype = :manual_refresh if manual_refresh
|
36
|
-
etype = :first_event if event_history.first_event
|
37
|
-
etype = :reconnected if event_history.reconnected
|
38
|
-
event_history.event_type = etype
|
39
|
-
|
40
|
-
# Prevent Multiple Order Events from Occuring --- #
|
41
|
-
ocancel = event_history.order_canceled
|
42
|
-
osubmit = event_history.order_submitted
|
43
|
-
|
44
|
-
# POTENTIAL STOP IN ORDERS WHEN
|
45
|
-
# event_history.order_canceled = true
|
46
|
-
# Verify it's not due to EMA being red.
|
47
|
-
# ocancel = false if (etype == :open || etype == :done) &&
|
48
|
-
# osubmit == false &&
|
49
|
-
# !manual_refresh
|
50
|
-
|
51
|
-
ocancel = false if etype == :done &&
|
52
|
-
osubmit == true &&
|
53
|
-
!manual_refresh
|
54
|
-
|
55
|
-
event_history.order_canceled = ocancel
|
56
|
-
|
57
|
-
osubmit = false if etype == :done &&
|
58
|
-
!manual_refresh
|
59
|
-
|
60
|
-
event_history.order_submitted = osubmit
|
61
|
-
# ---------------------------------------------- #
|
62
|
-
|
63
|
-
enotes = event_history.event_notes
|
64
|
-
enotes = "{ \"event_type\": \"#{etype}\", \"cancel\": \"#{ocancel}\", \"submitted\": \"#{osubmit}\" }" if option_choice.proxy
|
65
|
-
event_history.event_notes = enotes
|
66
|
-
|
67
|
-
portfolio = Cryptum::API.get_portfolio(
|
68
|
-
option_choice: option_choice,
|
69
|
-
env: env,
|
70
|
-
crypto: crypto,
|
71
|
-
fiat: fiat,
|
72
|
-
fiat_portfolio_file: fiat_portfolio_file,
|
73
|
-
event_notes: event_history.event_notes
|
74
|
-
)
|
75
|
-
event_history.order_book[:portfolio] = portfolio unless portfolio.empty?
|
76
|
-
|
77
|
-
order_history = Cryptum::API.get_order_history(
|
78
|
-
option_choice: option_choice,
|
79
|
-
env: env
|
80
|
-
)
|
81
|
-
event_history.order_book[:order_history] = order_history unless order_history.empty?
|
82
|
-
|
83
|
-
fees = Cryptum::API.get_fees(
|
84
|
-
option_choice: option_choice,
|
85
|
-
env: env
|
86
|
-
)
|
87
|
-
event_history.order_book[:fees] = fees unless fees.empty?
|
88
|
-
|
89
|
-
terminal_win.key_press_event.key_u = false if manual_refresh
|
90
|
-
# First Event to Refresh No Longer Needed
|
91
|
-
event_history.first_event = false
|
92
|
-
# Reconnected Event to Refresh No Longer Needed
|
93
|
-
event_history.reconnected = false
|
94
|
-
end
|
95
|
-
|
96
|
-
# Always reload fiat portfolio as it's shared
|
97
|
-
# by all sessions (unless it's empty)
|
98
|
-
fpf = ''
|
99
|
-
fpf = File.read(fiat_portfolio_file) unless File.empty?(
|
100
|
-
fiat_portfolio_file
|
101
|
-
)
|
102
|
-
|
103
|
-
unless fpf.empty?
|
104
|
-
event_history.order_book[:fiat_portfolio] = JSON.parse(
|
105
|
-
fpf,
|
106
|
-
symbolize_names: true
|
107
|
-
)
|
108
|
-
end
|
109
|
-
|
110
|
-
event_history
|
111
|
-
rescue StandardError => e
|
112
|
-
raise e
|
113
|
-
end
|
114
|
-
|
115
|
-
# Display Usage for this Module
|
116
|
-
public_class_method def self.help
|
117
|
-
puts "USAGE:
|
118
|
-
event_history.order_book = #{self}.crypto()
|
119
|
-
"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
data/lib/cryptum/portfolio.rb
DELETED
@@ -1,15 +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 Portfolio
|
8
|
-
require 'cryptum/portfolio/balance'
|
9
|
-
|
10
|
-
# Display Usage for this Module
|
11
|
-
public_class_method def self.help
|
12
|
-
constants.sort
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/cryptum/ui/command.rb
DELETED
@@ -1,314 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
module Cryptum
|
6
|
-
module UI
|
7
|
-
# This plugin is used to Refresh the Cryptum Command Section UI
|
8
|
-
module Command
|
9
|
-
# Supported Method Parameters::
|
10
|
-
# Cryptum::UI::Command.refresh(
|
11
|
-
# action_command_status: 'required - Instatiated Cryptum::OrderBook::Probabilities Object'
|
12
|
-
# )
|
13
|
-
public_class_method def self.refresh(opts = {})
|
14
|
-
command_win = opts[:command_win]
|
15
|
-
key_press_event = opts[:key_press_event]
|
16
|
-
|
17
|
-
key_press_event = Cryptum::UI.detect_key_press_in_ui(
|
18
|
-
key_press_event: key_press_event,
|
19
|
-
ui_win: command_win
|
20
|
-
)
|
21
|
-
|
22
|
-
if key_press_event.key_c
|
23
|
-
key_c_color = :cyan
|
24
|
-
key_c_style = :reverse
|
25
|
-
else
|
26
|
-
key_c_color = :white
|
27
|
-
key_c_style = :bold
|
28
|
-
end
|
29
|
-
|
30
|
-
if key_press_event.key_g
|
31
|
-
key_g_color = :cyan
|
32
|
-
key_g_style = :reverse
|
33
|
-
else
|
34
|
-
key_g_color = :white
|
35
|
-
key_g_style = :bold
|
36
|
-
end
|
37
|
-
|
38
|
-
if key_press_event.key_r
|
39
|
-
key_r_color = :cyan
|
40
|
-
key_r_style = :reverse
|
41
|
-
else
|
42
|
-
key_r_color = :white
|
43
|
-
key_r_style = :bold
|
44
|
-
end
|
45
|
-
|
46
|
-
if key_press_event.key_u
|
47
|
-
key_u_color = :cyan
|
48
|
-
key_u_style = :reverse
|
49
|
-
else
|
50
|
-
key_u_color = :white
|
51
|
-
key_u_style = :bold
|
52
|
-
end
|
53
|
-
|
54
|
-
if key_press_event.key_w
|
55
|
-
key_w_color = :cyan
|
56
|
-
key_w_style = :reverse
|
57
|
-
else
|
58
|
-
key_w_color = :white
|
59
|
-
key_w_style = :bold
|
60
|
-
end
|
61
|
-
|
62
|
-
if key_press_event.key_x
|
63
|
-
key_x_color = :cyan
|
64
|
-
key_x_style = :reverse
|
65
|
-
else
|
66
|
-
key_x_color = :white
|
67
|
-
key_x_style = :bold
|
68
|
-
end
|
69
|
-
|
70
|
-
command_str_r2_arr = [
|
71
|
-
"* v#{Cryptum::VERSION} >>> ",
|
72
|
-
'[',
|
73
|
-
'C',
|
74
|
-
']ancel Open Orders',
|
75
|
-
' | ',
|
76
|
-
'[',
|
77
|
-
'G',
|
78
|
-
']TFO',
|
79
|
-
' | ',
|
80
|
-
'[',
|
81
|
-
'r',
|
82
|
-
']eload bot conf'
|
83
|
-
]
|
84
|
-
|
85
|
-
command_str_r3_arr = [
|
86
|
-
'[',
|
87
|
-
'u',
|
88
|
-
']pdate summary',
|
89
|
-
' | ',
|
90
|
-
'[',
|
91
|
-
'w',
|
92
|
-
']rite order book',
|
93
|
-
' | ',
|
94
|
-
'e[',
|
95
|
-
'x',
|
96
|
-
']it'
|
97
|
-
]
|
98
|
-
# ROW 1
|
99
|
-
out_line_no = 0
|
100
|
-
command_win.setpos(
|
101
|
-
out_line_no,
|
102
|
-
Cryptum::UI.col_center(str: command_str_r2_arr.join)
|
103
|
-
)
|
104
|
-
command_win.clrtoeol
|
105
|
-
|
106
|
-
# * v#{Cryptum::VERSION} >>>
|
107
|
-
Cryptum::UI.colorize(
|
108
|
-
ui_win: command_win,
|
109
|
-
color: :yellow,
|
110
|
-
style: :bold,
|
111
|
-
string: command_str_r2_arr.first
|
112
|
-
)
|
113
|
-
|
114
|
-
# [C]ancel Open Orders
|
115
|
-
Cryptum::UI.colorize(
|
116
|
-
ui_win: command_win,
|
117
|
-
color: key_c_color,
|
118
|
-
style: key_c_style,
|
119
|
-
string: command_str_r2_arr[1]
|
120
|
-
)
|
121
|
-
|
122
|
-
Cryptum::UI.colorize(
|
123
|
-
ui_win: command_win,
|
124
|
-
color: :yellow,
|
125
|
-
style: key_c_style,
|
126
|
-
string: command_str_r2_arr[2]
|
127
|
-
)
|
128
|
-
|
129
|
-
Cryptum::UI.colorize(
|
130
|
-
ui_win: command_win,
|
131
|
-
color: key_c_color,
|
132
|
-
style: key_c_style,
|
133
|
-
string: command_str_r2_arr[3]
|
134
|
-
)
|
135
|
-
|
136
|
-
# |
|
137
|
-
Cryptum::UI.colorize(
|
138
|
-
ui_win: command_win,
|
139
|
-
color: :white,
|
140
|
-
string: command_str_r2_arr[4]
|
141
|
-
)
|
142
|
-
|
143
|
-
# [G]TFO
|
144
|
-
Cryptum::UI.colorize(
|
145
|
-
ui_win: command_win,
|
146
|
-
color: key_g_color,
|
147
|
-
style: key_g_style,
|
148
|
-
string: command_str_r2_arr[5]
|
149
|
-
)
|
150
|
-
|
151
|
-
Cryptum::UI.colorize(
|
152
|
-
ui_win: command_win,
|
153
|
-
color: :yellow,
|
154
|
-
style: key_g_style,
|
155
|
-
string: command_str_r2_arr[6]
|
156
|
-
)
|
157
|
-
|
158
|
-
Cryptum::UI.colorize(
|
159
|
-
ui_win: command_win,
|
160
|
-
color: key_g_color,
|
161
|
-
style: key_g_style,
|
162
|
-
string: command_str_r2_arr[7]
|
163
|
-
)
|
164
|
-
|
165
|
-
# |
|
166
|
-
Cryptum::UI.colorize(
|
167
|
-
ui_win: command_win,
|
168
|
-
color: :white,
|
169
|
-
string: command_str_r2_arr[8]
|
170
|
-
)
|
171
|
-
|
172
|
-
# [r]eload bot conf
|
173
|
-
Cryptum::UI.colorize(
|
174
|
-
ui_win: command_win,
|
175
|
-
color: key_r_color,
|
176
|
-
style: key_r_style,
|
177
|
-
string: command_str_r2_arr[9]
|
178
|
-
)
|
179
|
-
|
180
|
-
Cryptum::UI.colorize(
|
181
|
-
ui_win: command_win,
|
182
|
-
color: :yellow,
|
183
|
-
style: key_r_style,
|
184
|
-
string: command_str_r2_arr[10]
|
185
|
-
)
|
186
|
-
|
187
|
-
Cryptum::UI.colorize(
|
188
|
-
ui_win: command_win,
|
189
|
-
color: key_r_color,
|
190
|
-
style: key_r_style,
|
191
|
-
string: command_str_r2_arr.last
|
192
|
-
)
|
193
|
-
|
194
|
-
# ROW 3
|
195
|
-
out_line_no += 1
|
196
|
-
command_win.setpos(
|
197
|
-
out_line_no,
|
198
|
-
Cryptum::UI.col_center(str: command_str_r3_arr.join)
|
199
|
-
)
|
200
|
-
command_win.clrtoeol
|
201
|
-
|
202
|
-
# [u]date summary
|
203
|
-
Cryptum::UI.colorize(
|
204
|
-
ui_win: command_win,
|
205
|
-
color: key_u_color,
|
206
|
-
style: key_u_style,
|
207
|
-
string: command_str_r3_arr.first
|
208
|
-
)
|
209
|
-
|
210
|
-
Cryptum::UI.colorize(
|
211
|
-
ui_win: command_win,
|
212
|
-
color: :yellow,
|
213
|
-
style: key_u_style,
|
214
|
-
string: command_str_r3_arr[1]
|
215
|
-
)
|
216
|
-
|
217
|
-
Cryptum::UI.colorize(
|
218
|
-
ui_win: command_win,
|
219
|
-
color: key_u_color,
|
220
|
-
style: key_u_style,
|
221
|
-
string: command_str_r3_arr[2]
|
222
|
-
)
|
223
|
-
|
224
|
-
# |
|
225
|
-
Cryptum::UI.colorize(
|
226
|
-
ui_win: command_win,
|
227
|
-
color: :white,
|
228
|
-
string: command_str_r3_arr[3]
|
229
|
-
)
|
230
|
-
|
231
|
-
# [w]rite order book
|
232
|
-
Cryptum::UI.colorize(
|
233
|
-
ui_win: command_win,
|
234
|
-
color: key_w_color,
|
235
|
-
style: key_w_style,
|
236
|
-
string: command_str_r3_arr[4]
|
237
|
-
)
|
238
|
-
|
239
|
-
Cryptum::UI.colorize(
|
240
|
-
ui_win: command_win,
|
241
|
-
color: :yellow,
|
242
|
-
style: key_w_style,
|
243
|
-
string: command_str_r3_arr[5]
|
244
|
-
)
|
245
|
-
|
246
|
-
Cryptum::UI.colorize(
|
247
|
-
ui_win: command_win,
|
248
|
-
color: key_w_color,
|
249
|
-
style: key_w_style,
|
250
|
-
string: command_str_r3_arr[6]
|
251
|
-
)
|
252
|
-
|
253
|
-
# |
|
254
|
-
Cryptum::UI.colorize(
|
255
|
-
ui_win: command_win,
|
256
|
-
color: :white,
|
257
|
-
string: command_str_r3_arr[7]
|
258
|
-
)
|
259
|
-
|
260
|
-
# e[x]it
|
261
|
-
Cryptum::UI.colorize(
|
262
|
-
ui_win: command_win,
|
263
|
-
color: key_x_color,
|
264
|
-
style: key_x_style,
|
265
|
-
string: command_str_r3_arr[8]
|
266
|
-
)
|
267
|
-
|
268
|
-
Cryptum::UI.colorize(
|
269
|
-
ui_win: command_win,
|
270
|
-
color: :yellow,
|
271
|
-
style: key_x_style,
|
272
|
-
string: command_str_r3_arr[9]
|
273
|
-
)
|
274
|
-
|
275
|
-
Cryptum::UI.colorize(
|
276
|
-
ui_win: command_win,
|
277
|
-
color: key_x_color,
|
278
|
-
style: key_x_style,
|
279
|
-
string: command_str_r3_arr.last
|
280
|
-
)
|
281
|
-
|
282
|
-
# ROW 4
|
283
|
-
out_line_no += 1
|
284
|
-
Cryptum::UI.line(
|
285
|
-
ui_win: command_win,
|
286
|
-
out_line_no: out_line_no
|
287
|
-
)
|
288
|
-
|
289
|
-
command_win.refresh
|
290
|
-
|
291
|
-
sleep 0.15 if key_press_event.key_g ||
|
292
|
-
key_press_event.key_r ||
|
293
|
-
key_press_event.key_u ||
|
294
|
-
key_press_event.key_w ||
|
295
|
-
key_press_event.key_x
|
296
|
-
rescue Interrupt
|
297
|
-
# Exit Gracefully if CTRL+C is Pressed During Session
|
298
|
-
Cryptum.exit_gracefully(which_self: self)
|
299
|
-
rescue StandardError => e
|
300
|
-
raise e
|
301
|
-
end
|
302
|
-
|
303
|
-
# Display Usage for this Module
|
304
|
-
|
305
|
-
public_class_method def self.help
|
306
|
-
puts "USAGE:
|
307
|
-
#{self}.refresh(
|
308
|
-
command_status: 'required - Instatiated Cryptum::OrderBook::Probabilities Object'
|
309
|
-
)
|
310
|
-
"
|
311
|
-
end
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Cryptum
|
4
|
-
module UI
|
5
|
-
# This Class is Used to Detect Key Press Events
|
6
|
-
class KeyPressEvent
|
7
|
-
attr_accessor :key_c,
|
8
|
-
:key_g,
|
9
|
-
:key_r,
|
10
|
-
:key_u,
|
11
|
-
:key_w,
|
12
|
-
:key_x,
|
13
|
-
:key_ansi,
|
14
|
-
:key_down_arrow,
|
15
|
-
:key_end,
|
16
|
-
:key_enter,
|
17
|
-
:key_esc,
|
18
|
-
:key_home,
|
19
|
-
:key_page_down,
|
20
|
-
:key_page_up,
|
21
|
-
:key_tab,
|
22
|
-
:key_up_arrow
|
23
|
-
|
24
|
-
rescue Interrupt
|
25
|
-
# Exit Gracefully if CTRL+C is Pressed During Session
|
26
|
-
Cryptum.exit_gracefully(which_self: self)
|
27
|
-
rescue StandardError => e
|
28
|
-
# Produce a Stacktrace for anything else
|
29
|
-
Curses.close_screen
|
30
|
-
raise e
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|