Module: QuestradeClient::Account

Included in:
Client
Defined in:
lib/questrade_client/account.rb

Instance Method Summary collapse

Instance Method Details

#accountsArray[Hash]

Retrieves the accounts associated with the user on behalf of which the API client is authorized.

Docs: www.questrade.com/api/documentation/rest-operations/account-calls/accounts

Examples:

client.accounts

Returns:

  • (Array[Hash])

    List of accounts



22
23
24
# File 'lib/questrade_client/account.rb', line 22

def accounts
  get('/accounts')['accounts']
end

#activities(id) ⇒ Array[Hash]

Retrieve account activities, including cash transactions, dividends, trades, etc.

Docs: www.questrade.com/api/documentation/rest-operations/account-calls/accounts-id-activities

FIXME: Add support for start and end time

Examples:

client.activities(id)

Parameters:

  • id (String)

    The ID of the account

  • orderid (String)

    Only retrieve the order matching the specified order ID (optional)

Returns:

  • (Array[Hash])

    List of orders



88
89
90
# File 'lib/questrade_client/account.rb', line 88

def activities(id)
  get("/accounts/#{id}/activities")['activities']
end

#balances(id) ⇒ Hash

Retrieves per-currency and combined balances for a specified account.

Docs: www.questrade.com/api/documentation/rest-operations/account-calls/accounts-id-balances

Examples:

client.balances(id)

Parameters:

  • id (String)

    The ID of the account

Returns:

  • (Hash)

    Balance data for this account



46
47
48
# File 'lib/questrade_client/account.rb', line 46

def balances(id)
  get("/accounts/#{id}/balances")
end

#executions(id) ⇒ Array[Hash]

Retrieves executions for a specific account.

Docs: www.questrade.com/api/documentation/rest-operations/account-calls/accounts-id-executions

FIXME: Add support for start and end time

Examples:

client.executions(id)

Parameters:

  • id (String)

    The ID of the account

Returns:

  • (Array[Hash])

    List of executions



59
60
61
# File 'lib/questrade_client/account.rb', line 59

def executions(id)
  get("/accounts/#{id}/executions")['executions']
end

#orders(id, orderid = nil) ⇒ Array[Hash]

Retrieves orders for specified account

Docs: www.questrade.com/api/documentation/rest-operations/account-calls/accounts-id-orders

FIXME: Add support for start and end time FIXME: Add support for statefilter

Examples:

client.orders(id)

Parameters:

  • id (String)

    The ID of the account

  • orderid (String) (defaults to: nil)

    Only retrieve the order matching the specified order ID (optional)

Returns:

  • (Array[Hash])

    List of orders



74
75
76
# File 'lib/questrade_client/account.rb', line 74

def orders(id, orderid = nil)
  get("/accounts/#{id}/orders#{orderid ? "/#{orderid}" : ''}")['orders']
end

#positions(id) ⇒ Array[Hash]

Examples:

client.positions(id)

Parameters:

  • id (String)

    The ID of the account

Returns:

  • (Array[Hash])

    List of positions for the account



34
35
36
# File 'lib/questrade_client/account.rb', line 34

def positions(id)
  get("/accounts/#{id}/positions")['positions']
end

#timeDateTime

Examples:

client.time

Returns:

  • (DateTime)

    Current server time in ISO format and Eastern time zone.



11
12
13
# File 'lib/questrade_client/account.rb', line 11

def time
   DateTime.parse(get('/time')['time'])
end