Class: Itbit::Trade
- Inherits:
-
Object
- Object
- Itbit::Trade
- Defined in:
- lib/itbit/trade.rb
Overview
List the full trading history for a given wallet
Instance Attribute Summary collapse
-
#commission_currency ⇒ Object
Returns the value of attribute commission_currency.
-
#commission_paid ⇒ Object
Returns the value of attribute commission_paid.
-
#currency1 ⇒ Object
Returns the value of attribute currency1.
-
#currency1_amount ⇒ Object
Returns the value of attribute currency1_amount.
-
#currency2 ⇒ Object
Returns the value of attribute currency2.
-
#currency2_amount ⇒ Object
Returns the value of attribute currency2_amount.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#instrument ⇒ Object
Returns the value of attribute instrument.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#rebate_currency ⇒ Object
Returns the value of attribute rebate_currency.
-
#rebates_applied ⇒ Object
Returns the value of attribute rebates_applied.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.all(opts = {}) ⇒ Array<Itbit::Trade>
Lists all trades for a wallet Results can be filtered and paginated by passing in these options.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Trade
constructor
A new instance of Trade.
Constructor Details
#initialize(attrs) ⇒ Trade
Returns a new instance of Trade.
9 10 11 |
# File 'lib/itbit/trade.rb', line 9 def initialize(attrs) attrs.each{|k, v| send("#{k.underscore}=", v)} end |
Instance Attribute Details
#commission_currency ⇒ Object
Returns the value of attribute commission_currency.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def commission_currency @commission_currency end |
#commission_paid ⇒ Object
Returns the value of attribute commission_paid.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def commission_paid @commission_paid end |
#currency1 ⇒ Object
Returns the value of attribute currency1.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def currency1 @currency1 end |
#currency1_amount ⇒ Object
Returns the value of attribute currency1_amount.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def currency1_amount @currency1_amount end |
#currency2 ⇒ Object
Returns the value of attribute currency2.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def currency2 @currency2 end |
#currency2_amount ⇒ Object
Returns the value of attribute currency2_amount.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def currency2_amount @currency2_amount end |
#direction ⇒ Object
Returns the value of attribute direction.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def direction @direction end |
#instrument ⇒ Object
Returns the value of attribute instrument.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def instrument @instrument end |
#order_id ⇒ Object
Returns the value of attribute order_id.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def order_id @order_id end |
#rate ⇒ Object
Returns the value of attribute rate.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def rate @rate end |
#rebate_currency ⇒ Object
Returns the value of attribute rebate_currency.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def rebate_currency @rebate_currency end |
#rebates_applied ⇒ Object
Returns the value of attribute rebates_applied.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def rebates_applied @rebates_applied end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
4 5 6 |
# File 'lib/itbit/trade.rb', line 4 def @timestamp end |
Class Method Details
.all(opts = {}) ⇒ Array<Itbit::Trade>
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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 |