Sha256: a94213e84bdd3d4b9c0643cb865342c93d3bb9583586776719d2c175c41844dc

Contents?: true

Size: 1.7 KB

Versions: 69

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

module Cryptum
  # Cryptum::OrderBook Namespace
  module OrderBook
    # This module is used to indicate if the
    # Projected Profit Margin is greater than
    # the Target Profit Margin Outlined in the
    # Respective Bot Conf
    module ProfitMargin
      # Supported Method Parameters::
      # Cryptum::OrderBook::ProfitMargin.status(
      # )

      public_class_method def self.status(opts = {})
        indicator_hash = {}
        target_profit_margin_percent = opts[:target_profit_margin_percent]
        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 > target_profit_margin_percent
          indicator_hash[:color] = :green
          pm_op = '>'
        elsif ave_profit_margin_percent < target_profit_margin_percent
          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 Interrupt, StandardError => e
        Cryptum::Log.append(level: :error, msg: e, which_self: self)
      end

      # Display Usage for this Module

      public_class_method def self.help
        puts "USAGE:
         weighted_ave_indicator_hash = #{self}.status(
         )
        "
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
cryptum-0.0.466 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.465 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.464 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.463 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.462 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.461 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.460 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.459 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.458 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.457 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.456 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.455 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.454 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.453 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.452 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.451 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.450 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.449 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.448 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.447 lib/cryptum/order_book/profit_margin.rb