Module: Tradier::API::Accounts

Includes:
Utils
Included in:
Client
Defined in:
lib/tradier/api/accounts.rb

Instance Method Summary collapse

Instance Method Details

#balancesArray<Tradier::Balance> #balances(account_number) ⇒ Tradier::Balance Also known as: balance

Overloads:

  • #balancesArray<Tradier::Balance>

    Request a user's balances.

    Returns:

  • #balances(account_number) ⇒ Tradier::Balance

    Request an individual account's balance.

    Parameters:

    • account_number (String)

      An account number.

    Returns:

    • (Tradier::Balance)

      The account balance object when a single account is requested.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



30
31
32
33
34
35
36
# File 'lib/tradier/api/accounts.rb', line 30

def balances(=nil, options={})
  if 
    object_from_response(Tradier::Balance, :get, "/accounts/#{}/balances", options)
  else
    object_from_response(Tradier::API::Utils::Balance, :get, "/user/balances", options).body
  end
end

#eventsArray<Tradier::Account> #events(account_number) ⇒ Array<Tradier::Event> #events(account_number, options) ⇒ Object Also known as: history

Overloads:

  • #eventsArray<Tradier::Account>

    Request a user's events.

    Returns:

  • #events(account_number) ⇒ Array<Tradier::Event>

    Request a specific account's events.

    Parameters:

    • account_number (String)

      An account number (optional).

    Returns:

    • (Array<Tradier::Event>)

      An array of [Tradier::Event] objects for a given account.

  • #events(account_number, options) ⇒ Object

    Options Hash (options):

    • :limit (Integer)

      Indicate the number of events to return for pagination.

    • ;offset (Integer)

      Indicate the offset of results to return for pagination.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



115
116
117
118
119
120
121
# File 'lib/tradier/api/accounts.rb', line 115

def events(=nil, options={})
  if 
    object_from_response(Tradier::API::Utils::Event, :get, "/accounts/#{}/history", options).body
  else
    object_from_response(Tradier::API::Utils::Account, :get, '/user/history', options).body
  end
end

#gainlossArray<Tradier::Account> #gainloss(account_number) ⇒ Array<Tradier::Position>

Overloads:

  • #gainlossArray<Tradier::Account>

    Request a user's cost basis.

    Returns:

  • #gainloss(account_number) ⇒ Array<Tradier::Position>

    Request a specific account's cost basis.

    Parameters:

    • account_number (String)

      An account number (optional).

    Returns:

    • (Array<Tradier::Position>)

      An array of [Tradier::Position] objects for a given account.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



92
93
94
95
96
97
98
# File 'lib/tradier/api/accounts.rb', line 92

def gainloss(=nil, options={})
  if 
    object_from_response(Tradier::API::Utils::Gainloss, :get, "/accounts/#{}/gainloss", options).body
  else
    object_from_response(Tradier::API::Utils::Account, :get, '/user/gainloss', options).body
  end
end

#ordersArray<Tradier::Account> #orders(account_number) ⇒ Array<Tradier::Order>

Overloads:

  • #ordersArray<Tradier::Account>

    Request a user's orders.

    Returns:

  • #orders(account_number) ⇒ Array<Tradier::Order>

    Request a specific account's orders.

    Parameters:

    • account_number (String)

      An account number (optional).

    Returns:

    • (Array<Tradier::Order>)

      An array of [Tradier::Order] objects for a given account.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



72
73
74
75
76
77
78
# File 'lib/tradier/api/accounts.rb', line 72

def orders(=nil, options={})
  if 
    object_from_response(Tradier::API::Utils::Order, :get, "/accounts/#{}/orders", options).body
  else
    object_from_response(Tradier::API::Utils::Account, :get, '/user/orders', options).body
  end
end

#positionsArray<Tradier::Account> #positions(account_number) ⇒ Array<Tradier::Position> Also known as: position

Overloads:

  • #positionsArray<Tradier::Account>

    Request a user's positions.

    Returns:

  • #positions(account_number) ⇒ Array<Tradier::Position>

    Request an individual account's positions.

    Parameters:

    • account_number (String)

      An account number.

    Returns:

    • (Array<Tradier::Position>)

      An array of [Tradier::Position] objects for a given account.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



51
52
53
54
55
56
57
# File 'lib/tradier/api/accounts.rb', line 51

def positions(=nil, options={})
  if 
    object_from_response(Tradier::API::Utils::Position, :get, "/accounts/#{}/positions", options).body
  else
    object_from_response(Tradier::API::Utils::Account, :get, '/user/positions', options).body
  end
end

#profileTradier::Profile Also known as: user_profile

Returns The user's profile.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



13
14
15
# File 'lib/tradier/api/accounts.rb', line 13

def profile
  object_from_response(Tradier::Profile, :get, '/user/profile', {})
end