Class: Bitbot::Trader::Providers::MtGox::ValueWithCurrencyCoercer

Inherits:
Virtus::Attribute
  • Object
show all
Defined in:
lib/bitbot/trader/providers/mt_gox/value_with_currency_coercer.rb

Overview

Helps managing values with currencies

Class Method Summary collapse

Class Method Details

.call(data) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses value with currency hash

Parameters:

  • data (Hash)
  • decimal_point (Integer)

    MtGox sends integer values. We use this to divide that value.

Returns:

  • (Hash)


19
20
21
22
23
# File 'lib/bitbot/trader/providers/mt_gox/value_with_currency_coercer.rb', line 19

def self.call(data)
  value, currency = data.values_at("value_int", "currency")
  decimal_point = currency == "BTC" ? 8 : 5
  {value: BigDecimal(value) / (10 ** decimal_point), currency: currency}
end