class Itbit::Trade

List the full trading history for a given wallet

Attributes

commission_currency[RW]
commission_paid[RW]
currency1[RW]
currency1_amount[RW]
currency2[RW]
currency2_amount[RW]
direction[RW]
instrument[RW]
order_id[RW]
rate[RW]
rebate_currency[RW]
rebates_applied[RW]
timestamp[RW]

Public Class Methods

all(opts = {}) click to toggle source

Lists all trades for a wallet Results can be filtered and paginated by passing in these options.

wallet_id: String, defaults to Itbit.default_wallet_id
page: Integer, starting page for pagination.
per_page: Integer, how many to show per page.
range_start: Integer timestamp, start showing at this date.
range_end: Integer timestamp, stop showing at this date.

@return [Array<Itbit::Trade>]

# File lib/itbit/trade.rb, line 39
def self.all(opts = {})
  wallet_id = opts[:wallet_id] || Itbit.default_wallet_id
  params = {}
  %w(range_start range_end page per_page last_execution_id).each do |a|
    params[a.camelize(:lower)] = opts[a.to_sym].to_i if opts[a.to_sym]
  end
  response = Api.request(:get, "/wallets/#{wallet_id}/trades", params)
  {
    total_number_of_records: response['totalNumberOfRecords'].to_i,
    current_page_number: response['currentPageNumber'].to_i,
    latest_execution_id: response['latestExecutionId'].to_i,
    records_per_page: response['recordsPerPage'].to_i,
    trading_history: response['tradingHistory'].collect{|x| new(x) }
  }
end
new(attrs) click to toggle source
# File lib/itbit/trade.rb, line 9
def initialize(attrs)
  attrs.each{|k, v| send("#{k.underscore}=", v)}
end

Public Instance Methods

timestamp=(value) click to toggle source
# File lib/itbit/trade.rb, line 27
def timestamp=(value)
  @timestamp = value.is_a?(String) ? Time.parse(value).to_i : value
end