Skip to main content

Agent-side trading SDK for Alpaca execution and Bridgewood reporting.

Project description

oneworldtrade

oneworldtrade is the agent-side trading SDK that executes orders through a broker and reliably reports resulting fills to Bridgewood.

It exists for one specific reason: trading agents should not have to be infrastructure engineers.

What It Does

oneworldtrade sits between your strategy code and the external systems:

agent -> oneworldtrade -> Alpaca + Bridgewood

The agent decides what to trade.

oneworldtrade handles:

  • speaking Alpaca correctly
  • waiting for a final fill outcome
  • normalizing the resulting execution
  • reporting the completed fill to Bridgewood
  • retrying Bridgewood reporting safely
  • returning a structured result object instead of a vague success boolean

What It Does Not Do

This package is intentionally narrow.

It is not:

  • a strategy framework
  • a scheduler
  • a bot runner
  • a portfolio analytics suite
  • a replacement for Bridgewood
  • a replacement for Alpaca

In v1 it only supports:

  • Alpaca equities
  • Bridgewood agent-side reporting
  • fully filled orders only
  • synchronous workflows

Bridgewood is treated as an external dependency. oneworldtrade does not provision Bridgewood accounts or agents and only uses an existing BRIDGEWOOD_AGENT_API_KEY.

Install

pip install oneworldtrade

For local development:

python -m venv .venv
./.venv/bin/pip install -e ".[dev]"

Environment

Trader.from_env() reads from the ambient process environment provided by the agent runtime, shell, container, or deployment platform. oneworldtrade does not auto-load a local .env file.

Minimum environment:

ALPACA_API_KEY=...
ALPACA_SECRET_KEY=...
BRIDGEWOOD_AGENT_API_KEY=bgw_...

Optional:

ONEWORLDTRADE_ALPACA_PAPER=true
BRIDGEWOOD_API_BASE=https://bridgewood.onrender.com/v1
ONEWORLDTRADE_POLL_INTERVAL_SECONDS=2
ONEWORLDTRADE_FILL_TIMEOUT_SECONDS=120
ONEWORLDTRADE_HTTP_TIMEOUT_SECONDS=15
ONEWORLDTRADE_REPORT_MAX_ATTEMPTS=3
ONEWORLDTRADE_REPORT_BACKOFF_SECONDS=1
ONEWORLDTRADE_LOG_LEVEL=INFO

If you want .env loading in your own agent repo, do that at the application layer before constructing Trader.

Quick Start

from oneworldtrade import Trader

trader = Trader.from_env()

result = trader.buy("AAPL", qty=1)

if result.report_succeeded:
    print("Filled and reported to Bridgewood")
elif result.filled:
    print("Filled at broker, but Bridgewood reporting needs attention")
else:
    print(f"Order status: {result.broker_status}")

Advanced Usage

from decimal import Decimal

from oneworldtrade import OrderType, TimeInForce, Trader

trader = Trader.from_env()

result = trader.place_order(
    symbol="AAPL",
    side="buy",
    qty=Decimal("2"),
    order_type=OrderType.LIMIT,
    limit_price=Decimal("180"),
    time_in_force=TimeInForce.DAY,
)

Reconciliation

oneworldtrade is designed to recover cleanly from the important partial-failure case:

  1. Alpaca fills the order.
  2. Bridgewood reporting fails temporarily.
  3. The agent replays the filled order later.

Because Bridgewood deduplicates on external_order_id, oneworldtrade uses the stable Alpaca order ID when reporting a fully filled order. Replays are safe.

reconciliation = trader.reconcile(limit=20)
print(reconciliation.successful_reports)

CLI

The package includes a small CLI:

oneworldtrade config show
oneworldtrade broker verify
oneworldtrade bridgewood verify
oneworldtrade buy AAPL --qty 1
oneworldtrade sell TSLA --qty 1
oneworldtrade sync-order <broker-order-id>
oneworldtrade reconcile --limit 20

Design Notes

  • Only fully filled orders are reported to Bridgewood.
  • Bridgewood setup is human-owned and outside the package scope.
  • Alpaca is wrapped behind a broker client interface so future brokers can be added without rewriting strategy code.
  • The default public API is Trader.
  • Lower-level broker and Bridgewood clients are still available when needed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oneworldtrade-0.1.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oneworldtrade-0.1.0-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file oneworldtrade-0.1.0.tar.gz.

File metadata

  • Download URL: oneworldtrade-0.1.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oneworldtrade-0.1.0.tar.gz
Algorithm Hash digest
SHA256 71f9ab8736b86dac828759b44405db54920ca30ee4f1acbf31e71f93e618de8c
MD5 a2170546cce509c369bf2ea1fa55ea97
BLAKE2b-256 b50ea2f411d8e24684c3960dfc2ef95b595afa48d9f1e8ff2c9fbf1429d718b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for oneworldtrade-0.1.0.tar.gz:

Publisher: publish.yml on BridgewoodSecurities/oneworldtrade

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oneworldtrade-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oneworldtrade-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oneworldtrade-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e4cdf6b0d8591290e3238fd53c58268f074039763269195f249fa5521c86c56
MD5 3f0540652b0d43f1aeeb5b2f1aca4c4c
BLAKE2b-256 7d6e3a026ccd8999e1601af6cfb8925860ec791034417202eab7e9ebd8622827

See more details on using hashes here.

Provenance

The following attestation bundles were made for oneworldtrade-0.1.0-py3-none-any.whl:

Publisher: publish.yml on BridgewoodSecurities/oneworldtrade

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page