Trade
Overview
TT Platform
Description
Task
Browser Access
Description
Task
Videos
TT Desktop
Description
Task
Videos
Reference
Workspace Windows
Description
Task
Videos
Widgets
Description
Task
Preferences
Description
Viewing Market Data
Time and Sales
Task
Reference
Description
Depth
Description
Task
Reference
Market Grid
Description
Task
Videos
Reference
Product Grid
Description
Task
Reference
Spread Matrix
Description
Task
Videos
Reference
Basic Order Entry
TT Order Types
Description
Task
Videos
Reference
Case Studies
TT Premium Order Types
Description
Task
Reference
Order Ticket
Description
Task
Use Cases
Reference
MD Trader®
Description
Task
Videos
Reference
Order Profiles
Description
Task
Reference
Routing Rules
Description
Task
Blocktrader
Description
Task
Videos
Reference
Trading Crypto on TT
Description
Task
Videos
Reference
Trading on B3
Order Management
Order Book
Description
Task
Reference
Floating Order Book
Description
Task
Reference
Fills
Description
Task
Reference
Positions
Description
Task
Reference
Orders and Fills
Description
Task
Reference
Audit Trail
Description
Task
Reference
Audit Query
Description
Task
Reference
Account List
Description
Task
Videos
Reference
Position Manager
Description
Task
Reference
Alert Manager and Alert Viewer
Description
Task
Videos
Reference
Account & User Restrictions
Description
Task
Reference
Balances
Description
Task
Reference
TT® OMS
Care Orders
Description
Task
Videos
Reference
Lock and Release
Description
Task
Bulking
Description
Task
Videos
Stitching and Splitting
Description
Task
Combining
Description
Task
Order Passing
Description
Task
Use Cases
Order Exceptions
Description
Task
Options
Options on TT
Description
Videos
Options Chain
Description
Task
Use Cases
Videos
Reference
Options Trade Monitor
Description
Task
Videos
Reference
Vol Curve Manager
Description
Task
Use Cases
Videos
Reference
Electronic Eye
Description
Task
Videos
Reference
RFQ Viewer
Description
Task
Videos
Reference
RFQ with Counterparties
Description
Task
Counterparty Manager
Description
Task
Strategy Creation
Description
Task
Use Cases
Reference
Options Risk
Description
Task
Videos
Reference
Options Risk Matrix
Description
Task
Videos
Reference
Watchlist
Description
Task
Videos
Reference
Expiration Manager
Description
Task
Volatility Calculator
Description
Task
TT Uncovered 2.0
Description
Task
TT Uncovered 3.0
Description
Task
QuikStrike
Description
Task
Spread Trading
Autospreader
Description
Task
Use Cases
Videos
Reference
Autospreader Rules
Description
Task
Videos
Reference
Hedge Manager
Description
Task
Videos
Reference
Trading in Yield
Description
Task
Use Cases
Reference
Aggregator
Description
Task
Videos
Reference
Algo Trading
Algo Dashboard
Description
Task
Videos
Reference
Template Manager
Description
Task
Order Management Algos (OMAs)
Autotrader
Description
Task
Reference
Videos
Excel integration with TT
Description
Task
Videos
Reference
Market-Making Algos
Analytics
Charts
Description
Technical Indicators
Task
Videos
Reference
Trader Analytics
Description
Task
Reference
ADL
ADL Overview
Introduction to ADL
Description
Task
Videos
Reference
ADL Basic Concepts
Description
Task
Reference
Building your first algo
Lessons
Advanced concepts
Description
Task
Case Studies
Jump blocks
Group blocks
Virtualized blocks
Library blocks
Trading Blocks
Discrete blocks
Arithmetic blocks
Basic blocks
Logic blocks
Miscellaneous blocks
Setup
Setup Overview
Getting Started
Description
Task
Videos
Reference
Supported Order Types and TIFs
Company Administration
Connections
Description
Task
Videos
Reference
Accounts
Description
Task
Videos
Use Cases
Reference
Users
Description
Task
Videos
Reference
Company
Description
Task
Reference
Order Tag Defaults
Description
Task
Account Administrators
Description
Task
TT Premium Services
Description
Task
TT Access
Description
Task
Advanced Features
Description
Risk Management
Risk Administration
Description
Task
Risk Limits
Description
Task
Videos
Reference
Pre-Trade Portfolio Risk
Description
Task
Reference
Order Cross Prevention
Description
Task
Videos
KRM Limits
Description
Task
TT® OMS
TT OMS Administration
Description
Task
Use Cases
Reference
Exchanges: Americas
B3
Description
Task
CBOE
Description
Task
Cboe FX
Description
Task
Reference
CFE
Description
Task
CME
Description
Task
Dealerweb
Description
Task
EBS Direct
Description
Task
EBS Market
Description
Task
Fenics
Description
Task
FMX
Description
Task
FMX_USTF
Description
Task
Goldman Sachs Commodity Blocks (GSCB)
Description
Task
Referece
ICE
Description
Task
MexDer
Description
Task
MIAX_FUT_CH
Description
Task
MIAX_FUT_NY
Description
Task
MX
Description
Task
Nodal
Description
Task
NFI
Task
Exchanges: EMEA
ATHEX
Description
Task
BIST
Description
Task
DGCX
Description
Task
EEX
Description
Task
EPEX SPOT
Description
Task
Reference
Eris
Description
Task
Eurex
Description
Task
Videos
Euronext
Description
Task
GFO-X
Description
Task
ICE_L
Description
Task
JSE
Description
Task
LME
Description
Task
LME NTP
Description
Task
LSE
Description
Task
MEFF
Description
Task
NDAQ_EU
Description
Task
NASDAQ_NED
Description
Task
Nord Pool
Description
Task
Reference
WSE
Description
Task
Exchanges: Asia/Pacific
ABX
Description
Task
ASX
Description
Task
FEX
Description
Task
HKEx
Description
Task
JPX
Description
Task
NSE
Description
Task
NZX
Description
Task
SGX
Description
Task
SGX GIFT
Description
Task
TAIFEX
Description
Task
TFEX
Description
Task
TFX
Description
Task
CoinFLEX
Task
Exchanges: Crypto
Coinbase
Description
Task
Kraken
Description
Task
FIX Support
FIX Ruleset
Description
Task
FIX Sessions
Description
Task
Secondary Accounts
Description
Task
Monitor
TT Mobile
TT Backtesting
APIs
TT REST API 2.0
Getting Started
API Reference
TT REST API 2.0 (UAT)
Getting Started
API Reference
TT .NET SDK
Getting started with TT .NET SDK
Creating the application framework
Working with instruments
Subscribing for market data
More about prices
An in-depth look at the Price class
Working with orders and fills
Handling trade subscriptions
Working with trade subscriptions
Working with Algos
Algo Server
TT Order Types
TT Premium Order Types
Advanced Concepts and Options
Appendix
TT CORE SDK
Getting Started with TT Core SDK
Creating Application Framework
Working With Instruments
Subscribing for Market Data
Working with Orders and Fills
Creating a TT Application Server
Appendix
TT Trade Surveillance
Overview
Using TT Trade Surveillance
Cluster View
Core Models
Market Abuse Models
Cross Product Models
Spoofing Models
Improperly Matched Trade Models
Market Rate Models
Trading Behaviors Models
Miscellaneous Models
Configurable Models
Reports
Wachlists
Reference
TT FIX Services
TT FIX General
Getting Started
FIX Message Structure
Session messages
TT FIX Order Routing
Overview
TT FIX message conversations
Supported application messages
TT FIX Market Data
Overview
TT FIX message conversations
Supported application messages
TT FIX Drop Copy Out
Overview
TT FIX Message Conversations
Supported application messages
Compliance Feed messages
TT FIX Drop Copy In
Overview
Supported application messages
TT FIX Gateway
Getting Started
FIX Message Structure
Components
Session messages
Price Gateway Messages
Order Gateway Messages
TT FIX Recovery
Overview
FIX Recovery Methods
Supported application messages
Compliance Feed Messages
MiFID II Support

