ig_markets 0.27 → 0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/ig_markets/cli/commands/self_test_command.rb +0 -12
- data/lib/ig_markets/cli/tables/transactions_table.rb +5 -5
- data/lib/ig_markets/errors.rb +12 -0
- data/lib/ig_markets/instrument.rb +7 -0
- data/lib/ig_markets/model.rb +2 -2
- data/lib/ig_markets/streaming/account_state.rb +6 -2
- data/lib/ig_markets/streaming/working_order_update.rb +4 -0
- data/lib/ig_markets/transaction.rb +1 -0
- data/lib/ig_markets/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddb9a35321ec6be744a90297554801dda3b386ac
|
|
4
|
+
data.tar.gz: a48c71086d5b6384ebcd564bad98125fb4fd660f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 377a03f5f52f38011387628d4beda79ba53bf611a4d079bcb6583d32bb8fa6d6a70ad7ce03e8d0d97f44733a80708c3cd0d8469c1dc466a50f7a65ab4f55601c
|
|
7
|
+
data.tar.gz: ef6fd8c0825baffadcf19a21efe2e02e6bf7146b105f756a27f7bf7d251ae29a8f227c46282dcbfe3bc332b693117f4a34a3b79848c688528d91dbf81927cb75
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# IG Markets Changelog
|
|
2
2
|
|
|
3
|
+
### 0.28 — February 24, 2017
|
|
4
|
+
|
|
5
|
+
- Added IGMarkets::Instrument#limited_risk_premium
|
|
6
|
+
- Added IGMarkets::Transaction#open_date_utc
|
|
7
|
+
- Added `#currency`, `#good_till_date`, `#order_type` and `#time_in_force` attributes to
|
|
8
|
+
`IGMarkets::Streaming::WorkingOrderUpdate`
|
|
9
|
+
- Fixed `IGMarkets::AccountState` not updating its working orders when a level update is received
|
|
10
|
+
- Added `IGMarkets::Error::GetSessionTimeoutError` and `IGMarkets::Error::InvalidShareOrderInstrumentDataError`
|
|
11
|
+
|
|
3
12
|
### 0.27 — January 18, 2017
|
|
4
13
|
|
|
5
14
|
- Added `IGMarkets::Format.colored_currency`
|
|
@@ -20,7 +20,6 @@ module IGMarkets
|
|
|
20
20
|
def run_self_test
|
|
21
21
|
test_markets
|
|
22
22
|
test_positions
|
|
23
|
-
test_sprint_market_positions
|
|
24
23
|
test_working_orders
|
|
25
24
|
test_watchlists
|
|
26
25
|
test_client_sentiment
|
|
@@ -70,17 +69,6 @@ module IGMarkets
|
|
|
70
69
|
raise 'Error: failed closing position' if @dealing_platform.positions[@position.deal_id]
|
|
71
70
|
end
|
|
72
71
|
|
|
73
|
-
def test_sprint_market_positions
|
|
74
|
-
create_options = { direction: :buy, expiry_period: :sixty_minutes, epic: 'FM.D.EURUSD24.EURUSD24.IP',
|
|
75
|
-
size: 100 }
|
|
76
|
-
|
|
77
|
-
deal_reference = @dealing_platform.sprint_market_positions.create create_options
|
|
78
|
-
deal_confirmation = @dealing_platform.deal_confirmation deal_reference
|
|
79
|
-
sprint_market_position = @dealing_platform.sprint_market_positions[deal_confirmation.deal_id]
|
|
80
|
-
|
|
81
|
-
raise 'Error: failed creating sprint market position' unless sprint_market_position
|
|
82
|
-
end
|
|
83
|
-
|
|
84
72
|
def test_working_orders
|
|
85
73
|
test_working_order_create
|
|
86
74
|
test_working_order_update
|
|
@@ -9,17 +9,17 @@ module IGMarkets
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def headings
|
|
12
|
-
['Date', 'Reference', 'Type', 'Instrument', 'Size', 'Open', 'Close', 'Profit/loss']
|
|
12
|
+
['Date', 'Open Date', 'Reference', 'Type', 'Instrument', 'Size', 'Open', 'Close', 'Profit/loss']
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def right_aligned_columns
|
|
16
|
-
[
|
|
16
|
+
[5, 6, 7, 8]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def row(transaction)
|
|
20
|
-
[transaction.date_utc, transaction.
|
|
21
|
-
transaction.
|
|
22
|
-
Format.level(transaction.close_level),
|
|
20
|
+
[transaction.date_utc, transaction.open_date_utc, transaction.reference,
|
|
21
|
+
formatted_type(transaction.transaction_type), transaction.instrument_name, transaction.size,
|
|
22
|
+
Format.level(transaction.open_level), Format.level(transaction.close_level),
|
|
23
23
|
Format.currency(transaction.profit_and_loss_amount, transaction.currency)]
|
|
24
24
|
end
|
|
25
25
|
|
data/lib/ig_markets/errors.rb
CHANGED
|
@@ -170,6 +170,10 @@ module IGMarkets
|
|
|
170
170
|
class SecurityError < IGMarketsError
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
+
# This error is raised when there is a timeout while retrieving session details.
|
|
174
|
+
class GetSessionTimeoutError < IGMarketsError
|
|
175
|
+
end
|
|
176
|
+
|
|
173
177
|
# This error is raised when the provided user agent string is not valid.
|
|
174
178
|
class InvalidApplicationError < IGMarketsError
|
|
175
179
|
end
|
|
@@ -218,6 +222,10 @@ module IGMarkets
|
|
|
218
222
|
class CannotSetDefaultAccountError < IGMarketsError
|
|
219
223
|
end
|
|
220
224
|
|
|
225
|
+
# This error is raised when the specified instrument data for a share order is invalid.
|
|
226
|
+
class InvalidShareOrderInstrumentDataError < IGMarketsError
|
|
227
|
+
end
|
|
228
|
+
|
|
221
229
|
# This error is raised when an invalid account ID was specified.
|
|
222
230
|
class InvalidAccountIDError < IGMarketsError
|
|
223
231
|
end
|
|
@@ -347,11 +355,14 @@ module IGMarkets
|
|
|
347
355
|
'error.security.client-token-invalid' => Errors::ClientTokenInvalidError,
|
|
348
356
|
'error.security.client-token-missing' => Errors::ClientTokenMissingError,
|
|
349
357
|
'error.security.generic' => Errors::SecurityError,
|
|
358
|
+
'error.security.get.session.timeout' => Errors::GetSessionTimeoutError,
|
|
350
359
|
'error.security.invalid-application' => Errors::InvalidApplicationError,
|
|
351
360
|
'error.security.invalid-details' => Errors::InvalidCredentialsError,
|
|
352
361
|
'error.security.invalid-website' => Errors::InvalidWebsiteError,
|
|
353
362
|
'error.security.oauth-token-invalid' => Errors::OAuthTokenInvalidError,
|
|
354
363
|
'error.security.too-many-failed-attempts' => Errors::TooManyFailedLoginAttemptsError,
|
|
364
|
+
'error.service.create.stockbroking.share-order.instrumentdata-invalid' =>
|
|
365
|
+
Errors::InvalidShareOrderInstrumentDataError,
|
|
355
366
|
'error.service.watchlists.add-instrument.invalid-epic' => Errors::WatchlistInvalidEPICError,
|
|
356
367
|
'error.sprintmarket.create-position.expiry.outside-valid-range' => Errors::SprintMarketPositionInvalidExpiryError,
|
|
357
368
|
'error.sprintmarket.create-position.failure' => Errors::SprintMarketPositionCreateError,
|
|
@@ -370,6 +381,7 @@ module IGMarkets
|
|
|
370
381
|
'invalid.input' => Errors::InvalidInputError,
|
|
371
382
|
'invalid.input.too.many.markets' => Errors::TooManyMarketsError,
|
|
372
383
|
'invalid.url' => Errors::InvalidURLError,
|
|
384
|
+
'service.clientsecurity.error.authentication.failure-generic' => Errors::SecurityError,
|
|
373
385
|
'system.error' => Errors::SystemError,
|
|
374
386
|
'unauthorised.access.to.equity.exception' => Errors::UnauthorisedAccessToEquityError,
|
|
375
387
|
'unauthorised.api-key.revoked' => Errors::APIKeyRevokedError,
|
|
@@ -16,6 +16,12 @@ module IGMarkets
|
|
|
16
16
|
attribute :settlement_info
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# Contains details on the limited risk premium for an instrument. Returned by {#limited_risk_premium}.
|
|
20
|
+
class LimitedRiskPremium < Model
|
|
21
|
+
attribute :unit, Symbol, allowed_values: [:percentage, :points]
|
|
22
|
+
attribute :value, Float
|
|
23
|
+
end
|
|
24
|
+
|
|
19
25
|
# Contains details on the margin deposit requirements for an instrument at a certain price band. Returned by
|
|
20
26
|
# {#margin_deposit_bands}.
|
|
21
27
|
class MarginDepositBand < Model
|
|
@@ -65,6 +71,7 @@ module IGMarkets
|
|
|
65
71
|
attribute :expiry, Date, nil_if: %w(- DFB), format: ['%d-%b-%y', '%b-%y']
|
|
66
72
|
attribute :expiry_details, ExpiryDetails
|
|
67
73
|
attribute :force_open_allowed, Boolean
|
|
74
|
+
attribute :limited_risk_premium, LimitedRiskPremium
|
|
68
75
|
attribute :lot_size, Float
|
|
69
76
|
attribute :margin_deposit_bands, MarginDepositBand
|
|
70
77
|
attribute :margin_factor, Float
|
data/lib/ig_markets/model.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module IGMarkets
|
|
2
2
|
# This class is intended to be subclassed in order to create models that contain a set of attributes, where each
|
|
3
|
-
# attribute is defined by a call to {attribute}. Attributes have standard
|
|
4
|
-
#
|
|
3
|
+
# attribute is defined by a call to {attribute}. Attributes have standard accessor methods and can also be subject to
|
|
4
|
+
# a variety of constraints and validations, see {attribute} for further details.
|
|
5
5
|
class Model
|
|
6
6
|
# The current attribute values set on this model.
|
|
7
7
|
#
|
|
@@ -171,8 +171,12 @@ module IGMarkets
|
|
|
171
171
|
@working_orders.each do |working_order|
|
|
172
172
|
next unless working_order.deal_id == working_order_update.deal_id
|
|
173
173
|
|
|
174
|
-
working_order.
|
|
175
|
-
working_order.
|
|
174
|
+
working_order.currency_code = working_order_update.currency
|
|
175
|
+
working_order.order_level = working_order_update.level
|
|
176
|
+
|
|
177
|
+
%i(good_till_date limit_distance order_type stop_distance time_in_force).each do |attribute|
|
|
178
|
+
working_order.send "#{attribute}=", working_order_update.send(attribute)
|
|
179
|
+
end
|
|
176
180
|
end
|
|
177
181
|
end
|
|
178
182
|
|
|
@@ -5,18 +5,22 @@ module IGMarkets
|
|
|
5
5
|
class WorkingOrderUpdate < Model
|
|
6
6
|
attribute :account_id
|
|
7
7
|
attribute :channel
|
|
8
|
+
attribute :currency, String, regex: Regex::CURRENCY
|
|
8
9
|
attribute :deal_id
|
|
9
10
|
attribute :deal_reference
|
|
10
11
|
attribute :deal_status, Symbol, allowed_values: [:accepted, :rejected]
|
|
11
12
|
attribute :direction, Symbol, allowed_values: [:buy, :sell]
|
|
12
13
|
attribute :epic, String, regex: Regex::EPIC
|
|
13
14
|
attribute :expiry, Date, nil_if: %w(- DFB), format: ['%d-%b-%y', '%b-%y']
|
|
15
|
+
attribute :good_till_date, Time, format: '%FT%T'
|
|
14
16
|
attribute :guaranteed_stop, Boolean
|
|
15
17
|
attribute :level, Float
|
|
16
18
|
attribute :limit_distance, Integer
|
|
19
|
+
attribute :order_type, Symbol, allowed_values: [:limit, :stop]
|
|
17
20
|
attribute :size, Float
|
|
18
21
|
attribute :status, Symbol, allowed_values: [:deleted, :open, :updated]
|
|
19
22
|
attribute :stop_distance, Integer
|
|
23
|
+
attribute :time_in_force, Symbol, allowed_values: [:good_till_cancelled, :good_till_date]
|
|
20
24
|
attribute :timestamp, Time, format: '%FT%T.%L'
|
|
21
25
|
end
|
|
22
26
|
end
|
|
@@ -7,6 +7,7 @@ module IGMarkets
|
|
|
7
7
|
attribute :currency
|
|
8
8
|
attribute :date_utc, Time, format: '%FT%T'
|
|
9
9
|
attribute :instrument_name
|
|
10
|
+
attribute :open_date_utc, Time, format: '%FT%T'
|
|
10
11
|
attribute :open_level, String, nil_if: %w(- 0)
|
|
11
12
|
attribute :period, Time, nil_if: %w(- DFB), format: ['%FT%T', '%d-%b-%y', '%b-%y']
|
|
12
13
|
attribute :profit_and_loss
|
data/lib/ig_markets/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ig_markets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.28'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Viney
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: colorize
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: 0.10.4
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rainbow
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 2.1.0
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 2.1.0
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: terminal-table
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|