Class: Tastytrade::Models::BuyingPowerEffect
- Defined in:
- lib/tastytrade/models/buying_power_effect.rb
Overview
Represents the buying power effect from a dry-run order or order placement
Instance Attribute Summary collapse
-
#change_in_buying_power ⇒ Object
readonly
Returns the value of attribute change_in_buying_power.
-
#change_in_margin_requirement ⇒ Object
readonly
Returns the value of attribute change_in_margin_requirement.
-
#current_buying_power ⇒ Object
readonly
Returns the value of attribute current_buying_power.
-
#effect ⇒ Object
readonly
Returns the value of attribute effect.
-
#impact ⇒ Object
readonly
Returns the value of attribute impact.
-
#is_spread ⇒ Object
readonly
Returns the value of attribute is_spread.
-
#isolated_order_margin_requirement ⇒ Object
readonly
Returns the value of attribute isolated_order_margin_requirement.
-
#new_buying_power ⇒ Object
readonly
Returns the value of attribute new_buying_power.
Attributes inherited from Base
Instance Method Summary collapse
-
#buying_power_change_amount ⇒ Object
Get the absolute value of the buying power change.
-
#buying_power_usage_percentage ⇒ Object
Calculate the buying power usage percentage for this order.
-
#credit? ⇒ Boolean
Check if this is a credit (increases buying power).
-
#debit? ⇒ Boolean
Check if this is a debit (reduces buying power).
-
#exceeds_threshold?(threshold_percentage) ⇒ Boolean
Check if this order would use more than the specified percentage of buying power.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Tastytrade::Models::Base
Instance Attribute Details
#change_in_buying_power ⇒ Object (readonly)
Returns the value of attribute change_in_buying_power.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def end |
#change_in_margin_requirement ⇒ Object (readonly)
Returns the value of attribute change_in_margin_requirement.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def change_in_margin_requirement @change_in_margin_requirement end |
#current_buying_power ⇒ Object (readonly)
Returns the value of attribute current_buying_power.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def end |
#effect ⇒ Object (readonly)
Returns the value of attribute effect.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def effect @effect end |
#impact ⇒ Object (readonly)
Returns the value of attribute impact.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def impact @impact end |
#is_spread ⇒ Object (readonly)
Returns the value of attribute is_spread.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def is_spread @is_spread end |
#isolated_order_margin_requirement ⇒ Object (readonly)
Returns the value of attribute isolated_order_margin_requirement.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def isolated_order_margin_requirement @isolated_order_margin_requirement end |
#new_buying_power ⇒ Object (readonly)
Returns the value of attribute new_buying_power.
9 10 11 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 9 def end |
Instance Method Details
#buying_power_change_amount ⇒ Object
Get the absolute value of the buying power change
28 29 30 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 28 def &.abs || impact&.abs || BigDecimal("0") end |
#buying_power_usage_percentage ⇒ Object
Calculate the buying power usage percentage for this order
15 16 17 18 19 20 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 15 def return BigDecimal("0") if .nil? || .zero? impact_amount = impact || &.abs || BigDecimal("0") ((impact_amount / ) * 100).round(2) end |
#credit? ⇒ Boolean
Check if this is a credit (increases buying power)
38 39 40 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 38 def credit? effect == "Credit" || ( && > 0) end |
#debit? ⇒ Boolean
Check if this is a debit (reduces buying power)
33 34 35 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 33 def debit? effect == "Debit" || ( && < 0) end |
#exceeds_threshold?(threshold_percentage) ⇒ Boolean
Check if this order would use more than the specified percentage of buying power
23 24 25 |
# File 'lib/tastytrade/models/buying_power_effect.rb', line 23 def exceeds_threshold?(threshold_percentage) > BigDecimal(threshold_percentage.to_s) end |