cryptum 0.0.388 → 0.0.392

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a96ddf613cdc94e4883151dd4f6a79e409a0c3fe6b39d8ffc7b8518d3e29215c
4
- data.tar.gz: b899801924f9c55990902dbd9977a1b42876d4bc241b6736532d285bc9f078ee
3
+ metadata.gz: 110c196928530da1a4052a8e6040d4d8059b1aa1468a7da7801e6b9be24e0d51
4
+ data.tar.gz: 22d185e05a7fc7a365441c3147b481e9cf5aa097c1d857f459ac5302eb3f7a61
5
5
  SHA512:
6
- metadata.gz: 7809bad411a8b2ff88376b9dde60351a922f8d1668531a1703b3bd7889b6117767e9beafc501b4bd90ba36ba2f5a959c43578f2b253e4a7a3eeb7df9e9c60b61
7
- data.tar.gz: e33718bd1a1a52e925e7930d66ce0bfd19ada6510a06a143ef142fe641b2430170a953994a9cf716f35c4bacdbafcaeef34b82126e0eedff1c9fdd398441f64f
6
+ metadata.gz: 4b67141f9c82d817e68c6ff494af9a40b037114347ac8c26ba8bab339042bd94c0e0372c471636763603ce30ec39a89f57dbe5694e9b374b9d36b9612772d5c9
7
+ data.tar.gz: 19c5f92b35ca7d11b1fa693aebcc52e6b4dac788ead664b27bf74239f765005b9870229026debde3e900edd53214b91f5be88635ca8e1d4c526eb2cd86ca587f
data/.rubocop_todo.yml CHANGED
@@ -1,21 +1,11 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-04-03 17:23:47 UTC using RuboCop version 1.49.0.
3
+ # on 2023-04-03 22:26:52 UTC using RuboCop version 1.49.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- Lint/UnreachableCode:
11
- Exclude:
12
- - 'bin/cryptum'
13
-
14
- # Offense count: 1
15
- Style/ClassVars:
16
- Exclude:
17
- - 'bin/cryptum'
18
-
19
9
  # Offense count: 5
20
10
  # This cop supports safe autocorrection (--autocorrect).
21
11
  # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
@@ -30,9 +20,3 @@ Style/ConditionalAssignment:
30
20
  # Configuration parameters: AllowedConstants.
31
21
  Style/Documentation:
32
22
  Enabled: false
33
-
34
- # Offense count: 1
35
- # This cop supports safe autocorrection (--autocorrect).
36
- Style/RedundantSelf:
37
- Exclude:
38
- - 'lib/cryptum/api.rb'
data/README.md CHANGED
@@ -108,9 +108,9 @@ If you choose a lower value than the default, the target profit margin's (i.e. T
108
108
 
109
109
  Another option (particularly useful with smaller balances) is bumping the market trend reset to 604800 (i.e. 1 week) which will immediately increase the TPM %'s. The downside to this approach is trading volume is reduced, resulting in higher maker & taker fee tiers (i.e. higher cost / trade).
110
110
 
111
- From an logging perspective, they can be monitored via:
111
+ From a monitoring perspective, logs can be monitored via:
112
112
  ```
113
- tail -f /tmp/cryptum.log
113
+ $ tail -f /tmp/cryptum.log
114
114
  ```
115
115
 
116
116
  ### **Contributing** ###
data/bin/cryptum CHANGED
@@ -19,40 +19,22 @@ if option_choice.list_products
19
19
  )
20
20
  end
21
21
 
22
- # Instantiate Our Status Indicators & History Objects
23
- indicator_status = Cryptum::OrderBook::Indicator.new
24
-
25
- # Initialize Curses UI
26
- terminal_win = Cryptum::UI.init
27
-
28
22
  # Generate an Order Book for Session Tracking
29
- # Load previous order_book_justification from
30
- # Order Book File (if it exists)
31
23
  event_history = Cryptum::OrderBook::Generate.new(
32
24
  option_choice: option_choice,
33
25
  env: env
34
26
  )
35
- terminal_win.key_press_event.key_w = true if option_choice.reset_session_countdown
36
27
 
37
- # Automatically Create Bot Confs if they don't
38
- # Exist and Initialize Automated Trading Parameters
39
- bot_conf = Cryptum::BotConf.read(
40
- option_choice: option_choice,
41
- event_history: event_history
42
- )
28
+ # Initialize Curses UI
29
+ terminal_win = Cryptum::UI.init(event_history: event_history)
30
+ terminal_win.key_press_event.key_w = true if option_choice.reset_session_countdown
43
31
 
