Sha256: 4b70e5523e4efc6315418d7fc45ec113c14d5dc5cdc77c13e5d6006c8a36b0c8

Contents?: true

Size: 1.6 KB

Versions: 146

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

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

  module OrderBook
    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 StandardError => e
        raise e
      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

146 entries across 146 versions & 1 rubygems

Version Path
cryptum-0.0.386 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.385 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.384 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.383 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.382 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.381 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.380 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.379 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.378 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.377 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.376 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.375 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.374 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.373 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.372 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.370 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.369 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.368 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.367 lib/cryptum/order_book/profit_margin.rb
cryptum-0.0.366 lib/cryptum/order_book/profit_margin.rb