Raxx · internal docs

internal · gated ↑ index

TradeMaster API Documentation

Market Data Feeds

TradeMaster uses Alpaca's Market Data API to fetch historical and real-time market data. The following data feeds are available:

Data Feed Types

Feed ID Name Description Delay Subscription Required
delayed_sip Delayed SIP 15-minute delayed SIP (Securities Information Processor) data 15 minutes No
sip Real-time SIP Real-time SIP (Securities Information Processor) data None Yes
iex IEX Data from the Investors Exchange (IEX) None No
otc OTC Markets Data for OTC (Over-The-Counter) securities Varies No

Historical Data Timeframes

Alpaca's historical data API provides data at different timeframes:

Timeframe Description Availability
1Min 1-minute bars Limited to last 30 calendar days for free tier
5Min 5-minute bars Limited to last 30 calendar days for free tier
15Min 15-minute bars Limited to last 30 calendar days for free tier
1H 1-hour bars Limited to last 30 calendar days for free tier
1D 1-day bars Up to 5 years of historical data

TradeMaster primarily uses the 1D timeframe for backtesting, which provides up to 5 years of historical data.

Limitations and Considerations

  1. SIP Data Subscription: - The sip data feed requires a paid subscription to Alpaca. - Without a subscription, API calls using the sip feed will fail. - The application will automatically fall back to delayed_sip if a subscription error occurs.

  2. Date Range Limitations: - Daily historical data (1D) is typically limited to approximately 5 years (1250 trading days). - Intraday data (1Min, 5Min, etc.) is limited to the last 30 calendar days for free tier users. - Requesting longer date ranges may result in incomplete data.

  3. Real-time Data Restrictions: - When using delayed_sip, data for the current day has a 15-minute delay. - End dates that are too recent (within the 15-minute window) will be adjusted automatically.

  4. Symbol Availability: - Not all symbols are available in all data feeds. - The iex feed may have limited coverage for some symbols. - OTC securities are only available in the otc feed. - Some symbols may have limited historical data.

  5. Rate Limits: - Alpaca imposes rate limits on API calls. - Free tier users are limited to 200 API calls per minute. - Excessive requests may be throttled or blocked.

API Endpoints

GET /api/data-feeds

Returns all available data feeds as an object keyed by feed ID.

Response:

{
  "delayed_sip": {
    "id": "delayed_sip",
    "name": "Delayed SIP",
    "description": "15-minute delayed SIP data. Available to all users.",
    "delay": "15 minutes",
    "subscription_required": false,
    "default": true,
    "status": "connected",
    "last_checked": "2026-03-04T12:00:00",
    "error": null,
    "active": true
  },
  "sip": {
    "id": "sip",
    "name": "Real-time SIP",
    "description": "Real-time SIP data. Requires a paid subscription.",
    "delay": "None",
    "subscription_required": true,
    "default": false,
    "status": "disconnected",
    "last_checked": "2026-03-04T12:00:00",
    "error": null,
    "active": false
  },
  "iex": {
    "id": "iex",
    "name": "IEX",
    "description": "Data from the Investors Exchange (IEX).",
    "delay": "None",
    "subscription_required": false,
    "default": false,
    "status": "connected",
    "last_checked": "2026-03-04T12:00:00",
    "error": null,
    "active": false
  },
  "otc": {
    "id": "otc",
    "name": "OTC Markets",
    "description": "Data for OTC securities.",
    "delay": "Varies",
    "subscription_required": false,
    "default": false,
    "status": "error",
    "last_checked": "2026-03-04T12:00:00",
    "error": "OTC data requires a paid subscription",
    "active": false
  }
}

Feed object fields: | Field | Type | Description | |-------|------|-------------| | id | string | Feed identifier | | name | string | Human-readable name | | description | string | Feed description | | delay | string | Data delay | | subscription_required | boolean | Whether a paid subscription is needed | | default | boolean | Whether this is the default feed | | status | string | One of: connected, connecting, disconnected, error | | last_checked | string | ISO timestamp of last status check | | error | string|null | Error message if status is error | | active | boolean | Whether this is the currently active feed |

GET /api/data-feeds/status

Refreshes and returns status of all data feeds. Same response shape as GET /api/data-feeds.

GET /api/data-feeds/{feed_id}/status

Returns status for a single data feed.

Response: A single feed object (same shape as values in the /api/data-feeds response).

GET /api/data-feeds/active

Returns the currently active data feed.

Response:

{
  "active_feed": "delayed_sip",
  "feed_info": {
    "id": "delayed_sip",
    "name": "Delayed SIP",
    "description": "15-minute delayed SIP data. Available to all users.",
    "status": "connected",
    "last_checked": "2026-03-04T12:00:00",
    "error": null
  }
}

