Class: SchwabRb::DataObjects::OrderPreview
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::OrderPreview
show all
- Defined in:
- lib/schwab_rb/data_objects/order_preview.rb
Defined Under Namespace
Classes: CommissionAndFee, OrderBalance, OrderStrategy, OrderValidationResult
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
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
@projected_commission = attrs[:projectedCommission] ? CommissionAndFee.new(attrs[:projectedCommission]) : nil
end
|
Instance Attribute Details
#order_balance ⇒ Object
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
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
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
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
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
|
#projected_commission ⇒ Object
Returns the value of attribute projected_commission.
8
9
10
|
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 8
def projected_commission
@projected_commission
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 @projected_commission
@projected_commission.commission_value
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 @projected_commission
@projected_commission.fee_value
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,
projectedCommission: @projected_commission&.to_h
}
end
|