Class: CoinSync::Importers::EtherDelta
- Defined in:
- lib/coinsync/importers/etherdelta.rb
Overview
Look up your transactions using DeltaBalances at deltabalances.github.io/history.html, specifying the time range you need, and then download the “Default” CSV in the top-right section
Defined Under Namespace
Classes: HistoryEntry
Constant Summary collapse
- ETH =
CryptoCurrency.new('ETH')
Instance Method Summary collapse
Methods inherited from Base
#can_build?, #initialize, register_commands, register_importer, registered_commands
Constructor Details
This class inherits a constructor from CoinSync::Importers::Base
Instance Method Details
#read_transaction_list(source) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/coinsync/importers/etherdelta.rb', line 48 def read_transaction_list(source) csv = CSV.new(source, col_sep: ',') transactions = [] csv.each do |line| next if line[0] == 'Type' entry = HistoryEntry.new(line) next if entry.amount.round(8) == 0 || entry.total.round(8) == 0 if entry.trade == 'Buy' if entry.fee_token != ETH raise "EtherDelta importer: Unexpected fee currency: #{entry.fee_token.code}" end transactions << Transaction.new( exchange: 'EtherDelta', time: entry.date, bought_amount: entry.amount, bought_currency: entry.token, sold_amount: entry.total + entry.fee, sold_currency: ETH ) else if entry.fee_token != entry.token raise "EtherDelta importer: Unexpected fee currency: #{entry.fee_token.code}" end transactions << Transaction.new( exchange: 'EtherDelta', time: entry.date, bought_amount: entry.total, bought_currency: ETH, sold_amount: entry.amount + entry.fee, sold_currency: entry.token ) end end transactions.sort_by(&:time) end |