Skip to main content
Version: 1.0.0

Signals for Position Management

There are 4 position management signals. They share a few common configuration options.

  • Buy / Short — enter a position
  • Sell / Cover — exit a position
# enter position
def handle_new_bar(data, emit, atoms):
# open long position
emit.Buy(unit="shares", value=10, clobber=True)

# open short position
emit.Short(unit="shares", value=10, clobber=True)

# exit position
def handle_new_bar(data, emit, blocks):
# exit / reduce long position
emit.Sell(unit="shares", value=10)

# exit / reduce short position
emit.Cover(unit="shares", value=10)

Shared Options

value: number value is interpreted according to the unit

unit: string the unit for the value argument.

  • max (default) the max value possible based on the current position, account equity, and max position per asset
  • percent a percentage of the max total amount or the max possible whichever is lower
  • shares a specific number of shares — can't be more than max possible position
  • currency a specific dollar amount — can't be more than max possible position

reason: string shown as the "reason" the order was placed. Great for understanding your portfolio and orders — this appears in the order's description on the chart.

Position Clobbering

clobber: boolean control how your position is managed when you switch between short and long signals

  • true (default) opposite positions are closed before the new order is submitted

    • EXAMPLE if you own 10 shares of AAPL and short 5 shares of AAPL (result: 5 shares short)
  • false the signal changes your position directionally

    • EXAMPLE if you own 10 shares of AAPL and short 5 shares of AAPL (result: 5 shares long)