44
32
  # Connect to WebSocket
45
- # Trigger Events as Event Data
46
- # Generated via Coinbase Pro
47
- # Web Socket HTTP Responses
48
- # Refresh UI with Event Data
49
- # Update "Status Indicators"
50
- # Leverage "Status Indicators" to Initiate Actions
33
+ # Refresh UI and Trigger Events as Messages via Web Socket are Received.
34
+ # Leverage Indicators to Initiate Actions
51
35
  Cryptum::WebSock::EventMachine.run(
52
36
  option_choice: option_choice,
53
37
  env: env,
54
38
  terminal_win: terminal_win,
55
- event_history: event_history,
56
- indicator_status: indicator_status,
57
- bot_conf: bot_conf
39
+ event_history: event_history
58
40
  )
data/lib/cryptum/api.rb CHANGED
@@ -13,7 +13,7 @@ module Cryptum
13
13
  require 'cryptum/api/signature'
14
14
 
15
15
  public_class_method def self.help
16
- puts self.constants
16
+ puts constants.sort
17
17
  end
18
18
  end
19
19
  end
data/lib/cryptum/event.rb CHANGED
@@ -19,7 +19,7 @@ module Cryptum
19
19
  # Display Usage for this Module
20
20
 
21
21
  public_class_method def self.help
22
- constants.sort
22
+ puts constants.sort
23
23
  end
24
24
  end
25
25
  end
data/lib/cryptum/log.rb CHANGED
@@ -7,27 +7,31 @@ module Cryptum
7
7
  # Cryptum::Log.create(
8
8
  # )
9
9
  public_class_method def self.append(opts = {})
10
+ level = opts[:level].to_s.downcase.to_sym
11
+ msg = opts[:msg]
12
+ which_self = opts[:which_self].to_s
13
+ event_history = opts[:event_history]
14
+
15
+ # Always append to log file
16
+ log_file = File.open('/tmp/cryptum.log', 'a')
17
+
10
18
  # Leave 10 "old" log files where
11
19
  # each file is ~ 1,024,000 bytes
12
- log_file = File.open('/tmp/cryptum.log', 'a')
13
20
  logger = Logger.new(
14
21
  log_file,
15
22
  10,
16
23
  1_024_000
17
24
  )
18
- level = opts[:level].to_s.downcase.to_sym
19
- msg = opts[:msg]
20
- which_self = opts[:which_self].to_s
21
- event_history = opts[:event_history]
22
25
 
26
+ # Only attempt to exit gracefully if level == :error
23
27
  exit_gracefully = false
24
28
 
25
29
  case level
26
30
  when :debug
27
31
  logger.level = Logger::DEBUG
28
32
  when :error
29
- logger.level = Logger::ERROR
30
33
  exit_gracefully = true
34
+ logger.level = Logger::ERROR
31
35
  when :fatal
32
36
  # This is reserved for:
33
37
  # Cryptum::UI::Exit
@@ -46,12 +50,16 @@ module Cryptum
46
50
  end
47
51
 
48
52
  logger.datetime_format = '%Y-%m-%d %H:%M:%S.%N'
53
+ log_event = ''
54
+ log_event = event_history.order_book[:path] if event_history.respond_to?('order_book')
49
55
  if msg.instance_of?(Interrupt)
50
- logger.add(logger.level, 'CTRL+C Detected...Ended Session.', which_self)
56
+ log_event += ' => CTRL+C Detected...Exiting Session.'
51
57
  else
52
- logger.add(logger.level, msg, which_self)
58
+ log_event += " => #{msg}"
53
59
  end
54
60
 
61
+ logger.add(logger.level, log_event, which_self)
62
+
55
63
  Cryptum::UI::Exit.gracefully(event_history: event_history) if exit_gracefully
56
64
  rescue Interrupt, StandardError => e
57
65
  raise e
@@ -36,7 +36,9 @@ module Cryptum
36
36
 
37
37
  # Display Usage for this Module
38
38
  public_class_method def self.help
39
- constants.sort
39
+ puts "USAGE:
40
+ #{self}.get(option_choice: option_choice)
41
+ "
40
42
  end
41
43
  end
42
44
  end
@@ -78,7 +78,9 @@ module Cryptum
78
78
 
