Module: Cryptum

Defined in:
lib/cryptum.rb,
lib/cryptum/ui.rb,
lib/cryptum/api.rb,
lib/cryptum/log.rb,
lib/cryptum/event.rb,
lib/cryptum/matrix.rb,
lib/cryptum/option.rb,
lib/cryptum/open_ai.rb,
lib/cryptum/version.rb,
lib/cryptum/bot_conf.rb,
lib/cryptum/web_sock.rb,
lib/cryptum/event/buy.rb,
lib/cryptum/portfolio.rb,
lib/cryptum/ui/ticker.rb,
lib/cryptum/event/exit.rb,
lib/cryptum/event/gtfo.rb,
lib/cryptum/event/pane.rb,
lib/cryptum/event/sell.rb,
lib/cryptum/order_book.rb,
lib/cryptum/ui/command.rb,
lib/cryptum/event/parse.rb,
lib/cryptum/event/cancel.rb,
lib/cryptum/event/scroll.rb,
lib/cryptum/ui/portfolio.rb,
lib/cryptum/event/history.rb,
lib/cryptum/option/choice.rb,
lib/cryptum/ui/order_plan.rb,
lib/cryptum/event/bot_conf.rb,
lib/cryptum/ui/order_timer.rb,
lib/cryptum/event/key_press.rb,
lib/cryptum/ui/market_trend.rb,
lib/cryptum/event/order_book.rb,
lib/cryptum/ui/signal_engine.rb,
lib/cryptum/portfolio/balance.rb,
lib/cryptum/web_sock/coinbase.rb,
lib/cryptum/ui/key_press_event.rb,
lib/cryptum/ui/order_execution.rb,
lib/cryptum/ui/terminal_window.rb,
lib/cryptum/order_book/generate.rb,
lib/cryptum/order_book/indicator.rb,
lib/cryptum/ui/order_plan_details.rb,
lib/cryptum/web_sock/event_machine.rb,
lib/cryptum/order_book/market_trend.rb,
lib/cryptum/order_book/profit_margin.rb,
lib/cryptum/ui/order_execute_details.rb

Overview

Root-Level Namespace for cryptum

Defined Under Namespace

Modules: API, BotConf, Event, Log, Matrix, OpenAI, Option, OrderBook, Portfolio, UI, WebSock

Constant Summary collapse

VERSION =
'0.0.361'

Class Method Summary collapse

Class Method Details

.beautify_large_number(opts = {}) ⇒ Object

Add Commas to Large Numbers to Make it Easier to Read



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/cryptum.rb', line 63

public_class_method def self.beautify_large_number(opts = {})
  value = opts[:value].to_s

  split_str_num = value.split('.')
  whole_num = split_str_num.first
  fraction = 0
  fraction = split_str_num.last if split_str_num.length > 1

  is_negative = false
  is_negative = true if whole_num.chars.first == '-'
  whole_num = whole_num[1..] if is_negative
  beautify_whole = whole_num.reverse.scan(/.{1,3}/).join(',').reverse
  beautify_num = "#{beautify_whole}.#{fraction}" unless is_negative
  beautify_num = "-#{beautify_whole}.#{fraction}" if is_negative

  beautify_num
rescue Interrupt
  # Exit Gracefully if CTRL+C is Pressed During Session
  Cryptum.exit_gracefully(which_self: self)
rescue StandardError => e
  # Produce a Stacktrace for anything else
  Curses.close_screen
  raise e
end

.binObject



26
27
28
# File 'lib/cryptum.rb', line 26

public_class_method def self.bin
  File.join root, 'bin'
end

.down_arrowObject



54
55
56
# File 'lib/cryptum.rb', line 54

public_class_method def self.down_arrow
  "\u2193"
end

.etcObject



30
31
32
# File 'lib/cryptum.rb', line 30

public_class_method def self.etc
  File.join root, 'etc'
end

.exit_gracefully(opts = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cryptum.rb', line 88

public_class_method def self.exit_gracefully(opts = {})
  which_self = opts[:which_self]
  event_history = opts[:event_history]
  # option_choice = opts[:option_choice]
  # env = opts[:env]

  # Clear out candle data to ensure
  # Cryptum Statistics Only Apply to
  # Live Sessions
  if event_history
    File.write(
      order_book_file,
      JSON.pretty_generate(event_history.order_book)
    )
  end

  Curses.close_screen
  puts "Interrupt detected in #{which_self}...goodbye."

  exit 0
rescue NameError
  puts "\nInterrupt detected in #{which_self}...goodbye."

  exit 0
rescue StandardError => e
  # Produce a Stacktrace for anything else
  raise e
end

.flat_arrowObject



58
59
60
# File 'lib/cryptum.rb', line 58

public_class_method def self.flat_arrow
  '_'
end

.helpObject



117
118
119
# File 'lib/cryptum.rb', line 117

public_class_method def self.help
  constants.sort
end

.libObject



34
35
36
# File 'lib/cryptum.rb', line 34

public_class_method def self.lib
  File.join root, 'lib'
end

.open_symbolObject



46
47
48
# File 'lib/cryptum.rb', line 46

public_class_method def self.open_symbol
  "\u00f8"
end

.order_bookObject



38
39
40
# File 'lib/cryptum.rb', line 38

public_class_method def self.order_book
  File.join root, 'order_book'
end

.rootObject



42
43
44
# File 'lib/cryptum.rb', line 42

public_class_method def self.root
  File.dirname __dir__
end

.up_arrowObject



50
51
52
# File 'lib/cryptum.rb', line 50

public_class_method def self.up_arrow
  "\u2191"
end