As part of our Elite Smart Router*, we now offer advanced algorithmic order types — Volume-Weighted Average Price (VWAP) and Time-Weighted Average Price (TWAP) — alongside Direct Market Access Gateway** (DMA Gateway). These tools give you greater flexibility over execution, helping you efficiently manage large orders, reduce costs, minimize market impact, and support trades with your specific objectives.

What Are the Advanced Order Types?

Beyond simple market or limit orders, advanced order types are refined instructions that execute a trade only when certain parameters are met. They may offer a more sophisticated way to enter or exit positions, giving traders greater flexibility over both timing and price. With our Elite Smart Router, you can already access VWAP and TWAP, with additional types like PVOL and MPEG coming in the next release.

You can also refer to the Alpaca’s Doc: Market Order Types.

Why Advanced Market Orders Matter Now?

The most recent TRADE’s 2025 Algorithmic Trading Survey revealed a resurgence in algorithmic trading adoption from the hedge fund community. 

Among the most commonly used algorithms, advanced market orders like VWAP and TWAP rank near the top. In 2025, 74% of hedge funds reported using VWAP, while 42% use TWAP. Their popularity highlights the increasing demand for strategies that:

  • Help minimize market impact
  • Trade in sync with market activity
  • Target benchmark-base pricing

As average order sizes increase, firms may explore advanced order types to better manage execution and maintain alignment with their trading objectives. While no strategy guarantees specific outcomes, these tools help support more efficient execution in certain market conditions.

Volume-Weighted Average Price (VWAP) Order

A VWAP order is designed to execute a trade at or near the volume-weighted average price of a security over a specified time period. It is calculated by dividing the total dollar value traded for the security (price × volume) by the total volume traded during that period.

Understanding VWAP

VWAP automatically weights each trade price by its corresponding trade volume, ensuring the average reflects both price and trading activity. This makes VWAP a valuable reference for assessing execution quality and market trends.

Formula for VWAP: sum of (volume × price) divided by total volume, showing how VWAP accounts for both price and trade size over a defined period.
The VWAP formula calculates the average trade price weighted by volume, ensuring that both price and trading activity are reflected in the measure.

An example of a VWAP order executed over time:

Bar chart showing VWAP bucket sizes across the trading day, with larger order sizes in early and late sessions and smaller allocations midday.
Example of a VWAP execution schedule, where trade sizes are distributed across time intervals to align with market activity.

Benefits of a VWAP order

  • Market Impact Management: VWAP orders are designed to execute in proportion to market volume, which may help reduce the likelihood of large trades significantly influencing the market price.
  • Benchmark Alignment: VWAP can be used as a benchmark strategy, aiming to achieve execution prices close to the volume-weighted average price over a specified time period. This approach may help align fills with average market pricing trends.

While VWAP strategies are commonly used by institutional and algorithmic traders, outcomes can vary depending on market conditions and execution timing. No execution strategy guarantees specific results.

How to Trade VWAP with Alpaca’s Trading API

With our Trading API, integrating VWAP into your trading strategy is straightforward. When placing an order, include the advanced_instructions parameter in your request and specify the algorithm as VWAP, automatically pacing your trades in line with the volume-weighted average price for your chosen time window.

Example 1: Placing a Market Order with VWAP

Here’s how it works by running the sample code below: 

  • Start trading at market open (09:30 ET).
  • The algorithm tracks volume and price movement throughout the specified time period. 
  • Your 5,000-share order is broken into smaller trades, executed gradually until 14:30 ET.
  • Each slice is sized so your trades never exceed 12.3% of the total ticker's period volume this order might participate in.
  • The goal is for your average price to be as close as possible to the VWAP for that 9:30–14:30 window.
