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<Activity>
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(days) ⇒ Array<Activity>
Returns all account activities that occurred in the most recent specified number of days.
-
#recent_transactions(days, transaction_type = :all) ⇒ Array<Transaction>
Returns all transactions that occurred in the last specified number of days.
-
#transactions_in_date_range(from_date, to_date, transaction_type = :all) ⇒ Array<Transaction>
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<Activity>
Returns all account activities that occurred in the specified date range.
27 28 29 30 31 32 33 34 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 27 def activities_in_date_range(from_date, to_date) from_date = format_date from_date to_date = format_date to_date result = @dealing_platform.session.get("history/activity/#{from_date}/#{to_date}").fetch :activities @dealing_platform.instantiate_models Activity, result end |
#all ⇒ Array<Account>
Returns all accounts associated with the current IG Markets login.
15 16 17 18 19 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 15 def all result = @dealing_platform.session.get('accounts').fetch :accounts @dealing_platform.instantiate_models Account, result end |
#recent_activities(days) ⇒ Array<Activity>
Returns all account activities that occurred in the most recent specified number of days.
41 42 43 44 45 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 41 def recent_activities(days) result = @dealing_platform.session.get("history/activity/#{milliseconds(days)}").fetch :activities @dealing_platform.instantiate_models Activity, result end |
#recent_transactions(days, transaction_type = :all) ⇒ Array<Transaction>
Returns all transactions that occurred in the last specified number of days.
72 73 74 75 76 77 78 79 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 72 def recent_transactions(days, transaction_type = :all) validate_transaction_type transaction_type url = "history/transactions/#{transaction_type.to_s.upcase}/#{milliseconds(days)}" result = @dealing_platform.session.get(url).fetch :transactions @dealing_platform.instantiate_models Transaction, result end |
#transactions_in_date_range(from_date, to_date, transaction_type = :all) ⇒ Array<Transaction>
Returns all transactions that occurred in the specified date range.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 54 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}" result = @dealing_platform.session.get(url).fetch :transactions @dealing_platform.instantiate_models Transaction, result end |