Class: IGMarkets::DealingPlatform::SprintMarketPositionMethods

Inherits:
Object
  • Object
show all
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.

Defined Under Namespace

Classes: SprintMarketPositionCreateAttributes

Instance Method Summary collapse

Constructor Details

#initialize(dealing_platform) ⇒ SprintMarketPositionMethods

Initializes this helper class with the specified dealing platform.

Parameters:



8
9
10
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 8

def initialize(dealing_platform)
  @dealing_platform = dealing_platform
end

Instance Method Details

#allArray<SprintMarketPosition>

Returns all sprint market positions.

Returns:



15
16
17
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 15

def all
  @dealing_platform.gather 'positions/sprintmarkets', :sprint_market_positions, SprintMarketPosition
end

#create(attributes) ⇒ String

Creates a new sprint market position.

Parameters:

  • attributes (Hash)

    The attributes for the new sprint market position.

Options Hash (attributes):

  • :epic (String)

    The EPIC for the instrument to create a sprint market position for. Required.

  • :direction (:buy, :sell)

    The position direction. Required.

  • :expiry_period (:one_minute, :two_minutes, :five_minutes, :twenty_minutes, :sixty_minutes)

    The expiry period. Required.

  • :size (Float)

    The size of the sprint market position to create. Required.

Returns:



30
31
32
33
34
# File 'lib/ig_markets/dealing_platform/sprint_market_position_methods.rb', line 30

def create(attributes)
  payload = PayloadFormatter.format SprintMarketPositionCreateAttributes.new attributes

  @dealing_platform.session.post('positions/sprintmarkets', payload, API_V1).fetch(:deal_reference)
end