Class: Tastytrade::Models::Transaction
- Defined in:
- lib/tastytrade/models/transaction.rb
Overview
Represents a transaction in a Tastytrade account
Constant Summary collapse
- TRANSACTION_TYPES =
%w[ ACAT Assignment Balance\ Adjustment Cash\ Disbursement Cash\ Merger Cash\ Settled\ Assignment Cash\ Settled\ Exercise Credit\ Interest Debit\ Interest Deposit Dividend Exercise Expiration Fee Forward\ Split Futures\ Settlement Journal\ Entry Mark\ to\ Market Maturity Merger\ Acquisition Money\ Movement Name\ Change Paid\ Premium\ Lending\ Income Receive\ Deliver Reverse\ Split Special\ Dividend Stock\ Dividend Stock\ Loan\ Income Stock\ Merger Symbol\ Change Transfer Withdrawal ].freeze
- INSTRUMENT_TYPES =
%w[ Bond Cryptocurrency Equity Equity\ Offering Equity\ Option Future Future\ Option Index Unknown Warrant ].freeze
Instance Attribute Summary collapse
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#clearing_fees ⇒ Object
readonly
Returns the value of attribute clearing_fees.
-
#commission ⇒ Object
readonly
Returns the value of attribute commission.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#executed_at ⇒ Object
readonly
Returns the value of attribute executed_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#instrument_type ⇒ Object
readonly
Returns the value of attribute instrument_type.
-
#is_estimated_fee ⇒ Object
readonly
Returns the value of attribute is_estimated_fee.
-
#is_verified ⇒ Object
readonly
Returns the value of attribute is_verified.
-
#net_value ⇒ Object
readonly
Returns the value of attribute net_value.
-
#net_value_effect ⇒ Object
readonly
Returns the value of attribute net_value_effect.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#proprietary_index_option_fees ⇒ Object
readonly
Returns the value of attribute proprietary_index_option_fees.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#regulatory_fees ⇒ Object
readonly
Returns the value of attribute regulatory_fees.
-
#reverses_id ⇒ Object
readonly
Returns the value of attribute reverses_id.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
-
#transaction_date ⇒ Object
readonly
Returns the value of attribute transaction_date.
-
#transaction_sub_type ⇒ Object
readonly
Returns the value of attribute transaction_sub_type.
-
#transaction_type ⇒ Object
readonly
Returns the value of attribute transaction_type.
-
#underlying_symbol ⇒ Object
readonly
Returns the value of attribute underlying_symbol.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#value_date ⇒ Object
readonly
Returns the value of attribute value_date.
-
#value_effect ⇒ Object
readonly
Returns the value of attribute value_effect.
Attributes inherited from Base
Class Method Summary collapse
-
.get_all(session, account_number, **options) ⇒ Array<Transaction>
Fetch transaction history for an account.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Tastytrade::Models::Base
Instance Attribute Details
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def account_number @account_number end |
#action ⇒ Object (readonly)
Returns the value of attribute action.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def action @action end |
#clearing_fees ⇒ Object (readonly)
Returns the value of attribute clearing_fees.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def clearing_fees @clearing_fees end |
#commission ⇒ Object (readonly)
Returns the value of attribute commission.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def commission @commission end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def description @description end |
#executed_at ⇒ Object (readonly)
Returns the value of attribute executed_at.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def executed_at @executed_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def id @id end |
#instrument_type ⇒ Object (readonly)
Returns the value of attribute instrument_type.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def instrument_type @instrument_type end |
#is_estimated_fee ⇒ Object (readonly)
Returns the value of attribute is_estimated_fee.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def is_estimated_fee @is_estimated_fee end |
#is_verified ⇒ Object (readonly)
Returns the value of attribute is_verified.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def is_verified @is_verified end |
#net_value ⇒ Object (readonly)
Returns the value of attribute net_value.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def net_value @net_value end |
#net_value_effect ⇒ Object (readonly)
Returns the value of attribute net_value_effect.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def net_value_effect @net_value_effect end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def order_id @order_id end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def price @price end |
#proprietary_index_option_fees ⇒ Object (readonly)
Returns the value of attribute proprietary_index_option_fees.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def proprietary_index_option_fees @proprietary_index_option_fees end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def quantity @quantity end |
#regulatory_fees ⇒ Object (readonly)
Returns the value of attribute regulatory_fees.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def regulatory_fees @regulatory_fees end |
#reverses_id ⇒ Object (readonly)
Returns the value of attribute reverses_id.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def reverses_id @reverses_id end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def symbol @symbol end |
#transaction_date ⇒ Object (readonly)
Returns the value of attribute transaction_date.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def transaction_date @transaction_date end |
#transaction_sub_type ⇒ Object (readonly)
Returns the value of attribute transaction_sub_type.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def transaction_sub_type @transaction_sub_type end |
#transaction_type ⇒ Object (readonly)
Returns the value of attribute transaction_type.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def transaction_type @transaction_type end |
#underlying_symbol ⇒ Object (readonly)
Returns the value of attribute underlying_symbol.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def value @value end |
#value_date ⇒ Object (readonly)
Returns the value of attribute value_date.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def value_date @value_date end |
#value_effect ⇒ Object (readonly)
Returns the value of attribute value_effect.
11 12 13 |
# File 'lib/tastytrade/models/transaction.rb', line 11 def value_effect @value_effect end |
Class Method Details
.get_all(session, account_number, **options) ⇒ Array<Transaction>
Fetch transaction history for an account
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tastytrade/models/transaction.rb', line 47 def self.get_all(session, account_number, **) params = build_params() transactions = [] page_offset = [:page_offset] || 0 loop do current_params = params.dup current_params["page-offset"] = page_offset unless page_offset.zero? response = session.get("/accounts/#{account_number}/transactions", current_params) items = response.dig("data", "items") || [] break if items.empty? transactions.concat(items.map { |item| new(item) }) # Break if we've reached the requested limit or if pagination is manual break if [:page_offset] || transactions.size >= ([:per_page] || 250) page_offset += 1 end transactions end |