Class: IGMarkets::DealingPlatform::AccountMethods
- Inherits:
-
Object
- Object
- IGMarkets::DealingPlatform::AccountMethods
- Defined in:
- lib/ig_markets/dealing_platform/account_methods.rb
Overview
Provides methods for working with the logged in account. Returned by #account.
Instance Method Summary collapse
-
#activities_in_date_range(from_date, to_date) ⇒ Array<AccountActivity>
Returns all account activities that occurred in the specified date range.
-
#all ⇒ Array<Account>
Returns all accounts associated with the current IG Markets login.
-
#initialize(dealing_platform) ⇒ AccountMethods
constructor
Initializes this helper class with the specified dealing platform.
-
#recent_activities(seconds) ⇒ Array<AccountActivity>
Returns all account activities that occurred in the most recent specified number of seconds.
-
#recent_transactions(seconds, transaction_type = :all) ⇒ Array<AccountTransaction>
Returns all transactions that occurred in the last specified number of seconds.
-
#transactions_in_date_range(from_date, to_date, transaction_type = :all) ⇒ Array<AccountTransaction>
Returns all transactions that occurred in the specified date range.
Constructor Details
#initialize(dealing_platform) ⇒ AccountMethods
Initializes this helper class with the specified dealing platform.
8 9 10 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 8 def initialize(dealing_platform) @dealing_platform = dealing_platform end |
Instance Method Details
#activities_in_date_range(from_date, to_date) ⇒ Array<AccountActivity>
Returns all account activities that occurred in the specified date range.
25 26 27 28 29 30 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 25 def activities_in_date_range(from_date, to_date) from_date = format_date from_date to_date = format_date to_date @dealing_platform.gather "history/activity/#{from_date}/#{to_date}", :activities, AccountActivity end |
#all ⇒ Array<Account>
Returns all accounts associated with the current IG Markets login.
15 16 17 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 15 def all @dealing_platform.gather 'accounts', :accounts, Account end |
#recent_activities(seconds) ⇒ Array<AccountActivity>
Returns all account activities that occurred in the most recent specified number of seconds.
37 38 39 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 37 def recent_activities(seconds) @dealing_platform.gather "history/activity/#{(seconds * 1000.0).to_i}", :activities, AccountActivity end |
#recent_transactions(seconds, transaction_type = :all) ⇒ Array<AccountTransaction>
Returns all transactions that occurred in the last specified number of seconds.
65 66 67 68 69 70 71 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 65 def recent_transactions(seconds, transaction_type = :all) validate_transaction_type transaction_type url = "history/transactions/#{transaction_type.to_s.upcase}/#{(seconds * 1000.0).to_i}" @dealing_platform.gather url, :transactions, AccountTransaction end |
#transactions_in_date_range(from_date, to_date, transaction_type = :all) ⇒ Array<AccountTransaction>
Returns all transactions that occurred in the specified date range.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 48 def transactions_in_date_range(from_date, to_date, transaction_type = :all) validate_transaction_type transaction_type from_date = format_date from_date to_date = format_date to_date url = "history/transactions/#{transaction_type.to_s.upcase}/#{from_date}/#{to_date}" @dealing_platform.gather url, :transactions, AccountTransaction end |