Class: IGMarkets::DealingPlatform::AccountMethods

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(dealing_platform) ⇒ AccountMethods

Initializes this helper class with the specified dealing platform.

Parameters:



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.

Parameters:

  • from_date (Date)

    The start date of the desired date range.

  • to_date (Date)

    The end date of the desired date range.

Returns:



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

#allArray<Account>

Returns all accounts associated with the current IG Markets login.

Returns:



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(days) ⇒ Array<AccountActivity>

Returns all account activities that occurred in the most recent specified number of days.

Parameters:

  • days (Fixnum, Float)

    The number of days to return recent activities for.

Returns:



37
38
39
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 37

def recent_activities(days)
  @dealing_platform.gather "history/activity/#{milliseconds(days)}", :activities, AccountActivity
end

#recent_transactions(days, transaction_type = :all) ⇒ Array<AccountTransaction>

Returns all transactions that occurred in the last specified number of days.

Parameters:

  • days (Fixnum, Float)

    The number of days to return recent transactions for.

  • transaction_type (:all, :all_deal, :deposit, :withdrawal) (defaults to: :all)

    The type of transactions to return.

Returns:



65
66
67
68
69
70
71
# File 'lib/ig_markets/dealing_platform/account_methods.rb', line 65

def recent_transactions(days, transaction_type = :all)
  validate_transaction_type transaction_type

  url = "history/transactions/#{transaction_type.to_s.upcase}/#{milliseconds(days)}"

  @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.

Parameters:

  • from_date (Date)

    The start date of the desired date range.

  • to_date (Date)

    The end date of the desired date range.

  • transaction_type (:all, :all_deal, :deposit, :withdrawal) (defaults to: :all)

    The type of transactions to return.

Returns:



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