Module: Cryptum::Option
- Defined in:
- lib/cryptum/option.rb,
lib/cryptum/option/choice.rb
Overview
This plugin is used to Cancel Open Limit Orders
Defined Under Namespace
Classes: Choice
Class Method Summary collapse
-
.get_env(opts = {}) ⇒ Object
Initialize Cryptum Session Environment.
-
.help ⇒ Object
Display a List of Every UI Module.
-
.input_validation(opts = {}) ⇒ Object
Validate Options for cryptum Driver.
-
.list_products_and_exit(opts = {}) ⇒ Object
List Supported Cryptum Products and Exit.
-
.parser(opts = {}) ⇒ Object
Options for cryptum Driver.
Class Method Details
.get_env(opts = {}) ⇒ Object
Initialize Cryptum Session Environment
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/cryptum/option.rb', line 137 public_class_method def self.get_env(opts = {}) option_choice = opts[:option_choice] yaml_conf_file = "#{option_choice.repo_root}/etc/coinbase_pro.yaml" yaml_conf = YAML.load_file( yaml_conf_file, symbolize_names: true ) env = yaml_conf[:prod] env[:env] = :prod env = yaml_conf[:sandbox] if option_choice.sandbox env[:env] = :sandbox if option_choice.sandbox env rescue StandardError => e raise e end |
.help ⇒ Object
Display a List of Every UI Module
157 158 159 |
# File 'lib/cryptum/option.rb', line 157 public_class_method def self.help constants.sort end |
.input_validation(opts = {}) ⇒ Object
Validate Options for cryptum Driver
76 77 78 79 80 81 82 83 84 85 86 87 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 |
# File 'lib/cryptum/option.rb', line 76 public_class_method def self.input_validation(opts = {}) option_choice = opts[:option_choice] # Conditions to display cryptum usage if option_choice.symbol.nil? && option_choice.list_products.nil? usage = true reason = :symbol end option_choice.repo_root = "#{Dir.home}/cryptum" if option_choice.repo_root.nil? unless Dir.exist?(option_choice.repo_root) usage = true reason = :repo_root end option_choice.market_trend_reset = 60 if option_choice.market_trend_reset.to_i.zero? unless option_choice.market_trend_reset.to_f.positive? usage = true reason = :market_trend_reset end if usage case reason when :symbol puts "ERROR: --symbol Flag is Required.\n\n" when :repo_root puts "ERROR: #{option_choice.repo_root} does not exist.\n\n" when :market_trend_reset puts "ERROR: #{option_choice.market_trend_reset} Must be a positive floating point number.\n\n" end puts `#{option_choice.driver_name} --help` exit 1 end rescue StandardError => e raise e end |
.list_products_and_exit(opts = {}) ⇒ Object
List Supported Cryptum Products and Exit
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/cryptum/option.rb', line 116 public_class_method def self.list_products_and_exit(opts = {}) option_choice = opts[:option_choice] env = opts[:env] puts `#{option_choice.driver_name} --help` puts "\n#{option_choice.driver_name} Supports the Following Products:" products = Cryptum::API.get_products( option_choice: option_choice, env: env ) products.map do |product| puts product[:id].downcase end exit 0 rescue StandardError => e raise e end |
.parser(opts = {}) ⇒ Object
Options for cryptum Driver
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cryptum/option.rb', line 13 public_class_method def self.parser(opts = {}) option_choice = Option::Choice.new option_choice.driver_name = opts[:driver_name] OptionParser.new do || . = "USAGE: #{option_choice.driver_name} [opts]" .on( '-sSYMBOL', '--symbol=SYMBOL', '<Required - Crypto Symbol.(e.g. btc-usd, eth-usd, etc.)' ) { |s| option_choice.symbol = s.to_s.gsub('-', '_').downcase.to_sym } .on( '-A', '--[no-]autotrade', '<Optional - Automatically Buy and Sell Crypto>' ) { |a| option_choice.autotrade = a } .on( '-l', '--[no-]list-products', '<Optional - List Supported Crypto Currency Products and Exit>' ) { |l| option_choice.list_products = l } .on( '-pPROXY', '--proxy=PROXY', '<Optional - HTTP Proxy e.g. "http://127.0.0.1:8080">' ) { |p| option_choice.proxy = p } .on( '-rPATH', '--repo-root=PATH', '<Optional - Directory of Cloned Repo (Defaults to ~/cryptum)>' ) { |r| option_choice.repo_root = r } .on( '-S', '--[no-]sandbox', '<Optional - Use Coinbase Sandbox Environment for Testing Ideas>' ) { |n| option_choice.sandbox = n } .on( '-tSECONDS', '--time-between-orders=SECONDS', '<Optional - Seconds Between Market Trend Reset (Default 60)>' ) { |t| option_choice.market_trend_reset = t } end.parse! input_validation(option_choice: option_choice) option_choice rescue OptionParser::InvalidOption => e # Print Usage if unsupported flags are passed puts "ERROR: #{e.}\n\n" puts `#{option_choice.driver_name} --help` exit 1 rescue StandardError => e raise e end |