79
79
  # Display Usage for this Module
80
80
  public_class_method def self.help
81
- constants.sort
81
+ puts "USAGE:
82
+ #{self}.check(option_choice: option_choice)
83
+ "
82
84
  end
83
85
  end
84
86
  end
@@ -76,7 +76,9 @@ module Cryptum
76
76
 
77
77
  # Display Usage for this Module
78
78
  public_class_method def self.help
79
- constants.sort
79
+ puts "USAGE:
80
+ #{self}.get(option_choice: option_choice)
81
+ "
80
82
  end
81
83
  end
82
84
  end
@@ -10,7 +10,7 @@ module Cryptum
10
10
 
11
11
  # Display Usage for this Module
12
12
  public_class_method def self.help
13
- constants.sort
13
+ puts constants.sort
14
14
  end
15
15
  end
16
16
  end
@@ -7,7 +7,7 @@ module Cryptum
7
7
 
8
8
  # Display Usage for this Module
9
9
  public_class_method def self.help
10
- constants.sort
10
+ puts constants.sort
11
11
  end
12
12
  end
13
13
  end
@@ -8,6 +8,9 @@ module Cryptum
8
8
  event_history = opts[:event_history]
9
9
 
10
10
  Curses.close_screen
11
+ msg = event_history.order_book[:path] if event_history.respond_to?('order_book')
12
+ msg += ' => Session Gracefully Terminated.'
13
+ Cryptum::Log.append(level: :info, msg: msg, which_self: self)
11
14
 
12
15
  exit 0
13
16
  rescue Interrupt, StandardError => e
@@ -27,7 +30,7 @@ module Cryptum
27
30
  # Display a List of Every UI Module
28
31
 
29
32
  public_class_method def self.help
30
- constants.sort
33
+ puts constants.sort
31
34
  end
32
35
  end
33
36
  end
@@ -29,7 +29,7 @@ module Cryptum
29
29
  # Display a List of Every UI Module
30
30
 
31
31
  public_class_method def self.help
32
- constants.sort
32
+ puts constants.sort
33
33
  end
34
34
  end
35
35
  end
@@ -14,7 +14,7 @@ module Cryptum
14
14
  # Display a List of Every UI Module
15
15
 
16
16
  public_class_method def self.help
17
- constants.sort
17
+ puts constants.sort
18
18
  end
19
19
  end
20
20
  end
data/lib/cryptum/ui.rb CHANGED
@@ -16,7 +16,12 @@ module Cryptum
16
16
  require 'cryptum/ui/ticker'
17
17
 
18
18
  # Initialize the UI
19
- public_class_method def self.init
19
+ public_class_method def self.init(opts = {})
20
+ event_history = opts[:event_history]
21
+ msg = event_history.order_book[:path] if event_history.respond_to?('order_book')
22
+ msg += ' => Session Started.'
23
+ Cryptum::Log.append(level: :info, msg: msg, which_self: self)
24
+
20
25
  # Initialize curses Screen
21
26
  Curses.init_screen
22
27
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.388'
4
+ VERSION = '0.0.392'
5
5
  end
@@ -15,8 +15,16 @@ module Cryptum
15
15
  option_choice = opts[:option_choice]
16
16
  terminal_win = opts[:terminal_win]
17
17
  event_history = opts[:event_history]
18
- indicator_status = opts[:indicator_status]
19
- bot_conf = opts[:bot_conf]
18
+
19
+ # Instantiate Our Status Indicator Objects
20
+ indicator_status = Cryptum::OrderBook::Indicator.new
21
+
22
+ # Automatically Create Bot Confs if they don't
23
+ # Exist and Initialize Automated Trading Parameters
24
+ bot_conf = Cryptum::BotConf.read(
25
+ option_choice: option_choice,
26
+ event_history: event_history
27
+ )
20
28
 
21
29
  max_conn_attempts = 30
22
30
  conn_attempt = 0
@@ -49,12 +57,7 @@ module Cryptum
49
57
  end
50
58
 
51
59
  ws.on :message do |event|
