Conditional Order

Using logic considering price/time conditions, TaaS can delay an order until those conditions are met. Once the order is released, this condition is not re-evaluated or considered in order execution.

A Green Tick indicate that Condition is Valid
Viewing conditional orders

Symbols

Valid Dynamic Terms

Pair Price

{Pair}@{Exchange} // ex. ETH:PERP-USDT@Bybit

Order Fields

:qty // order qty in target token

orders are submitted with either base_asset_qty or quote_asset_qty, which is targeting the base or quote token. Ex. :qty will evaluate to 150 if your order is BUY 150 ETH or 100,000 if BUY 100,000 USDT of ETH

:current_target // current scheduled target qty

the engine tries to place up to a certain amount at all times and this value changes over time

:filled // executed qty in target token

always converted to target token same as :qty

Current Time

TIME // current time in UTC

Valid Operators

  • max ( ) , min ( )

  • +, -, *, /, ** (exponentiate) , % (modulo)

  • >= , <= , > , < , == , !=

  • AND , OR

Note the differences between the initialization (?=), assignment (:=), and comparison (==) operators.

Sample Use Cases

Time Conditions

Using TIME as a placeholder for the current time, you can set a time in the future to trigger an order. For example, this order will run on midnight (UTC) on 2023-09-24:

TIME > dt2023-09-24T00:00

Price Conditions

By using the common placeholder <Token Pair>@<Exchange>, you can assign a price condition. For example, this order will only run when BTC-USDT on Binance hits 30,000 or more:

BTC-USDT@Binance > 300000

Note: If you would like the algo order to only trade above this price as well, be sure to place a limit price as well.

Using basic math operators, you can also specify ratios to trigger orders. For example, this order will run when the BTC/ETH ratio reaches 20 on Binance:

( BTC-USDT@Binance / ETH-USDT@Binance ) > 20

Taking advantage of other operators, another example can be an order that only triggers when the spread between ETH and ETH:PERP reaches a certain threshold:

( ETH-USDT@Binance - ETH:PERP-USDT@Binance ) > 1

Variable Tracking

In certain scenarios, a previous state may be needed to facilitate the right condition. In this case, you can set variables to track through each consecutive evaluation. There are three operators that faciliate variable tracking:

  • To assign a value to keep track <Variable name> := <Dynamic value>

  • To assign a value only if null (for initialization) <Variable name> ?= <(Dynamic) Value>

  • To end line and go to the next clause ;

A perfect example is a trailing stop:

TRAILING_STOP ?= BTC-USDT@Binance * 0.7 ;
TRAILING_STOP := MAX ( BTC-USDT@Binance * 0.7 , TRAILING_STOP ) ;
TRAILING_STOP > BTC-USDT@Binance

Breaking down this complex example line-by-line:

  • TRAILING_STOP ?= BTC-USDT@Binance * 0.7 ;
  • Set the initial value of the TRAILING_STOP variable to 30% away from the current price. This line will not be run unless the TRAILING_STOP variable is null, which is only true on the first evaluation.

  • TRAILING_STOP := MAX ( BTC-USDT@Binance * 0.7 , TRAILING_STOP ) ;
  • On the evaluation, set the value of TRAILING_STOP to the higher of either the current 30% away on BTC-USDT or the previous TRAILING_STOP

  • TRAILING_STOP < BTC-USDT@Binance
  • Run the order if the ultimate condition of BTC-USDT price is less than the TRAILING_STOP price

Was this helpful?