Broker Descriptors

Broker descriptors define connections to brokerage accounts for paper and live trade execution. They specify which broker to connect to, how to authenticate, what trading permissions your algo has, and what risk limits to enforce.

Purpose

Broker descriptors tell Datafye:

  • Which broker to connect to (Alpaca, Interactive Brokers, etc.)

  • How to authenticate with your brokerage account

  • Trading mode (paper or live)

  • Trading permissions (what assets the algo can trade)

  • Risk limits (position sizes, loss limits, etc.)

  • Order settings (default order types, time in force, etc.)

Based on your broker descriptor, Datafye provisions the Broker Connector and establishes a secure connection to your brokerage account.

When You Need Broker Descriptors

Broker descriptors are required for Trading scenarios only:

  • Trading: Data Cloud + Broker — Connects your own algo containers to broker

  • Trading: Full Stack — Connects Datafye Algo Container to broker

For Foundry scenarios (Data Cloud Only and Full Stack), you don't need a broker descriptor since they're for development and backtesting only.

Structure

A typical broker descriptor includes:

Supported Brokers

Datafye supports connections to multiple brokers:

Alpaca

Features:

  • Commission-free US equities trading

  • Paper trading with simulated fills

  • [Crypto trading supported?]

  • REST and WebSocket APIs

Setup:

  • Create account at alpaca.markets

  • Generate API keys in dashboard

  • [Paper and live use different keys?]

Interactive Brokers