Capturing fills data

On this page

In this section, you will create the logic to extract data from your entry order fills and use the data to calculate your running average open price. The average open price will later be used to calculate the exit price of our Scalper algo.

Add-PIC

This section covers:

  • The difference between continuous and discrete messages.
  • Using ADL’s Formula Editor.
  • Using the math blocks to perform calculations.

Messages in ADL: Continuous Messages vs Discrete Messages

Data passed between blocks in ADL are referred to as messages. The two types of messages in ADL are:

  • Continuous Messages: a continuous input of specified data.
  • Discrete Messages: an individual message sent at a specific point in time, triggered by an event, storing details about the event in fields.

Thus far, the blocks of the Scapler algo use continuous messages:

  • The Instrument block outputs a continuous feed of instrument data.
  • The Field block continuously outputs the Best Bid price for the selected instrument.
  • The Number block provides a continuous output of 5.

Next, you will use discrete event messages such as those emitted through the Entry Order block’s fills output port which outputs an individual discrete message for each fill that occurs using the orders placed by this block.

The fills discrete message contains fields that capture information about the fill, such as the fill price and fill quantity.

Calculating the average open price

The Scalper algo will calculate the average open price of all executed entry orders. This will later be used to calculate the exit price. To calculate the average open price:

  • Calculate value at risk which is the cost of your position.
  • Total the fill quantities of all entry orders.
  • Divide the value at risk by the total fill quantities to determine the average open price.