# Create the market order request
req = MarketOrderRequest(
    symbol = "SPY",
    qty = 5000,
    side = OrderSide.BUY,
    type = OrderType.MARKET,
    order_class = OrderClass.SIMPLE,
    time_in_force = TimeInForce.DAY,
    advanced_instructions = {
        "algorithm":  "VWAP",
        "start_time": "2025-07-21T09:30:00-04:00",
        "end_time": "2025-07-21T14:30:00-04:00",
	  "max_percentage": "0.123"
    }
)
# Submit the market order request
res = trade_client.submit_order(req)
res

Example 2: Placing a Limit Order with VWAP

You can also place a VWAP order using a limit order. With a limit order, you set the maximum price you are willing to pay (for a buy) or the minimum price you are willing to accept (for a sell).

Here’s how it works by running the sample code below: 

  • Start trading at market open (09:30 ET).
  • The algorithm tracks market volume and price movement throughout the specified time period. 
  • The limit price is set at $623.80, so no trades will be placed above that price.
  • Your 5,000-share order is broken into smaller trades, executed gradually until 14:30 ET.
  • Each slice is sized so your trades never exceed 12.3% of the total ticker's period volume this order might participate in.
  • The goal is for your average price to be as close as possible to the VWAP for that 9:30–14:30 window.
# Create the limit order request
req = LimitOrderRequest(
    symbol = "SPY",
    qty = 5000,
    limit_price = 623.80,
    side = OrderSide.BUY,
    type = OrderType.LIMIT,
    time_in_force = TimeInForce.DAY,
    advanced_instructions = {
        "algorithm":  "VWAP",
        "start_time": "2025-07-21T09:30:00-04:00",
        "end_time": "2025-07-21T14:30:00-04:00",
	  "max_percentage": "0.123"
    }
)
# Submit the market order request
res = trade_client.submit_order(req)
res

Note:

  • You can also find detailed API resources here: DMA / Advanced Order Types.
  • We need to use ISO format for both start_time and end_time
  • advanced_instructions will be accepted for paper trading; however, the order will not be simulated in the paper environment.
  • If you are not on Elite Smart Router, you will likely receive a rejection message like:
{
  "code": 40310000,
  "message": "account not allowed to use advanced_instructions"
}

Time-Weighted Average Price (TWAP) Order

A TWAP order is designed to execute a trade evenly over a specified time period, regardless of market volume. The order is divided into equal-sized trades that are placed at regular, pre-defined intervals until the order is complete.

Understanding TWAP

TWAP focuses on time rather than volume. By executing trades at consistent intervals, this strategy reduces the risk of moving the market with large, sudden orders and aims for a stable average execution price over the chosen period. TWAP is often used when you want predictable pacing and minimal market impact without relying on real-time volume patterns.

Formula for TWAP: sum of prices across equal time intervals divided by the number of intervals, showing how trades are averaged over time rather than by volume.
The TWAP formula calculates the average trade price across equal time intervals, ensuring executions are evenly distributed throughout the day.

An example of a TWAP order executed over time:

Bar chart titled “TWAP Bucket Size” displaying consistent share allocations over time, illustrating how TWAP spreads orders evenly across the trading day.
TWAP execution example, where order sizes are evenly divided into equal time buckets, creating a steady execution pace across the trading session.

Benefits of a TWAP order

  • Reduces Market Impact: By spreading the order evenly across time, TWAP can help minimize the risk of significant price swings caused by large trades.
  • Execution Predictability: Unlike VWAP, which adjusts based on market volume, TWAP may offer more consistent, evenly paced execution, which can be helpful in managing certain trading strategies.
  • Effective in Low-Liquidity Environments: When volume patterns are unpredictable, TWAP can help prevent trades from disrupting the market and can help maintain price stability.

How to Trade TWAP with Alpaca’s Trading API

Just like with the VWAP implementation, it's very easy to integrate TWAP into your trading using our Trading API. You can use advanced algorithmic execution simply by including the advanced_instructions parameter in your regular order request.

Example 1: Placing a Market Order with TWAP

