Ally Object

class ally.Ally(params=None, timeout: float = 1.0)

The ally.Ally.Ally class.

This is the main class for this library.

__init__(params=None, timeout: float = 1.0)

Manages all facets of your Ally Invest account.

Manage your account

Track the current and past state of your account. Visit the Account page for full details.

  • Balances (gets all current cash and margin balances)

  • History (gets full history of all trades, dividends, and cash transfers of the account)

  • Holdings (gets list of all currently-held non-cash positions, and profitability information)

Get quotes

Specified in-detail in Quotes. Supports 3 types of quote-gathering:

  • Real-time quotes

  • Timesales (historical intraday prices over rolling 5 day window)

  • Quote Streaming (get quotes for up to 256 symbols in real-time, as prices update)

Place trades

Trades can be placed, modified (after being created locally, and even after submitting), or cancelled. Order objects described in Trading in detail.

  • timeout (float) – number of seconds to wait before failing unresponsive api call

  • params

    provide keys in the form of:

    1. A dictionary: { ALLY_OAUTH_SECRET: …}

    2. A string: (filename to json file containing api keys)

    3. None (default): Grab the api keys from environment variables

    For any of the mediums above, be sure to provide all of the keys:

    params = {
        'ALLY_OAUTH_SECRET': ...,
        'ALLY_OAUTH_TOKEN': ...,
        'ALLY_CONSUMER_SECRET': ...,
        'ALLY_CONSUMER_KEY': ...,
        'ALLY_ACCOUNT_NBR': ...