Class: IGMarkets::Watchlist

Inherits:
Model
  • Object
show all
Defined in:
lib/ig_markets/watchlist.rb

Overview

Contains details on a watchlist. Returned by DealingPlatform::WatchlistMethods#all and DealingPlatform::WatchlistMethods#[].

Instance Attribute Summary

Attributes inherited from Model

#attributes

Instance Method Summary collapse

Methods inherited from Model

#==, allowed_values, attribute, attribute_type, attribute_value_allowed?, defined_attribute_names, deprecated_attribute, #initialize, #initialize_copy, #inspect, #to_h, valid_attribute?

Constructor Details

This class inherits a constructor from IGMarkets::Model

Instance Method Details

#add_market(epic) ⇒ Object

Adds a market to this watchlist.

Parameters:

  • epic (String)

    The EPIC of the market to add to this watchlist.



28
29
30
# File 'lib/ig_markets/watchlist.rb', line 28

def add_market(epic)
  @dealing_platform.session.put "watchlists/#{id}", epic: epic
end

#default_system_watchlistBoolean

The default_system_watchlist attribute.

Returns:



5
# File 'lib/ig_markets/watchlist.rb', line 5

attribute :default_system_watchlist, Boolean

#deleteObject

Deletes this watchlist.



21
22
23
# File 'lib/ig_markets/watchlist.rb', line 21

def delete
  @dealing_platform.session.delete "watchlists/#{id}"
end

#deleteableBoolean

The deleteable attribute.

Returns:



6
# File 'lib/ig_markets/watchlist.rb', line 6

attribute :deleteable, Boolean

#editableBoolean

The editable attribute.

Returns:



7
# File 'lib/ig_markets/watchlist.rb', line 7

attribute :editable, Boolean

#idObject

The id attribute.

Returns:



8
# File 'lib/ig_markets/watchlist.rb', line 8

attribute :id

#marketsArray<MarketOverview>

Returns the markets for this watchlist.

Returns:



14
15
16
17
18
# File 'lib/ig_markets/watchlist.rb', line 14

def markets
  result = @dealing_platform.session.get("watchlists/#{id}").fetch :markets

  @dealing_platform.instantiate_models MarketOverview, result
end

#nameObject

The name attribute.

Returns:



9
# File 'lib/ig_markets/watchlist.rb', line 9

attribute :name

#remove_market(epic) ⇒ Object

Removes a market from this watchlist.

Parameters:

  • epic (String)

    The EPIC of the market to remove from this watchlist.



35
36
37
# File 'lib/ig_markets/watchlist.rb', line 35

def remove_market(epic)
  @dealing_platform.session.delete "watchlists/#{id}/#{epic}"
end