Class: Excoin::Account::Trade

Inherits:
Object
  • Object
show all
Defined in:
lib/account/trade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trade_data) ⇒ Trade

Returns a new instance of Trade.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/account/trade.rb', line 5

def initialize(trade_data)
  begin
    @timestamp = Time.parse(trade_data['timestamp'])
    @currency = trade_data['currency']
    @commodity = trade_data['commodity']
    @type = trade_data['type']
    @price = BigDecimal.new(trade_data['price'])
    @sent = BigDecimal.new(trade_data['sent'])
    @received = BigDecimal.new(trade_data['received'])
    @fee = BigDecimal.new(trade_data['fee'])
    @net_received = BigDecimal.new(trade_data['net_received'])
  rescue
    puts "Error in Excoin::Account::Trade.initialize"
    puts trade_data
  end
end

Instance Attribute Details

#commodityObject (readonly)

Returns the value of attribute commodity.



2
3
4
# File 'lib/account/trade.rb', line 2

def commodity
  @commodity
end

#currencyObject (readonly)

Returns the value of attribute currency.



2
3
4
# File 'lib/account/trade.rb', line 2

def currency
  @currency
end

#feeObject (readonly)

Returns the value of attribute fee.



2
3
4
# File 'lib/account/trade.rb', line 2

def fee
  @fee
end

#net_receivedObject (readonly)

Returns the value of attribute net_received.



2
3
4
# File 'lib/account/trade.rb', line 2

def net_received
  @net_received
end

#priceObject (readonly)

Returns the value of attribute price.



2
3
4
# File 'lib/account/trade.rb', line 2

def price
  @price
end

#receivedObject (readonly)

Returns the value of attribute received.



2
3
4
# File 'lib/account/trade.rb', line 2

def received
  @received
end

#sentObject (readonly)

Returns the value of attribute sent.



2
3
4
# File 'lib/account/trade.rb', line 2

def sent
  @sent
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



2
3
4
# File 'lib/account/trade.rb', line 2

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/account/trade.rb', line 2

def type
  @type
end

Instance Method Details

#exchangeObject



22
23
24
# File 'lib/account/trade.rb', line 22

def exchange
  Excoin.market.exchange(@currency + @commodity)
end