Unified Execution

Unified execution is an alternate way to structure a strategy, and it's cognitively more complex but provides a more flexible and efficient foundation for trading logic.

Getting Started

  1. 1.
    Tick the box "Use unified execution" in Options > Advanced Options
  2. 2.
    Update your strategy to adhere to the new data interface

Notable Changes

  • Your strategy will execute only once for each decision interval instead of one time per ticker
  • You must pass a ticker parameter as seen in the example to get a bar or indicator value.
  • Signals need an asset specified through the ticker parameter

Strategy Examples

Default Execution

This strategy will buy and sell based on the follwing logic for each asset you've selected:
def handle_new_bar(data: VelocitySlice, emit: Emit, atoms: VelocityAtomManager):
if data.SMA(ln=20) > data.SMA(ln=200):
emit.Buy(unit="shares", value=10)
if data.SMA(ln=20) < data.SMA(ln=200):

Unified Execution

With this execution model you have to include a ticker for every call to get data
def handle_new_bar(data: VelocitySlice, emit: Emit, atoms: VelocityAtomManager):
# enter MSFT position based on AAPL's SMA crossover
if data.SMA(ln=20, ticker="AAPL") > data.SMA(ln=200, ticker="AAPL"):
emit.Buy(unit="shares", value=10, ticker="MSFT")
# exit MSFT position based on MSFT's SMA crossover
if data.SMA(ln=20, ticker="MSFT") < data.SMA(ln=200, ticker="MSFT"):
emit.Sell(unit="max", ticker="MSFT")
Last modified 3mo ago