Skip to main content

VWAP Algorithm

The Volume Weighted Average Price (VWAP) Algorithm uses the historical volume pattern of order instrument to determine a trading trajectory. The VWAP algorithm uses the same “market chasing” approach as TWAP (described above).

Order Parameters

Standard order Parameters

TagField nameTypeReq'dComments
1AccountStringNTrading Order account. All child orders will have the same trading account.
55SymbolStringYThis tag is required. Human-readable instrument name as it is defined in Deltix Security Metadata.
54SideCharYOrder side ("1"=BUY or "2"=SELL)
50SenderSubIDStringYTrader ID
44PricePriceYLimit Price
38OrderQtyQtyYOrder quantity
76BrokerIDStringY"VWAP" (Deployment key of algo strategy)
40OrdTypeCharY"X" (Denotes custom algo order)

VWAP Specific Order Parameters

TagField nameTypeReq'dComments
6002OrderDurationStringNOrder duration in HH:MM:SS or HH:MM:SS.sss format. For example, 05:03:30 would be 5 hours, 3 minutes and 30 seconds from the time the order was initially entered (entry time captured during initialization).
The entry time would be statically assigned so if the user chooses later to modify the parameter to 03:00:00, the new calculated end time of the algo would be from the initial entry time plus 3 hours. Required when StopTime is not specified.
6013FixedQtyFloatNFixed quantity is the threshold lean quantity. Disabled at 0 (default). Algorithm ignores quotes that are smaller than fixed quantity when it determines passive price.
6021StartTimeTimestampNDefines order execution start time. If missed, start time will be order’s arrival time.
6022StopTimeTimestampNDefines order exit time. Required when OrderDuration is not specified.
6023PercentFloatYPercentage used to split time.
Example: "25" means 25%. Order duration will be split in four equal intervals.
6027IntervalVarianceFloatNPercentage in the range from 0 to 50% that randomizes the fixed time interval between child orders. For instance, when a 10% interval variance is specified, each next child order will be issued after interval within 10% of the fixed time interval specified by Duration and Percent attributes.
6034WeeklyVolumeRatioFloatNDefines ratio of Weekly trading volume profile relative to Daily volume profile. Value of this attribute must be between 0 and 100. The default value is 0: only previous day profile will be used. When set to 100 we will use the previous week profile for the same day and time of the week only.
6036MinPriceUpdateIntervalStringNMin time interval that must pass between order price updates during market chasing. This attribute is in HH:MM:SS or HH:MM:SS.sss format
6044ActivePriceOffsetUnitIntNPrice offset Unit: 0 for quote currency (default), 1 for percentage and 2 for offset in ticks
6045ActivePriceOffsetFloatNPrice offset in unit specified by price offset unit attribute or by default in quote currency. If specified, VWAP will use a more aggressive active price that instead of staying at market price will cross the market by specified offset. Also, when chasing the market VWAP will switch to using active price instead of passive price.
7002EligibleExchangesStringNIf specified, restricts exchanges where order should be executed. Comma-separated list of exchange codes "COINBASE,BINANCE,GEMINI". Each exchange name must match the Deltix exchange code. This tag is used for children orders (for example when sending children to SOR).

Changing Order Working Price

The child order is entered at the passive price (the price one tick above the bid price when selling and one tick below the offer when buying), subject to the maximum price specified by the user.

There are various conditions that force the order to change prices to a maximum limit. An order can change price if any one of the following conditions are met:

  • The parameter FixedQty(6013) quantity is breached when Best Qty ≤ Fixed Qty.

    Action: Aggress to best market price.

  • The market is wide: market is wider than the best price ± one tick.

    Action: Move the order to the passive price.

  • The order price is not on passive price (missed). This occurs when the price flips without any of the other conditions being met.

    Action: The order is then moved to the passive price.

Each of the above conditions moves the order price to at least the passive price. If the working price of the order was changed, all active child orders are moved to the new price.

note

Best Bid is the quantity of the top of the book on the other side of the market. For example, for SELL orders "Best Qty" is the size of the best bid on the market.

Other Considerations

IOC Orders

The TWAP note about IOC orders is applicable to VWAP as well.

Deployment Options

VWAP Curve Stream

TimeBase stream that defines VWAP curve.

Default Destination

When defined, this parameter ensures that all child orders are routed to a specific destination. For example, SIMULATOR.

Configuration

Here is the complete list of supported config settings:

Parameter NameDescription
initialActiveOrdersCacheSizeOptional, int. Initial active orders cache size.
initialClientsCapacityOptional, int. Initial client capacity.
maxInactiveOrdersCacheSizeOptional, int. Maximum inactive orders cache size.
orderCacheCapacityOptional, int. Order cache capacity.
defaultOrderDestinationOptional, string, null by default. Destination of orders issued by the algorithm
volumeProfileStreamRequired, string. TimeBase stream that defines VWAP curve
maxCancellationsOptional, int. 3 by default. Parent order will be canceled when the number of child orders cancellations with no trades exceeds this number
applyRequestTagsOptional, array of strings. [ 7002 ] by default. List of tags of parent order custom attributes that should be included with child orders if available. This list can contain individual keys or a range of keys from a min and up to a max. Min and max key in the range will be separated by '-'. For example: "applyRequestTags = [ 7002, 1-1000 ]", where the second value is a range of keys that includes all keys from 1 to 1000

VWAP Profile Generation

Deltix provides Java and .NET samples that generate volume profiles consumed by VWAP Algorithm.

VWAP curves are expected in the following format (VolumeProfileMessage TimeBase message):

FieldTimeBase TypeDescription
symbolVARCHAR, REQUIREDInstrument ID
timestampTIMESTAMP, REQUIREDCaptures when this message is stored into TimeBase. Not used in calculations.
BuyQuantityDOUBLE, REQUIREDTotal volume of trades where BUY side was initiator
SellQuantityDOUBLE, REQUIREDTotal volume of trades where SELL side was initiator
StartTimeTIMESTAMP, REQUIREDTime when this profile will be actual. Only time of day part of this timestamp matter. VWAP will convert this time to Linux epoch time and build index using formula:

( timestamp % (24 * 60 * 60 * 1000)) / 60000

EndTimeTIMESTAMP, REQUIREDTime when this profile will be no longer actual (must be later than StartTime). Same handling as StartTime.

Each VolumeProfileMessage contains symbol volume data for a 1 minute interval specified by startTime and endTime in UTC. buyQuantity and sellQuantity attributes contain traded volume for this interval where the BUY or SELL side was the aggressor.

For markets that do not provide an aggressor side indicator in their trades, you can use the Lee / Ready heuristic or simply use total observed volume for Buy and Sell quantities.

A Java representation of a corresponding TimeBase message:

package deltix.ember.algorithm.pack.vwap.data;

import deltix.qsrv.hf.pub.InstrumentMessage;
import deltix.qsrv.hf.pub.md.FloatDataType;
import deltix.qsrv.hf.pub.md.TimeOfDayDataType;

@deltix.timebase.api.SchemaElement(name = "deltix.ember.algorithm.pack.vwap.data.VolumeProfileMessage")
public class VolumeProfileMessage extends InstrumentMessage {
public double BuyQuantity = FloatDataType.IEEE64_NULL;
public double SellQuantity = FloatDataType.IEEE64_NULL;
public int StartTime = TimeOfDayDataType.NULL;
public int EndTime = TimeOfDayDataType.NULL;
}

VWAP Curve Generation Utility

Ember provides a volume-profile-publisher utility to generate volume profiles based on market data. The following is a command line utility help screen:

Usage: volume-profile-publisher [-help] [-timebase <arg>] -marketStreams <arg> -profileStream <arg>
[-startTime <arg>] [-endTime <arg>] [-symbols <arg>] [-dryRun]
-help print this message
-timebase <arg> timebase URL (default is dxtick://localhost:8011)
-marketStreams <arg> comma-separated list of market data streams
-profileStream <arg> volume profile stream, where volume profile messages will be written
-startTime <arg> start time from which profile should be generated from market data. By
default publisher will process market data starting one week back
-endTime <arg> end time at which to stop generating profile from market data. If not
specified publisher will keep processing messages in live mode
-symbols <arg> comma-separated list of symbols of instruments for which volume profile
should be generated. If not specified profile will be generated for all
market data symbols
-dryRun execute a dry run with volume profile messages written to the console only

The script is located in /opt/deltix/ember/bin folder.

Example use (as docker-compose):

vwap-profile-generator:
image: "registry.deltixhub.com/deltix.docker/anvil/deltix-ember-pack:1.10.42"
depends_on: [ timebase ]
environment:
- JAVA_OPTS=
-Xms256m
-Xmx256m
entrypoint:
- /opt/deltix/ember/bin/volume-profile-publisher.sh
- $${JAVA_OPTS}
- -timebase
- dxtick://timebase:8011
- -marketStreams
- COINBASE,BINANCE,KRAKEN
- -profileStream
- vwap-profile