Calculating the value at risk

As fills are received from your entry order, the total cost of those fills can be calculated by multiplying the price by the quantity of each fill. The ValueAccumulator block lets you perform this calculation for each fill and then accumulates a running total of each result. The block uses the provided formula to calculate a new value to accumulate each time a discrete message enters the block.

To calculate the value at risk from your order fills:


  1. From the Blocks panel, locate the ValueAccumulator block and place it on the canvas to the right of the Entry Order block.


  2. Connect the fills output port of the Entry Order block to the top input port of the ValueAccumulator block.

    Notice that the edge displays differently to provide a visual indication that this edge passes discrete messages.

  3. In the Block Properties panel, set the Name to VAR.

  4. Define the formula for the block to use in its calculations by clicking the edit link in the Formula field.

    The Formula Editor for the block appears.

  5. In the Formula Builder, you will create a formula to multiply the fill price and the fill quantity to determine the cost of the incoming fill.

    To access discrete message fields sent into the block, you type #, followed by the name of the value you want to use. The editor displays the available message fields as you type.

    • Type # and select fillPrice from the list to add the fillPrice field to the formula.


    • Type * for multiplication and then select the fillQuantity field to complete the formula.


    • Click Save.

      Notice the Formula field of the Block Properties now shows the block formula.

Tracking the total filled quantities

To determine the average price of all fills received for your order, you need to keep track of quantities of all fills. In a similar manner used to calculate the value at risk, you will use the ValueAccumulator block to keep a running total of the fill quantities.

To track the total filled quantities:


  1. Drag another ValueAccumlator block to the canvas beneath the VAR block and connect it to the Entry Order fills output port.


  2. In the Block Properties panel, set the Name to Fill Qty.

  3. Open the Formula Editor and type # to add the fillQty field to the formula.


  4. Click Save.

Calculate the average open price

Finally, you need to use the values from the VAR and Fill Qty blocks to determine the average open price. You will use the Divide block to perform this calculation.

To determine the average open price:


  1. From the Blocks panel, drag a Divide block to the canvas. Rename it to Average Open Price.



  2. Connect the top numeric output port of the VAR block to the top input port of the Average Open Price block.

  3. Connect the top numeric output port of the Fill Qty block to the bottom input port of the Average Open Price block.


Testing your logic

Before continuing with the algo, it is a good idea to test your fills logic to make sure it is functioning as intended.

To test your logic, using the same setup as before:

  1. In the Values tab, enter a larger order quantity so you can verify each fill updates the blocks values properly.
  2. Play the algo and watch the numeric outputs of the VAR, Fill Qty and Average Open Price blocks to ensure they are updating as expected.


  3. Stop the algo.

You have successfully completed capturing data from your fills and performing calculations with the data. Now you are ready to use these values to determine the price and quantity for your exit order.