Class: SchwabRb::DataObjects::TransferItem
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::TransferItem
- Defined in:
- lib/schwab_rb/data_objects/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#fee_type ⇒ Object
readonly
Returns the value of attribute fee_type.
-
#instrument ⇒ Object
readonly
Returns the value of attribute instrument.
-
#position_effect ⇒ Object
readonly
Returns the value of attribute position_effect.
Class Method Summary collapse
Instance Method Summary collapse
- #asset? ⇒ Boolean
- #commission? ⇒ Boolean
- #credit_debit? ⇒ Boolean
- #description ⇒ Object
- #equity? ⇒ Boolean
- #fee? ⇒ Boolean
-
#initialize(instrument:, amount:, cost:, fee_type:, position_effect:) ⇒ TransferItem
constructor
A new instance of TransferItem.
- #instrument_id ⇒ Object
- #option? ⇒ Boolean
- #put_call ⇒ Object
- #symbol ⇒ Object
- #to_h ⇒ Object
- #underlying_symbol ⇒ Object
Constructor Details
#initialize(instrument:, amount:, cost:, fee_type:, position_effect:) ⇒ TransferItem
22 23 24 25 26 27 28 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 22 def initialize(instrument:, amount:, cost:, fee_type:, position_effect:) @instrument = instrument @amount = amount @cost = cost @fee_type = fee_type @position_effect = position_effect end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
20 21 22 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 20 def amount @amount end |
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
20 21 22 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 20 def cost @cost end |
#fee_type ⇒ Object (readonly)
Returns the value of attribute fee_type.
20 21 22 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 20 def fee_type @fee_type end |
#instrument ⇒ Object (readonly)
Returns the value of attribute instrument.
20 21 22 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 20 def instrument @instrument end |
#position_effect ⇒ Object (readonly)
Returns the value of attribute position_effect.
20 21 22 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 20 def position_effect @position_effect end |
Class Method Details
.build(data) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 9 def build(data) TransferItem.new( instrument: Instrument.build(data.fetch(:instrument)), amount: data.fetch(:amount), cost: data.fetch(:cost), fee_type: data.fetch(:feeType, nil), position_effect: data.fetch(:positionEffect, nil) ) end |
Instance Method Details
#asset? ⇒ Boolean
54 55 56 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 54 def asset? option? || equity? end |
#commission? ⇒ Boolean
70 71 72 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 70 def commission? fee_type == "COMMISSION" end |
#credit_debit? ⇒ Boolean
62 63 64 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 62 def credit_debit? fee_type.nil? end |
#description ⇒ Object
42 43 44 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 42 def description asset? ? instrument.description : "" end |
#equity? ⇒ Boolean
50 51 52 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 50 def equity? instrument.equity? end |
#fee? ⇒ Boolean
66 67 68 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 66 def fee? %w[OPT_REG_FEE TAF_FEE SEC_FEE INDEX_OPTION_FEE].include?(fee_type) end |
#instrument_id ⇒ Object
30 31 32 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 30 def instrument_id instrument.instrument_id end |
#option? ⇒ Boolean
46 47 48 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 46 def option? instrument.option? end |
#put_call ⇒ Object
58 59 60 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 58 def put_call instrument.put_call end |
#symbol ⇒ Object
34 35 36 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 34 def symbol instrument.symbol end |
#to_h ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 74 def to_h { instrument: instrument.to_h, amount: amount, cost: cost, fee_type: fee_type, position_effect: position_effect } end |
#underlying_symbol ⇒ Object
38 39 40 |
# File 'lib/schwab_rb/data_objects/transaction.rb', line 38 def option? ? instrument. : "" end |