Features:

  • Multi-asset class trading (stocks, options, futures, forex)

  • Global market access

  • [Paper trading through IB's paper account?]

Setup:

  • IB account required

  • [TWS or IB Gateway installation needed?]

  • [Special API permissions required?]

Other Brokers

[List other supported brokers: TD Ameritrade, Schwab, Robinhood, etc.?]

Each broker may have specific configuration requirements — see broker-specific documentation.

Trading Modes

Paper Trading

Simulated trading with fake money to validate your algo:

Characteristics:

  • No real money at risk

  • Simulated order fills (may not match real execution exactly)

  • Full broker API functionality

  • Same trading hours as live markets

  • Reset account balance as needed

Use cases:

  • Initial algo validation

  • Testing new strategies

  • Confidence building before live trading

  • Debugging order logic

Limitations:

  • Fills may be more optimistic than reality

  • [Slippage modeling accurate?]

  • [No impact from your orders on market]

  • Some edge cases may not be simulated perfectly

Live Trading

Real trading with actual capital:

Characteristics:

  • Real capital at risk

  • Actual market execution and slippage

  • Real transaction costs

  • Subject to real market conditions

  • Trades affect your actual portfolio

Best practices:

  • Always paper trade first

  • Start with small position sizes

  • Monitor closely initially

  • Set strict risk limits

  • Have a stop-loss plan

Authentication

Environment Variables

Store credentials securely using environment variables:

Security best practices:

  • Never commit credentials to git

  • Use different keys for paper and live

  • Rotate keys periodically

  • Restrict key permissions to trading only

  • [Does Datafye provide secure credential storage?]

Credential Management

[How does Datafye handle broker credentials securely?]

  • [Encrypted storage?]

  • [Key rotation support?]

  • [Access controls?]

  • [Audit logging of credential usage?]

Trading Permissions

Define what assets and actions your algo is allowed to perform:

Permission categories:

Asset classes:

  • trade_equities — US stocks

  • trade_options — Options contracts

  • trade_futures — Futures contracts

  • trade_crypto — Cryptocurrencies

  • trade_forex — Foreign exchange

Trading actions:

  • short_selling — Short positions allowed

  • margin_trading — Use margin/leverage

  • extended_hours — Pre-market and after-hours trading

Account actions:

  • modify_orders — Change existing orders

  • cancel_orders — Cancel pending orders

Why restrict permissions?

  • Risk management — Prevent algo from unexpected actions

  • Compliance — Meet regulatory requirements

  • Testing — Start with limited permissions, expand gradually

  • Safety — Limit potential damage from bugs

Risk Limits

Enforce position sizing and loss limits to manage risk:

Position Limits

Control position sizing:

How limits are enforced:

  • Orders that would violate limits are rejected

  • [Partial fills if full order would violate?]

  • [Warnings before limits are hit?]

Loss Limits

Prevent catastrophic losses:

What happens when limit is hit:

  • [All positions closed immediately?]

  • [Trading suspended until manual intervention?]

  • [Alerts sent?]

Order Limits

Control order flow:

Why order limits:

  • Prevent runaway algos

  • Avoid pattern day trader violations

  • Manage broker rate limits

  • Control transaction costs

Default Order Settings

Configure default order parameters:

Order Types

Order type selection:

  • Market: Immediate execution, no price guarantee

  • Limit: Price guarantee, execution not guaranteed

  • Stop: Trigger at price, then market order

  • Stop Limit: Trigger at price, then limit order

  • Trailing Stop: Dynamic stop based on price movement

Default vs. override:

  • Descriptor sets default

  • Algo can override per-order

  • [Are some order types restricted?]

Time in Force

Time in force options:

  • day: Order expires at end of trading day

  • gtc (Good 'Til Canceled): Open until filled or canceled

  • ioc (Immediate or Cancel): Fill immediately or cancel

  • fok (Fill or Kill): Fill completely immediately or cancel

Limit Order Offset

For limit orders, how much to offset from current price:

Purpose:

  • Increase fill probability

  • Get better prices than market orders

  • Balance execution speed vs. price

Example Broker Descriptors

Example 1: Paper Trading with Alpaca

Basic paper trading setup for initial validation:

Example 2: Conservative Live Trading

Small-scale live trading with strict limits:

Example 3: Options Trading

Options strategy with appropriate permissions:

Example 4: High-Frequency Strategy

More permissive settings for active trading:

Validation

Before provisioning, Datafye validates your broker descriptor:

Schema Validation

  • All required fields present

  • Valid broker provider name

  • Valid mode (paper or live)

  • Credentials format correct

Broker Connectivity

  • Can authenticate with broker

  • Account exists and is accessible

  • [Test API connectivity?]

  • [Verify account permissions match requested permissions?]

Limits Validation

  • Limit values are reasonable

  • No conflicting limits

  • [Verify limits are within broker account constraints?]

Common validation errors:

  • Invalid broker credentials

  • Broker account not found or inaccessible

  • Requested permissions not available on account

  • Risk limits conflict or are invalid

  • [Other common errors?]

Broker-Specific Considerations

Alpaca

Strengths:

  • Easy setup with API keys

  • Good paper trading environment

  • Commission-free equities

  • Real-time data included

Limitations:

  • US markets only

  • [Options trading support status?]

  • [Crypto support?]

Interactive Brokers

Strengths:

  • Multi-asset class support

  • Global market access

  • Low commissions

Limitations:

  • More complex setup (TWS/Gateway)

  • [Minimum account balance?]

  • [API complexity?]

Other Brokers

[Document broker-specific setup, features, and limitations for each supported broker]

Security Best Practices

Credential Management

Do:

  • Use environment variables for credentials

  • Use different keys for paper and live

  • Rotate API keys regularly

  • Restrict key permissions to minimum needed

  • Monitor key usage for anomalies

Don't:

  • Commit credentials to git

  • Share credentials

  • Use same credentials across environments

  • Give keys broader permissions than needed

Permission Scoping

Principle of least privilege:

  • Start with minimal permissions

  • Add permissions only as needed

  • Review permissions regularly

  • Revoke unused permissions

Risk Limit Tuning

Start conservative:

  • Begin with small position sizes

  • Set tight loss limits initially

  • Gradually increase as confidence builds

  • Always have hard stop-loss limits

Monitoring and Alerts

Monitor:

  • Connection health to broker

  • Order success/failure rates

  • Position sizes relative to limits

  • Daily/total losses relative to limits

  • [What metrics are available?]

Alerts:

  • Connection failures

  • Approaching risk limits

  • Risk limits hit

  • Authentication errors

  • Unusual order patterns

  • [How are alerts configured and delivered?]

Transitioning from Paper to Live

Pre-Live Checklist

Before switching to live trading:

  1. Extensive paper trading

    • Run for at least [recommended period?]

    • Include various market conditions

    • Verify fills and execution

  2. Review performance

    • Compare to backtest expectations

    • Check slippage and costs

    • Analyze order fills

  3. Validate risk controls

    • Test position limits work

    • Verify loss limits trigger

    • Confirm permissions are correct

  4. Update credentials

    • Switch to live API keys

    • Verify live account has adequate funds

    • Double-check all settings

  5. Start small

    • Use smaller position sizes initially

    • Tighter risk limits at first

    • Monitor closely for first days/weeks

Descriptor Changes for Live

Best Practices

Development Workflow

Development (broker-paper.yaml):

Production (broker-live.yaml):

Version Control

  • Store broker descriptors in git (without credentials!)

  • Use environment variables for all secrets

  • Document broker setup in README

  • Tag descriptors with deployment versions

Testing

  • Verify paper trading matches backtest performance

  • Test risk limit enforcement

  • Validate order execution

  • Check error handling (network issues, rejections, etc.)

Next Steps


Last updated: 2025-10-11

Last updated