52
- # TODO: The Speed of the UI is dictated by the
53
- # Frequency of WebSocket Messages Coming Through.
54
- # Explore another way to decouple required events
55
- # (such as keypresses) from only being triggered
56
- # when messages come through.
57
-
60
+ # Convert Web Socket Response JSON Message to Hash
58
61
  event_history.event = JSON.parse(
59
62
  event.data,
60
63
  symbolize_names: true
@@ -73,8 +76,7 @@ module Cryptum
73
76
  # Detect Key Press Events
74
77
  Cryptum::Event::KeyPress.detect(terminal_win: terminal_win)
75
78
 
76
- # Cancel ALL Open Orders when
77
- # C is pressed
79
+ # Cancel ALL Open Orders when C is pressed
78
80
  if terminal_win.key_press_event.key_c
79
81
  Cryptum::Event::Cancel.open_orders(
80
82
  terminal_win: terminal_win,
@@ -83,8 +85,7 @@ module Cryptum
83
85
  )
84
86
  end
85
87
 
86
- # Get the F* Out (GTFO) when
87
- # G is pressed
88
+ # Get the F* Out (GTFO) when G is pressed
88
89
  if terminal_win.key_press_event.key_g
89
90
  event_history = Cryptum::Event::GTFO.now(
90
91
  terminal_win: terminal_win,
@@ -104,8 +105,7 @@ module Cryptum
104
105
  )
105
106
  end
106
107
 
107
- # Only Write Order Book to File when
108
- # W is Pressed
108
+ # Write Order Book to File when W is Pressed
109
109
  if terminal_win.key_press_event.key_w
110
110
  Cryptum::Event::OrderBook.write(
111
111
  terminal_win: terminal_win,
@@ -114,7 +114,11 @@ module Cryptum
114
114
  end
115
115
 
116
116
  # Exit if x is Pressed
117
- Cryptum::Event::Exit.gracefully(event_history: event_history) if terminal_win.key_press_event.key_x
117
+ if terminal_win.key_press_event.key_x
118
+ Cryptum::Event::Exit.gracefully(
119
+ event_history: event_history
120
+ )
121
+ end
118
122
 
119
123
  # TAB through Order Plan / Order Execution Window Panes
120
124
  if terminal_win.key_press_event.key_tab
@@ -182,9 +186,9 @@ module Cryptum
182
186
  end
183
187
 
184
188
  ws.on :close do
185
- # raise when remote peer forces reset...this
186
- # is then caught below and reattempts to connect
187
- # until conn_attempt > max_conn_attempts
189
+ # raise Errno::ECONNRESET when remote peer forces reset...
190
+ # This will be caught in the rescue block below which reattempts
191
+ # to connect until conn_attempt > max_conn_attempts
188
192
  raise Errno::ECONNRESET
189
193
  end
190
194
 
@@ -211,7 +215,7 @@ module Cryptum
211
215
 
212
216
  EM.add_periodic_timer(option_choice.market_trend_reset) do
213
217
  # NOTE: To ensure the integrity of event_history is maintained,
214
- # changes to its contenta _MUST_ stay in thos block.
218
+ # changes to its contents _MUST_ stay in this block.
215
219
  event_history.order_book[:market_trend][:buy] = 0
216
220
  event_history.order_book[:market_trend][:sell] = 0
217
221
  event_history.order_book[:last_trend_reset] = Time.now.strftime(
@@ -10,7 +10,7 @@ module Cryptum
10
10
  # Display Usage for this Module
11
11
 
12
12
  public_class_method def self.help
13
- constants.sort
13
+ puts constants.sort
14
14
  end
15
15
  end
16
16
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Cryptum::Option::Environment do
6
6
  it 'should return data for help method' do
7
- help_response = Cryptum::Option::Environment.help
8
- expect(help_response).not_to be_nil
7
+ help_response = Cryptum::Option::Environment
8
+ expect(help_response).to respond_to :help
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Cryptum::Option::InputValidation do
6
6
  it 'should return data for help method' do
7
- help_response = Cryptum::Option::InputValidation.help
8
- expect(help_response).not_to be_nil
7
+ help_response = Cryptum::Option::InputValidation
8
+ expect(help_response).to respond_to :help
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Cryptum::Option::Parser do
6
6
  it 'should return data for help method' do
7
- help_response = Cryptum::Option::Parser.help
8
- expect(help_response).not_to be_nil
7
+ help_response = Cryptum::Option::Parser
8
+ expect(help_response).to respond_to :help
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Cryptum do
6
6
  it 'should return data for help method' do
7
- help_response = Cryptum.help
7
+ help_response = Cryptum
8
8
  expect(help_response).not_to be_nil
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.388
4
+ version: 0.0.392
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.