Here’s how it works by running the sample code below: 

  • Start trading at market open (09:30 ET).
  • The algorithm splits 5,000-share orders into equal-sized trades at fixed time intervals until 14:30 ET.
  • Each slice is sized so your trades never exceed 12.3% of the total ticker’s period volume this order might participate in.
  • The goal is for your average price to be as close as possible to the TWAP for that 9:30–14:30 window.
# Create the market order request
req = MarketOrderRequest(
    symbol = "SPY",
    qty = 100,
    side = OrderSide.BUY,
    type = OrderType.MARKET,
    order_class = OrderClass.SIMPLE,
    time_in_force = TimeInForce.DAY,
    advanced_instructions = {
        "algorithm":  "TWAP",
        "start_time": "2025-07-21T09:30:00-04:00",
        "end_time": "2025-07-21T15:30:00-04:00",
	  "max_percentage": "0.123"
    }
)
# Submit the market order request
res = trade_client.submit_order(req)
res

Example 2: Placing a Limit Order with TWAP

You can also place a TWAP order using other order types, such as a limit order. With a limit order, you set the maximum price you are willing to pay (for a buy) or the minimum price you are willing to accept (for a sell).

Here’s how it works by running the sample code below: 

  • Start trading at market open (09:30 ET).
  • The algorithm splits 5,000-share orders into equal sized trades at fixed time intervals until 14:30 ET.
  • The limit price is set at $623.80, so no trades will be placed above that price.
  • Each slice also respects your participation cap of 12.3 percent if supported.
  • The goal is for your average price to be as close as possible to the TWAP for that 9:30–14:30 window.
# Create the limit order request
req = LimitOrderRequest(
    symbol = "SPY",
    qty = 5000,
    limit_price = 623.80,
    side = OrderSide.BUY,
    type = OrderType.LIMIT,
    time_in_force = TimeInForce.DAY,
    advanced_instructions = {
        "algorithm":  "TWAP",
        "start_time": "2025-07-21T09:30:00-04:00",
        "end_time": "2025-07-21T14:30:00-04:00",
	  "max_percentage": "0.123"
    }
)
# Submit the market order request
res = trade_client.submit_order(req)
res

Note:

  • You can also find detailed API resources here: DMA / Advanced Order Types.
  • We need to use ISO format for both start_time and end_time
  • advanced_instructions will be accepted for paper trading; however, the order will not be simulated in the paper environment.
  • If you are not on Elite Smart Router, you will likely receive a rejection message like:
{
  "code": 40310000,
  "message": "account not allowed to use advanced_instructions"
}

Risk of VWAP and TWAP Orders

Execution quality for VWAP and TWAP orders depends heavily on market conditions, liquidity, and volatility. Under certain circumstances, these orders may result in less favorable execution prices and may not adapt to unexpected market events. These order types should be used only by traders who fully understand their mechanics, limitations, and potential risks. 

Conclusion

VWAP and TWAP order types can be effective tools for advanced traders who need to execute large orders strategically. They are designed to help manage market impact and may help achieve an average price over a set period of time or volume. Our Trading API makes it easy to integrate these advanced order types into your own trading strategies. To get started, explore these resources:

If you want to know more about how to code alpaca-py, check out the following resources:


*Please note that this is currently only available to Alpaca Elite Smart Router users. For more information on Alpaca Elite please see the term and conditions.

**Direct Market Access Gateway is provided solely by DASH Financial Technologies ("DASH"), a member of the listed exchanges. Alpaca enables customers to route orders to the selected exchange through DASH’s DMA capabilities.

Please note that we are using SPY as an example, and it should not be considered investment advice.

Options trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options before investing in options.

Past hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.

All investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.

The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, “Alpaca”) is not authorized to do business.

Please note that this article is for general informational purposes only and is believed to be accurate as of the posting date but may be subject to change. The examples above are for illustrative purposes only.

Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.

This is not an offer, solicitation of an offer, or advice to buy or sell securities or open a brokerage account in any jurisdiction where Alpaca Securities are not registered or licensed, as applicable.