POST /api/data-feeds/active

Set the active data feed.

Request Body:

{
  "feed_id": "iex"
}

The feed key is also accepted for backward compatibility.

Response (200):

{
  "success": true,
  "active_feed": "iex"
}

Error responses: - 400 — Missing feed ID - 404 — Unknown feed ID

GET /api/data-feeds/detailed-status

Returns detailed status with test results for all feeds.

Response:

{
  "feeds": { /* same shape as GET /api/data-feeds, plus test_results per feed */ },
  "active_feed": "delayed_sip",
  "timestamp": "2026-03-04T12:00:00"
}

GET /api/data-feeds/test-results

Returns test results for all feeds from the most recent test run.

POST /api/backtest

Run a backtest with the specified parameters.

Request Body:

{
  "symbol": "AAPL",
  "strategy_id": "golden_cross",
  "start_date": "2022-01-01",
  "end_date": "2022-12-31",
  "initial_capital": 10000,
  "data_feed": "delayed_sip",
  "strategy_params": [
    {
      "name": "short_window",
      "value": 50
    },
    {
      "name": "long_window",
      "value": 200
    }
  ]
}

Response:

{
  "symbol": "AAPL",
  "strategy": "golden_cross",
  "start_date": "2022-01-01",
  "end_date": "2022-12-31",
  "initial_capital": 10000,
  "final_capital": 12500,
  "total_return": 0.25,
  "annualized_return": 0.22,
  "sharpe_ratio": 1.5,
  "max_drawdown": -0.15,
  "win_rate": 0.6,
  "equity_curve": [
    {
      "date": "2022-01-01",
      "value": 10000
    },
    // ...more data points
  ],
  "drawdown_curve": [
    {
      "date": "2022-01-01",
      "value": 0
    },
    // ...more data points
  ],
  "trades": [
    {
      "date": "2022-01-15",
      "type": "buy",
      "price": 150.25,
      "quantity": 10,
      "pnl": null
    },
    // ...more trades
  ]
}

POST /api/compare-strategies

Compare multiple strategies with the same parameters.

Request Body:

{
  "symbol": "AAPL",
  "strategy_ids": ["golden_cross", "rsi", "macd"],
  "start_date": "2022-01-01",
  "end_date": "2022-12-31",
  "initial_capital": 10000,
  "data_feed": "delayed_sip",
  "strategy_params_map": {
    "golden_cross": [
      {
        "name": "short_window",
        "value": 50
      },
      {
        "name": "long_window",
        "value": 200
      }
    ],
    "rsi": [
      {
        "name": "window",
        "value": 14
      },
      {
        "name": "oversold",
        "value": 30
      },
      {
        "name": "overbought",
        "value": 70
      }
    ],
    "macd": [
      {
        "name": "fast_period",
        "value": 12
      },
      {
        "name": "slow_period",
        "value": 26
      },
      {
        "name": "signal_period",
        "value": 9
      }
    ]
  }
}

Response:

{
  "strategies": [
    {
      "id": "golden_cross",
      "name": "Golden Cross",
      "equity_curve": [10000, 10050, 10100, ...],
      "total_return": 0.25,
      "annualized_return": 0.22,
      "sharpe_ratio": 1.5,
      "max_drawdown": -0.15,
      "win_rate": 0.6
    },
    // ...more strategies
  ],
  "dates": ["2022-01-01", "2022-01-02", ...],
  "equity_curves": {
    "golden_cross": [
      {"date": "2022-01-01", "value": 10000},
      // ...more data points
    ],
    // ...more strategies
  },
  "metrics": {
    "golden_cross": {
      "total_return": 0.25,
      "annualized_return": 0.22,
      "sharpe_ratio": 1.5,
      "max_drawdown": -0.15,
      "win_rate": 0.6
    },
    // ...more strategies
  }
}

GET /api/stock-price/:symbol

Get current stock price information for a specific symbol.

Parameters: - symbol (path parameter): The stock symbol to get price information for (e.g., AAPL)

Response:

{
  "symbol": "AAPL",
  "current_price": 175.25,
  "previous_close": 173.50,
  "change": 1.75,
  "change_percent": 1.01,
  "timestamp": "2023-03-15T15:30:00.000Z",
  "previous_timestamp": "2023-03-14T20:00:00.000Z",
  "is_mock_data": false
}

Notes: - If the Alpaca API is not initialized or unavailable, mock data will be returned with is_mock_data set to true. - The current_price is calculated as the midpoint between the bid and ask prices. - The change and change_percent values are calculated relative to the previous day's closing price. - The timestamp field indicates when the price data was last updated.