Skip to main content

finance-dev

Developer-friendly & type-safe Python SDK specifically catered to leverage finance-dev API.



Summary

Aries API — OpenAPI Specification: OpenAPI Specification for the Aries trading platform API.

Authentication

Learn how to authenticate with the Aries API using OAuth2 and manage access tokens in your SDK.

Overview

The Aries API uses OAuth2 with Bearer tokens (JWT format) for authentication. All API requests require a valid access token in the Authorization header:

Authorization: Bearer <access_token>

Providing Client ID and Client Secret (SDK)

When using the generated SDK, provide your Client ID and Client Secret when you create the API client (e.g. in the constructor or security options). The SDK will use these to obtain and refresh the access token internally; you do not need to manage tokens yourself.

Obtain your OAuth2 credentials from the Aries platform (e.g. Client Center / Manage Account at https://app.aries.com):

  • Client ID – Your application identifier (pass to SDK client)
  • Client Secret – Your application secret key (pass to SDK client; use PKCE for public clients where secret cannot be stored)

Authentication Flow

1. Authorization Code Flow

For server-side or confidential clients:

  1. Redirect the user to the authorization URL to sign in and consent:
  • URL: https://app.aries.com/oauth2/authorize
  • Query params: response_type=code, client_id, redirect_uri, scope, state
  1. Exchange the code for tokens (after user is redirected back with ?code=.):
  • POST https://api.aries.com/v1/oauth2/token
  • Body: grant_type=authorization_code, code, redirect_uri, client_id, client_secret
  • Response includes access_token and refresh_token
  1. Call the API with the access token: Authorization: Bearer <access_token>

2. PKCE Flow

For SPAs and mobile apps (public clients that cannot store client_secret):

  1. Generate a code_verifier (random string) and code_challenge = BASE64URL(SHA256(code_verifier)).
  2. Redirect the user to https://app.aries.com/oauth2/authorize with code_challenge, code_challenge_method=S256, plus client_id, redirect_uri, scope, state.
  3. Exchange the code at POST https://api.aries.com/v1/oauth2/token with grant_type=authorization_code, code, redirect_uri, client_id, code_verifier (no client_secret).
  4. Use the returned access_token as Bearer.

3. MFA Verification

If the user has MFA enabled, the authorize step may return is_mfa: true and a next_step_auth_id. Call POST https://api.aries.com/v1/oauth2/authorize/mfa with next_step_auth_id and verification_code (6-digit code). Then continue with POST /v1/oauth2/authorize/confirm to get the authorization code, and exchange it at /v1/oauth2/token.

Token Management

  • Refresh when expired: POST https://api.aries.com/v1/oauth2/token with grant_type=refresh_token, client_id, client_secret, refresh_token.
  • Using a Bearer token directly: If you already have an access token, set the header Authorization: Bearer <access_token> on every request. The SDK can accept a pre-obtained token and use it until it expires.

OAuth2 Scopes

Request only the scopes your application needs. Available scopes:

Scope Description
user:information View user profile and personal details
watchlist:information View your watchlists and their symbols
watchlist:management Create, update, replace, and delete your watchlists
account:information View account balances, positions, and transaction history
order:execution Place, modify, and cancel orders
order:information View order history and status
position:information View current positions and holdings
market:information Access live and historical market data
calendar:information Access earnings, economic, and market schedule data
options:information Access options chains and expiration data
analytics:information View analytics, ratings, and market insights
market:supplemental News, company profiles, financials, filings, ETF data, technical analysis

Specify multiple scopes as a space-separated string, e.g. account:information order:execution market:information.

Security Best Practices

  • Store credentials securely – Use environment variables or a secrets manager for client_id and client_secret. Never hardcode them.
  • Handle token expiration – Check for 401 responses and refresh the token using the refresh_token, then retry the request.
  • Use HTTPS – All authorization and token endpoints must be called over HTTPS.
  • Validate state – When using the authorization code flow, validate the state parameter on the callback to prevent CSRF.

Error Handling

  • 400 Bad Request – Invalid or missing parameters, validation failures, or malformed JSON. Response bodies follow the same patterns as other errors (flat error string, optional codes, nested error object, or rarely no body).

  • 401 Unauthorized – Invalid or expired access token; refresh the token or re-authenticate. JSON bodies are not identical on every route: you may see a flat error string (sometimes with codes), a nested error object (type, code, message), or rarely an empty body

  • 403 Forbidden – Insufficient scope or permissions for the requested resource. Error JSON may be flat or nested, like 400/401.

  • 404 Not Found – Resource does not exist or is not visible. Error JSON may be flat or nested.

  • 500 / 5xx – Server or upstream failure; retry with backoff. Do not depend on a single error JSON shape; some responses may have no body.


Endpoints in this spec: health, OAuth2 (authorize, confirm, mfa, token), users, accounts, orders, market data, watchlist, chart, analytics, calendars, company, economy, financials, indices, options, news, and supplemental data.

Table of Contents

SDK Installation

The SDK can be installed with uv, pip, or poetry package managers.

uv

uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.

uv add finance_dev

PIP

PIP is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.

pip install finance_dev

Poetry

Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.

poetry add finance_dev

Shell and script usage with uv

You can use this SDK in a Python shell with uv and the uvx command that comes with it like so:

uvx --from finance_dev python

It's also possible to write a standalone Python script without needing to set up a whole project like so:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "finance_dev",
# ]
# ///

from finance_dev import FinanceDev

sdk = FinanceDev(
  # SDK arguments
)

# Rest of script here...

Once that is saved to a file, you can run it with uv run script.py where script.py can be replaced with the actual file name.

IDE Support

PyCharm

Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.

SDK Example Usage

Example

# Synchronous Example
from finance_dev import FinanceDev, models


with FinanceDev(
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:

    res = fd_client.accounts.get_positions(id="TEST-ACCOUNT-001")

    assert res.get_positions_response is not None

    # Handle response
    print(res.get_positions_response)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from finance_dev import FinanceDev, models

async def main():

    async with FinanceDev(
        security=models.Security(
            client_id="<YOUR_CLIENT_ID_HERE>",
            client_secret="<YOUR_CLIENT_SECRET_HERE>",
        ),
    ) as fd_client:

        res = await fd_client.accounts.get_positions_async(id="TEST-ACCOUNT-001")

        assert res.get_positions_response is not None

        # Handle response
        print(res.get_positions_response)

asyncio.run(main())

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
client_id
client_secret
token_url
oauth2 OAuth2 Client Credentials Flow

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

from finance_dev import FinanceDev, models


with FinanceDev(
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:

    res = fd_client.accounts.get_positions(id="TEST-ACCOUNT-001")

    assert res.get_positions_response is not None

    # Handle response
    print(res.get_positions_response)

Available Resources and Operations

Available methods

Accounts

Accounts.Orders

Analytics

Analytics.TopMostActive

  • list - Get Most Active Stocks

Calendars

Chart

Companies

Company

CorporateActions

Economy

Etf

Etfs

Filings

Financials

Financials.CashFlowStatements

  • get - Get Cash Flow Statements

Indices

Logos

  • search - Search Company Logos
  • sync - Sync Company Logos

Market

Market.Equities

MarketData

News

Options

Orders

Ownership

PredictionHistoricalData

  • get - Get historical ticks for a single symbol

PredictionMarketCategories

  • list - List prediction market categories

PredictionMarkets

PredictionOrders

  • create - Place prediction order
  • get - Get prediction order

Predictions

  • batch_get - Batch historical ticks for up to 5 symbols
  • list_orders - List current prediction orders

Predictions.Markets

  • get_election_map - Get every race of an election cycle with its candidates' prices

Predictions.Orders

PredictionsMarkets

  • search - Search contracts, events or base events

Signals

StockAlternative

StockAlternatives

StockEstimates

Stocks

TechnicalAnalysis

Users

Users.Accounts

  • list - Get User Accounts

Watchlists

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will have a Next method that can be called to pull down the next group of results. If the return value of Next is None, then there are no more pages to be fetched.

Here's an example of one such pagination call:

from finance_dev import FinanceDev, models


with FinanceDev(
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:

    res = fd_client.accounts.orders.list_active(id="TEST-ACCOUNT-001", limit=50, cursor=0)

    while res is not None:
        # Handle items

        res = res.next()

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:

from finance_dev import FinanceDev, models
from finance_dev.utils import BackoffStrategy, RetryConfig


with FinanceDev(
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:

    res = fd_client.accounts.get_positions(id="TEST-ACCOUNT-001",
        RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))

    assert res.get_positions_response is not None

    # Handle response
    print(res.get_positions_response)

If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:

from finance_dev import FinanceDev, models
from finance_dev.utils import BackoffStrategy, RetryConfig


with FinanceDev(
    retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:

    res = fd_client.accounts.get_positions(id="TEST-ACCOUNT-001")

    assert res.get_positions_response is not None

    # Handle response
    print(res.get_positions_response)

Error Handling

FinanceDevAPIError is the base class for all HTTP error responses. It has the following properties:

Property Type Description
err.message str Error message
err.status_code int HTTP response status code eg 404
err.headers httpx.Headers HTTP response headers
err.body str HTTP body. Can be empty string if no body is returned.
err.raw_response httpx.Response Raw HTTP response
err.data Optional. Some errors may contain structured data. See Error Classes.

Example

from finance_dev import FinanceDev, errors, models


with FinanceDev(
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:
    res = None
    try:

        res = fd_client.accounts.get_positions(id="TEST-ACCOUNT-001")

        assert res.get_positions_response is not None

        # Handle response
        print(res.get_positions_response)


    except errors.FinanceDevAPIError as e:
        # The base class for HTTP error responses
        print(e.message)
        print(e.status_code)
        print(e.body)
        print(e.headers)
        print(e.raw_response)

        # Depending on the method different errors may be thrown
        if isinstance(e, errors.AuthenticationErrorEnvelope):
            print(e.data.error)  # Optional[models.AuthenticationErrorDetail]
            print(e.data.meta)  # Optional[Dict[str, Any]]
            print(e.data.http_meta)  # models.HTTPMetadata

Error Classes

Primary errors:

  • FinanceDevAPIError: The base class for HTTP error responses.
    • ErrorResponse: Flat error body: an error string, with optional structured codes and additional metadata. *
    • AuthenticationErrorEnvelope: JSON envelope where error is a nested object (type, code, message, …). Many services use this shape for 400, 401, 403, 404, and 5xx when using the shared HTTP error format. *
Less common errors (7)

Network errors:

Inherit from FinanceDevAPIError:

  • PredOrdersErrorEnvelope: Invalid request. INVALID_ORDER carries the reason in message; on placement this includes refusals from order entry and the venue (price, tick size, account setup). Applicable to 9 of 159 methods.*
  • ErrorEnvelope: Prediction-market error envelope. Returned by historical-data and prediction-market reference endpoints on 400/404/500/502. Applicable to 7 of 159 methods.*
  • ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the cause attribute.

* Check the method documentation to see if the error is applicable.

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:

from finance_dev import FinanceDev, models


with FinanceDev(
    server_url="https://api.aries.com",
    security=models.Security(
        client_id="<YOUR_CLIENT_ID_HERE>",
        client_secret="<YOUR_CLIENT_SECRET_HERE>",
    ),
) as fd_client:

    res = fd_client.accounts.get_positions(id="TEST-ACCOUNT-001")

    assert res.get_positions_response is not None

    # Handle response
    print(res.get_positions_response)

Custom HTTP Client

The Python SDK makes API calls using the httpx HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance. Depending on whether you are using the sync or async version of the SDK, you can pass an instance of HttpClient or AsyncHttpClient respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls. This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of httpx.Client or httpx.AsyncClient directly.

For example, you could specify a header for every request that this sdk makes as follows:

from finance_dev import FinanceDev
import httpx

http_client = httpx.Client(headers={"x-custom-header": "someValue"})
s = FinanceDev(client=http_client)

or you could wrap the client with your own custom logic:

from finance_dev import FinanceDev
from finance_dev.httpclient import AsyncHttpClient
import httpx

class CustomClient(AsyncHttpClient):
    client: AsyncHttpClient

    def __init__(self, client: AsyncHttpClient):
        self.client = client

    async def send(
        self,
        request: httpx.Request,
        *,
        stream: bool = False,
        auth: Union[
            httpx._types.AuthTypes, httpx._client.UseClientDefault, None
        ] = httpx.USE_CLIENT_DEFAULT,
        follow_redirects: Union[
            bool, httpx._client.UseClientDefault
        ] = httpx.USE_CLIENT_DEFAULT,
    ) -> httpx.Response:
        request.headers["Client-Level-Header"] = "added by client"

        return await self.client.send(
            request, stream=stream, auth=auth, follow_redirects=follow_redirects
        )

    def build_request(
        self,
        method: str,
        url: httpx._types.URLTypes,
        *,
        content: Optional[httpx._types.RequestContent] = None,
        data: Optional[httpx._types.RequestData] = None,
        files: Optional[httpx._types.RequestFiles] = None,
        json: Optional[Any] = None,
        params: Optional[httpx._types.QueryParamTypes] = None,
        headers: Optional[httpx._types.HeaderTypes] = None,
        cookies: Optional[httpx._types.CookieTypes] = None,
        timeout: Union[
            httpx._types.TimeoutTypes, httpx._client.UseClientDefault
        ] = httpx.USE_CLIENT_DEFAULT,
        extensions: Optional[httpx._types.RequestExtensions] = None,
    ) -> httpx.Request:
        return self.client.build_request(
            method,
            url,
            content=content,
            data=data,
            files=files,
            json=json,
            params=params,
            headers=headers,
            cookies=cookies,
            timeout=timeout,
            extensions=extensions,
        )

s = FinanceDev(async_client=CustomClient(httpx.AsyncClient()))

httpx2 (Pydantic's httpx fork)

httpx2 is Pydantic's maintained fork of httpx. To run this SDK on httpx2, call alias_httpx() at your program's entry point, before importing the SDK, so every import httpx — including the ones inside the SDK — resolves to httpx2:

import httpx2

httpx2.alias_httpx()

from finance_dev import FinanceDev

s = FinanceDev()

An SDK can also be generated against httpx2 directly, so it depends on the fork instead of httpx, by setting python.httpClientLibrary: httpx2 in gen.yaml.

Resource Management

The FinanceDev class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a context manager and reuse it across the application.

from finance_dev import FinanceDev, models
def main():

    with FinanceDev(
        security=models.Security(
            client_id="<YOUR_CLIENT_ID_HERE>",
            client_secret="<YOUR_CLIENT_SECRET_HERE>",
        ),
    ) as fd_client:
        # Rest of application here...


# Or when using async:
async def amain():

    async with FinanceDev(
        security=models.Security(
            client_id="<YOUR_CLIENT_ID_HERE>",
            client_secret="<YOUR_CLIENT_SECRET_HERE>",
        ),
    ) as fd_client:
        # Rest of application here...

Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass your own logger class directly into your SDK.

from finance_dev import FinanceDev
import logging

logging.basicConfig(level=logging.DEBUG)
s = FinanceDev(debug_logger=logging.getLogger("finance_dev"))

WebSocket streaming

FinanceDev exposes market, chart, and account WebSocket clients under sdk.websocket. Connections authenticate on entry and support both sync and async context managers. See the WebSocket guide for examples, token providers, event semantics, and reconnect behavior.

Market field selectors use "*" for all fields. To combine Time & Sales with quotes and trades, set time_and_sales=True, quote_fields="*", and trade_fields="*"; Time & Sales alone selects only that stream.

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

Metadata

Release files for finance_dev 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for finance_dev 0.10.0
File Size Uploaded Provenance Actions
finance_dev-0.10.0.tar.gz 465.6 kB Without provenance Details for finance_dev-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for finance_dev 0.10.0
File Interpreter ABI Platform Actions
finance_dev-0.10.0-py3-none-any.whl Python 3 none any Details for finance_dev-0.10.0-py3-none-any.whl

Total release size: 1.3 MB

Release files / finance_dev-0.10.0.tar.gz

Download URL finance_dev-0.10.0.tar.gz
Size 465.6 kB
Tags Source
SHA-256 checksum
How to use checksums
318985fcdeadeca87b68822e8950c98b4120c9f4f8d85504cc2d1767bcc8b3da
BLAKE2b-256 checksum
How to use checksums
32e9d20733e7962cb4f4cffeb05261974fdfac221478c6ffcc1ad2973231679e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / finance_dev-0.10.0-py3-none-any.whl

Download URL finance_dev-0.10.0-py3-none-any.whl
Size 799.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c14282637394d55ed82153f68114891ac2ec3f21b2bb33b4ce3af65cc622b146
BLAKE2b-256 checksum
How to use checksums
cf48b239166d51dfd13da441a2cb321b6bf1b28810061ffb10d03f03e77d06e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for finance_dev 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page