Links

Tradehooks

Learn what are Tradehooks and why are they your strategy's best friend
Tradehooks is our data delivery engine. They keep your strategy updated with relevant information as it becomes available and relevant, saving you from constantly having to chase data.
You can think of Tradehooks as Webhooks (hence the name) that post JSON-formatted data to your strategy, based on a schedule (used to deliver market data "bars/candles") or an event (used to report strategy and system events) – depending on the data.

Tradehook types

There are several types of Tradehooks:
Type
Description
Status
bar
The most common Tradehook. Sends you pricing bars information. Can be based on a schedule or a price event.
Released
order
Sent on any order status change.
Released
price
Sent when a price monitor is triggered (you've registered a price monitor and the price was hit).
Released
position
Sent when a position monitor is triggered (you've registered a position monitor and the target was reached).
Released
error
When something's wrong - we'll send it to you as an "error" Tradehook.
Released
event
Sent on any corporate event including earning, dividend, or split .
Coming soon
news
Sent on every news bulletin related to the asset.
Coming soon

Tradehook-strategy relationship

To have a Tradehook push data to a strategy, you'll need to attach the Tradologics to a Strategy. However, as with most things in Tradologics, there are no one-to-one relationships between objects.
This means that...
  • a single strategy can receive data from multiple Tradehooks
  • a single Tradehook can send data to multiple strategies
Reminder: Strategies in Tradologics are passive. That means instead of actively fetching market data, monitoring trades, or setting up pricing alerts - you set up Tradehooks that will take care of everything for you and push the data to your strategy as it becomes available.

Scheduled Tradehooks

Scheduled Tradehooks are triggers based on predefined intervals that deliver market data to your strategy.
Scheduled Tradehooks are required to run a strategy. They're actually what makes your strategy run. Remember that Tradologics' strategies are passive — meaning that they wait for data to be pushed to them and then react accordingly.
You can think of a scheduled Tradehook as the engine that pushes new bars to a charting program.
A scheduled Tradehook has two parts:
  • What information do you want to be pushed when the Tradehook is invoked?
  • When the information should be pushed to the strategy

The “What”

This section of the Tradehook configuration provides Tradologics with instructions regarding the type and structure of the data you need.
For example, this:
{
"what": {
"assets": ["TSLA:US", "AMZN:US"],
"bar": "1day",
"history": 2
},
"when": { ... },
}
...means: "2 daily bars for both TSLA and AMZN"
Available Parameters
Key
Description
Status
assets
asset (string) or list of assets (array) you need data for.
Released
universes
Universe(s) representing a group of assets (eg. DJ30 will send data for all stocks that are part of the Dow Jones Index).
In beta
pipelines
A list of pipelines data should be passed through before being sent to your strategy.
Coming soon
bar
The bar resolution of the data to be sent (min, hrs, day, week, month, quarter, year).
Released
history
How many bars to send (look-back window).
Released

The “When”

This section of the Tradehook configuration instructs Tradologics when to send the data described in the "what" section.
The when section could be:
  • schedule - data will be sent based on the defined schedule
  • condition - data will be sent one time, once one of the specified conditions is met (for example, price level)

Conditional invocation

Conditional Tradehooks will push data to your strategy only once – when one of your conditions is met.
For example, this:
{
"what": { ... },
"when": {
"condition": [{
"asset": "AAPL:US",
"trigger": "price",
"rule": {
"type": "above",
"price": 200.00
}
}]
}
}
...means: "send me the 'what' data once AAPL goes above $200"
Example workflow:
  • You enter a position once a stock reaches a certain price
  • You create a position and price monitors to trigger your next strategy invocation
  • The rest of the time your strategy is idle

Scheduled Invocations

This is the most commonly used Tradehook, and it works similarly to a bar generator engine on charting platforms.
The scheduled object has the following parameters:
Param
Description
on_days
day (string) or list of days (array) on which the Tradehook should be invoked. Options are: * (everyday), mon, tue, wed, thu, fri, sat, sun, ftdm (first trading day of month), ltdm (last trading day of month) and Ntdm (Nth trading day of month).
exchange
Main exchange MIC Code (used for timezone calculations).
session
Your trading window. Can be either an offset (in minutes) from open/close or specific hours (eg. 10am, 2pm, 14:40).
timing
How often to push data. Can be either an interval (min, hrs, day, week, month, quarter, year), or specific hour or list of hours (eg. 10am, 2pm, 14:40).

Examples

Pre-market bar
Send me the 10 most recent 1-minute bars for GOOG, every day, 10 minutes before XNYS (NYSE) opens
{
"what": {
"assets": [ "GOOG:US" ],
"bar": "1min",
"history": 10
},
"when": {
"schedule": {
"on_days": "*",
"exchange": "XNYS",
"session": {
"open": -10,
"close": 0
},
"timing": "1day"
}
}
}
Custom session
Send me the 60 most recent 15-minute bars, for AAPL and MSFT, every 30 minutes on Monday, Wednesday, and Friday - from 10am to 4pm, based on XNYS (NYSE) market hours.
{
"what": {
"assets": [ "AAPL:US", "MSFT:US" ],
"bar": "15min",
"history": 60
},
"when": {
"schedule": {
"on_days": ["mon", "wed", "fri"],
"exchange": "XNYS",
"session": {
"open": "10am",
"close": "2pm"
},
"timing": "30min"
}
}
}
1-Year bar each quarter
Send me 1 bar representing the most recent 12 months, for assets SPY and TLT, once per quarter on XNYS' market open, on the first trading day of the month.
{
"what": {
"assets": [ "SPY:US", "TLT:US" ],
"bar": "12mo",
"history": 1
},
"when": {
"schedule": {
"on_days": "ftdm",
"exchange": "XNYS",
"session": {
"open": 0,
"close": 0
},
"timing": "1q"
}
}
}
Crude Oil Inventories
Send me the 30 most recent 1-minute bars, for USO ETF, once every Wednesday at 10:30am, based on XNYS (NYSE) timezone.
{
"what": {
"assets": [ "USO:US" ],
"bar": "1min",
"history": 30
},
"when": {
"schedule": {
"on_days": "wed",
"exchange": "XNYS",
"session": {
"open": 0,
"close": 0
},
"timing": "10:30am"
}
}
}

Sent payload

Regardless of the "when" mechanism used – the sent payload will always have the same structure since it is based on the "what" section.
It includes:
  • assets - list of assets sent in this payload
  • bars - the actual pricing information
The bars key is structured in the following hierarchy:
  • Date of the bar – in YYYY-MM-DDTHH:II:SS.MS format
  • Symbol – list of asset identifiers (as used in the Tradehook)
  • Pricing Data (OHLC+VTW)– open, high, low, close, volume, trades, and vwap.
{
"assets": ["AAPL:US"],
"bars": {
"YYYY-MM-01T16:00:00.000000": {
"AAPL:US": {
"o": "113.79",
"h": "117.26",
"l": "113.62",
"c": "115.56",
"v": 136210200,
"t": 782692,
"w": "116.11665173913042"
},
}
}
}
Further reading:
  • Tradehooks API specifications
  • Order Tradehook payload structure

Event-based Tradehooks

​Monitors let you register for certain events. When an event occurs, this will trigger a Tradehook push containing the relevant information. There are several event-based (a.k.a. monitors) Tradehooks currently supported by Tradologics:
  • Order status
  • Price alerts
  • Position/PnL alerts
Let's take a look at each one in more detail...

Order status

An Order Tradehook will send the order status information whenever the status changes. When the monitor triggers, an Order Status JSON payload will be pushed to the strategy associated with that order and will be sent by the Tradehook engine.
When you submit an order- you will receive a Tradehook on every order status change until the order is either: fully filled, canceled, rejected, or expired.
Order Status Tradehooks are an integral part of Tradologics and there is no way to "opt-out" of them. As such, they are not considered “operations you initiate with the platform” and will not count towards your action usage.
Further reading:

Price alerts

Price alerts are the result of a triggered price level monitor. You can create a price monitor from the UI, or by issuing a POST request to /monitor/price.
Further reading:

Position alerts

Position alerts are very similar to the Price Tradehook, except they receive issues on a triggered PnL threshold is met. You can create a position monitor from the UI or by issuing a POST request to /monitor/position.
Further reading:
Last modified 1yr ago