Class: SchwabRb::DataObjects::OrderPreview
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::OrderPreview
- Defined in:
- lib/schwab_rb/data_objects/order_preview.rb
Defined Under Namespace
Classes: CommissionAndFee, OrderBalance, OrderStrategy, OrderValidationResult
Instance Attribute Summary collapse
-
#commission_and_fee ⇒ Object
readonly
Returns the value of attribute commission_and_fee.
-
#order_balance ⇒ Object
readonly
Returns the value of attribute order_balance.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#order_strategy ⇒ Object
readonly
Returns the value of attribute order_strategy.
-
#order_validation_result ⇒ Object
readonly
Returns the value of attribute order_validation_result.
-
#order_value ⇒ Object
readonly
Returns the value of attribute order_value.
Class Method Summary collapse
Instance Method Summary collapse
- #accepted? ⇒ Boolean
- #commission ⇒ Object
- #fees ⇒ Object
-
#initialize(attrs) ⇒ OrderPreview
constructor
A new instance of OrderPreview.
- #price ⇒ Object
- #quantity ⇒ Object
- #status ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(attrs) ⇒ OrderPreview
Returns a new instance of OrderPreview.
17 18 19 20 21 22 23 24 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 17 def initialize(attrs) @order_id = attrs[:orderId] @order_value = attrs[:orderValue] @order_strategy = attrs[:orderStrategy] ? OrderStrategy.new(attrs[:orderStrategy]) : nil @order_balance = attrs[:orderBalance] ? OrderBalance.new(attrs[:orderBalance]) : nil @order_validation_result = attrs[:orderValidationResult] ? OrderValidationResult.new(attrs[:orderValidationResult]) : nil @commission_and_fee = attrs[:commissionAndFee] ? CommissionAndFee.new(attrs[:commissionAndFee]) : nil end |
Instance Attribute Details
#commission_and_fee ⇒ Object (readonly)
Returns the value of attribute commission_and_fee.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8 def commission_and_fee @commission_and_fee end |
#order_balance ⇒ Object (readonly)
Returns the value of attribute order_balance.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8 def order_balance @order_balance end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8 def order_id @order_id end |
#order_strategy ⇒ Object (readonly)
Returns the value of attribute order_strategy.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8 def order_strategy @order_strategy end |
#order_validation_result ⇒ Object (readonly)
Returns the value of attribute order_validation_result.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8 def order_validation_result @order_validation_result end |
#order_value ⇒ Object (readonly)
Returns the value of attribute order_value.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8 def order_value @order_value end |
Class Method Details
.build(data) ⇒ Object
12 13 14 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 12 def build(data) new(data) end |
Instance Method Details
#accepted? ⇒ Boolean
38 39 40 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 38 def accepted? status == "ACCEPTED" end |
#commission ⇒ Object
42 43 44 45 46 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 42 def commission return 0.0 unless @commission_and_fee @commission_and_fee.commission end |
#fees ⇒ Object
48 49 50 51 52 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 48 def fees return 0.0 unless @commission_and_fee @commission_and_fee.fee end |
#price ⇒ Object
30 31 32 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 30 def price @order_strategy&.price end |
#quantity ⇒ Object
34 35 36 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 34 def quantity @order_strategy&.quantity end |
#status ⇒ Object
26 27 28 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 26 def status @order_strategy&.status end |
#to_h ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 54 def to_h { orderId: @order_id, orderValue: @order_value, orderStrategy: @order_strategy&.to_h, orderBalance: @order_balance&.to_h, orderValidationResult: @order_validation_result&.to_h, commissionAndFee: @commission_and_fee&.to_h } end |