Class: Excoin::Market::Exchange::Trade

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trade_data) ⇒ Trade

Returns a new instance of Trade.



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

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'])
    @commodity_amount = BigDecimal.new(trade_data['commodity_amount'])
    @currency_amount = BigDecimal.new(trade_data['currency_amount'])
  rescue
    puts "Error in Excoin::Market::Exchange::Trade.initialize"
    puts trade_data
  end
end

Instance Attribute Details

#commodityObject (readonly)

Returns the value of attribute commodity.



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

def commodity
  @commodity
end

#commodity_amountObject (readonly)

Returns the value of attribute commodity_amount.



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

def commodity_amount
  @commodity_amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



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

def currency
  @currency
end

#currency_amountObject (readonly)

Returns the value of attribute currency_amount.



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

def currency_amount
  @currency_amount
end

#priceObject (readonly)

Returns the value of attribute price.



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

def price
  @price
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#exchangeObject



21
22
23
# File 'lib/exchange/trade.rb', line 21

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