Class: IGMarkets::DealingPlatform::SprintMarketPositionMethods
- Inherits:
-
Object
- Object
- IGMarkets::DealingPlatform::SprintMarketPositionMethods
- Defined in:
- lib/ig_markets/dealing_platform/sprint_market_position_methods.rb
Overview
Provides methods for working with sprint market positions. Returned by #sprint_market_positions.
Instance Method Summary collapse
-
#[](deal_id) ⇒ SprintMarketPosition
Returns the sprint market position with the specified deal ID, or ‘nil` if there is no sprint market position with that ID.
-
#all ⇒ Array<SprintMarketPosition>
Returns all sprint market positions.
-
#create(attributes) ⇒ String
Creates a new sprint market position.
-
#initialize(dealing_platform) ⇒ SprintMarketPositionMethods
constructor
Initializes this helper class with the specified dealing platform.
Constructor Details
#initialize(dealing_platform) ⇒ SprintMarketPositionMethods
Initializes this helper class with the specified dealing platform.
8 9 10 |
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 8 def initialize(dealing_platform) @dealing_platform = WeakRef.new dealing_platform end |
Instance Method Details
#[](deal_id) ⇒ SprintMarketPosition
Returns the sprint market position with the specified deal ID, or ‘nil` if there is no sprint market position with that ID.
27 28 29 30 31 |
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 27 def [](deal_id) all.detect do |sprint_market_position| sprint_market_position.deal_id == deal_id end end |
#all ⇒ Array<SprintMarketPosition>
Returns all sprint market positions.
15 16 17 18 19 |
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 15 def all result = @dealing_platform.session.get('positions/sprintmarkets', API_V2).fetch :sprint_market_positions @dealing_platform.instantiate_models SprintMarketPosition, result end |
#create(attributes) ⇒ String
Creates a new sprint market position.
44 45 46 47 48 |
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 44 def create(attributes) body = RequestBodyFormatter.format SprintMarketPositionCreateAttributes.new(attributes) @dealing_platform.session.post('positions/sprintmarkets', body).fetch :deal_reference end |