Class: IGMarkets::Market
Overview
Contains details on a market, which is a combination of an #instrument, a set of #dealing_rules, and a current #snapshot of the instrument’s market. Returned by DealingPlatform::MarketMethods#find and DealingPlatform::MarketMethods#[].
Defined Under Namespace
Classes: DealingRules, Snapshot
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#dealing_rules ⇒ DealingRules
The dealing_rules attribute.
-
#historical_prices(options) ⇒ HistoricalPriceResult
Returns historical prices for this market at a given resolution, either the most recent prices by specifying the ‘:number` option, or those from a date range by specifying the `:from` and `:to` options.
-
#instrument ⇒ Instrument
The instrument attribute.
-
#reload ⇒ Object
Reloads this market’s attributes by re-querying the IG Markets API.
-
#snapshot ⇒ Snapshot
The snapshot attribute.
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
#dealing_rules ⇒ DealingRules
The dealing_rules attribute.
42 |
# File 'lib/ig_markets/market.rb', line 42 attribute :dealing_rules, DealingRules |
#historical_prices(options) ⇒ HistoricalPriceResult
Returns historical prices for this market at a given resolution, either the most recent prices by specifying the ‘:number` option, or those from a date range by specifying the `:from` and `:to` options.
Required.
64 65 66 67 68 69 70 71 72 |
# File 'lib/ig_markets/market.rb', line 64 def historical_prices() [:max] = .delete(:number) if .key? :number [:from] = [:from].utc.strftime '%FT%T' if .key? :from [:to] = [:to].utc.strftime '%FT%T' if .key? :to @dealing_platform.instantiate_models HistoricalPriceResult, historical_prices_request() end |
#instrument ⇒ Instrument
The instrument attribute.
43 |
# File 'lib/ig_markets/market.rb', line 43 attribute :instrument, Instrument |
#reload ⇒ Object
Reloads this market’s attributes by re-querying the IG Markets API.
47 48 49 |
# File 'lib/ig_markets/market.rb', line 47 def reload self.attributes = @dealing_platform.markets[instrument.epic].attributes end |