Module: Cryptum::OrderBook

Defined in:
lib/cryptum/order_book.rb,
lib/cryptum/order_book/generate.rb,
lib/cryptum/order_book/indicator.rb,
lib/cryptum/order_book/market_trend.rb,
lib/cryptum/order_book/weighted_avg.rb,
lib/cryptum/order_book/profit_margin.rb

Overview

This plugin is used to indicate if the Projected Profit Margin is greater than the Target Profit Margin Outlined in the Respective Bot Conf

Defined Under Namespace

Modules: Generate, MarketTrend, ProfitMargin, WeightedAvg Classes: Indicator

Class Method Summary collapse

Class Method Details

.analyze(opts = {}) ⇒ Object

Supported Method Parameters

Cryptum::OrderBook.analyze(

order_book_file: 'required - path to order book file'

)



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/cryptum/order_book.rb', line 119

public_class_method def self.analyze(opts = {})
  order_book_file = opts[:order_book_file]
  option_choice = opts[:option_choice]
  # TODO: Handle File that exists
  # w/ Zero size...N number of
  # attempts?  Timeout may be better.
  order_book = JSON.parse(
    File.read(order_book_file),
    symbolize_names: true
  )

  order_book[:option_choice] = option_choice

  bot_conf = Cryptum::BotConf.read(option_choice: option_choice)
  order_book[:bot_conf] = bot_conf

  env = Cryptum::Option.get_env(option_choice: option_choice)
  order_book[:env] = env

  order_book
rescue JSON::ParserError => e
  File.open('/tmp/cryptum-errors.txt', 'a') do |f|
    f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
    f.puts "Module: #{self}"
    f.puts "#{e}\n\n\n"
  end

  retry
rescue StandardError => e
  raise e
end

.base_currency_overridesObject

Supported Method Parameters

base_currency_overrides = Cryptum::OrderBook.base_currency_overrides



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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/order_book.rb', line 53

public_class_method def self.base_currency_overrides
  %i[
    1inch
    aave
    ada
    amp
    ankr
    bal
    band
    bat
    bnt
    bond
    cgld
    chz
    clv
    comp
    crv
    ctsi
    dot
    enj
    farm
    fet
    fil
    forth
    grt
    gtc
    icp
    keep
    lpt
    lrc
    mana
    mask
    matic
    mir
    mkr
    mln
    nkn
    nmr
    nu
    ogn
    poly
    qnt
    ren
    rly
    shib
    skl
    snx
    sol
    storj
    sushi
    trb
    tribe
    uma
    uni
    wbtc
    yfi
    zrx
  ]
rescue StandardError => e
  raise e
end

.get_populated_indicators(opts = {}) ⇒ Object

Supported Method Parameters

Cryptum::OrderBook.get_populated_indicators(

indicator_status: 'required - indicator_status object instantiated via Cryptum::OrderBook::Indicators'

)



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
# File 'lib/cryptum/order_book.rb', line 18

public_class_method def self.get_populated_indicators(opts = {})
  indicator_status = opts[:indicator_status]

  indicator_type_hash = {}
  indicator_type_hash[:trend_indicator_arr] = []
  trend_indicator_arr = indicator_type_hash[:trend_indicator_arr]

  indicator_type_hash[:health_indicator_arr] = []
  health_indicator_arr = indicator_type_hash[:health_indicator_arr]

  if indicator_status.order_trend
    trend_indicator_arr.push(
      indicator_status.order_trend
    )
  end

  if indicator_status.weighted_avg
    health_indicator_arr.push(
      indicator_status.weighted_avg
    )
  end

  if indicator_status.profit_margin
    health_indicator_arr.push(
      indicator_status.profit_margin
    )
  end

  indicator_type_hash
rescue StandardError => e
  raise e
end

.helpObject

Display Usage for this Module



152
153
154
# File 'lib/cryptum/order_book.rb', line 152

public_class_method def self.help
  constants.sort
end