Method: CoinSync::Importers::BinanceAPI::HistoryEntry#initialize
- Defined in:
- lib/coinsync/importers/binance_api.rb
#initialize(hash) ⇒ HistoryEntry
Returns a new instance of HistoryEntry.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/coinsync/importers/binance_api.rb', line 25 def initialize(hash) @quantity = BigDecimal.new(hash['qty']) @commission = BigDecimal.new(hash['commission']) @commission_asset = CryptoCurrency.new(hash['commissionAsset']) @price = BigDecimal.new(hash['price']) @time = Time.at(hash['time'] / 1000) @buyer = hash['isBuyer'] @asset, @currency = parse_coins(hash['symbol']) if (@buyer && @commission_asset != @asset) || (!@buyer && @commission_asset != @currency) raise "Binance API: Unexpected fee: #{hash}" end end |