Module: Coinbot::OrderBook::ProfitMargin
- Defined in:
- lib/coinbot/order_book/profit_margin.rb
Class Method Summary collapse
-
.help ⇒ Object
Display Usage for this Module.
-
.status(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::OrderBook::ProfitMargin.status( ).
Class Method Details
.help ⇒ Object
Display Usage for this Module
47 48 49 50 51 52 |
# File 'lib/coinbot/order_book/profit_margin.rb', line 47 public_class_method def self.help puts "USAGE: weighted_ave_indicator_hash = #{self}.status( ) " end |
.status(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::OrderBook::ProfitMargin.status( )
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 |
# File 'lib/coinbot/order_book/profit_margin.rb', line 15 public_class_method def self.status(opts = {}) indicator_hash = {} tpm = opts[:tpm].to_f total_invested = opts[:total_invested] total_projected_return = opts[:total_projected_return] indicator_status = opts[:indicator_status] invested = opts[:invested] ave_profit_margin_percent = 100 - ((total_invested / total_projected_return) * 100) if ave_profit_margin_percent > tpm.to_f indicator_hash[:color] = :green pm_op = '>' elsif ave_profit_margin_percent < tpm.to_f indicator_hash[:color] = :red pm_op = '<' else indicator_hash[:color] = :yellow pm_op = '==' end profit_margin_status_out = "Profit Margin #{pm_op} TPM" indicator_hash[:invested] = invested indicator_hash[:status] = profit_margin_status_out indicator_status.profit_margin = indicator_hash rescue StandardError => e raise e end |