Skip to main content

Ember Console Application (CLI)

Overview

This document describes the Ember Console Application, ember-cli, which is a command-line tool that can be used to:

  • Submit, replace, cancel, mass-cancel, and discard orders
  • Request order status and mass status
  • Halt or resume trading, and query halt state
  • List services and risk table limits
  • Import risk limit updates from CSV
  • Query and reset positions

The CLI requires Ember to be running, and it communicates with the Ember server using the EMBER_HOME environment variable (and EMBER_WORK variable if Ember is running with separated home/work directories). Alternatively, Java system properties ember.home and ember.work can be used instead of environment variables.

Supported Commands

Here is a list of the supported commands that can be listed by the CLI help command:

$ export EMBER_HOME=/path/to/ember
$ $EMBER_HOME/bin/ember-cli
==> help
Usage:
set [<attribute_name> [<attribute_value>]]]
unset [<attribute_name>] [<attribute_name>]
submit [-f] [-n <number_of_orders>] [<orderId>]
replace [-f] [<originalOrderId> [<newOrderId>]]
cancel [-f] [<orderId> [<reason>]
mass-cancel [-f] [-a <account>] [-t <traderId>] [-e <exchangeId>] [-r <reason>] [-c ALL|SOURCE]
status [<orderId>]
mass-status [-a <account>] [-t <traderId>] [-e <exchangeId>]
discard [-f] [<orderId> [<reason>]]
halt-state [<projectionPath>]
halt [-f] [projectionPath> [<reason> [CANCEL]]]
resume [-f] [<projectionPath> [<reason>]]
sleep [<interval>] (1s is default)
list-services
list-risk-table <projection>
import -risk <userId> <csvFile>
reset-positions [-f][<daily>]
position <projection> [-account <v>] [-trader <v>] [-traderGroup <v>] [-userData <v>] [-moduleKey <v>] [-portfolioKey <v>] [-src <v>] [-dst <v>] [-exchange <v>]
exit
help [<command>]

The table below provides an overview of the above commands:

CommandDescription
setAllows setting attributes of requests sent by other commands, such as submit, replace, cancel, status, discard, halt, and resume. It shows the current values of the attributes if entered without any parameters.
unsetClears attributes specified on the command line or clears all attributes when entered without parameters.
submitSends a new order request. It allows specifying an order ID for the new order on the command line. If not specified, it uses the orderId attribute set with the set command or generates a new unique ID for the order.

The -n option allows you to issue multiple new order requests with a single command. For multiple orders, this command uses a specified or generated order ID for the first order, and then uses it as a prefix in the IDs of all the remaining orders issued by this command.
replaceSends a replace order request. It allows specifying the original and new order IDs on the command line or in context properties modified by the set command. If IDs are omitted, it uses the order ID of the last order issued during the CLI session as the original order ID, and generates an ID for the new order ID.
cancelSends an order cancel request. It allows specifying an order ID on the command line or in context properties. If omitted, it tries to use the ID of the last order issued during the CLI session.
mass-cancelSends a mass-cancel request for active orders that match optional filter parameters (-a account, -t traderId, -e exchangeId). Optional -r sets the cancel reason. Optional -c selects cancel type ALL or SOURCE (default is SOURCE). Uses sourceId from context properties.
statusSends an order status request. It allows specifying an order ID on the command line or in context properties. If omitted, it tries to use the ID of the last order issued during the CLI session.
mass-statusSends a mass-status request to Ember and returns the status of active orders that match filter parameters. It takes the account, traderID, and exchangeID on the command line, and the sourceID from context properties.
discardSends an order discard request. It allows specifying an order ID on the command line or in context properties. If omitted, it tries to use the ID of the last order issued during the CLI session.
halt-stateRequests the current kill-switch / halt state for a projection path. The projection path can be specified on the command line or in context with the set command; if omitted, the root projection is used.
haltHalts trading for a specified projection path. Projection path and reason parameters can be specified on the command line or in context with the set command. Optional CANCEL also cancels orders under that path.
resumeResumes trading for a specified projection path. Projection path and reason parameters can be specified on the command line or in context with the set command. See example below.
sleepPauses execution for a specified interval.
list-servicesLists Ember algorithms and trade connectors.
list-risk-tableLists risk table limits configured for a specified projection on the command line. The projection parameter should specify one of the projections in the Ember risk config.
importImports risk limit updates from a CSV file and sends a risk update request for each line. Currently only -risk import type is supported. Requires a user ID (set as changedByUserId on each request) and a path to the CSV file. See Import risk limits below.
reset-positionsResets positions. Optional true/false argument selects daily vs non-daily reset (default is non-daily). Prompts for confirmation unless -f is specified.
positionRequests positions for a required projection (for example Account/Symbol). Optional filters (-account, -trader, -traderGroup, -userData, -moduleKey, -portfolioKey, -src, -dst, -exchange) narrow the request. Uses sourceId from context properties when set.
exitExits the CLI session.

All the commands making changes (i.e., submit, replace, cancel, mass-cancel, discard, halt, resume, and reset-positions) display the request parameters and prompt the user for confirmation before sending the request to Ember.

Most of those commands accept an optional -f flag. When set, commands issue requests without prompting for confirmation.

The import command does not prompt for confirmation: it validates the entire CSV first, and only then sends the requests.

set command

The set command allows users to set attributes for requests sent by various commands such as submit, replace, cancel, status, discard, halt, and resume.

Users can view all the supported attribute names and their current values by entering the set command without any parameters. Entering the set command with just an attribute name parameter will show current value of the attribute.

Attribute values that contain space characters should be enclosed in quotes. These attribute values are persisted between CLI sessions in the <ember.work>/ember-console.properties file.

Below is an example demonstrating how to set order parameters and submit an order:

set side BUY
set quantity 1
set symbol BTCUSD
set orderType MARKET
set account "Gold 1"
submit

Custom order parameters can be entered using their numeric keys:

set attributes 6100=MARKER,6101=00:00:00.500

You can escape commas in attribute values by using a slash:

set attributes 7001=REJECT,DISCONNECT,DELAY:5,CONNECT,7002=Test

The current version of the tool requires you to set all custom attributes at once. If you need to change one attribute, you need to resubmit the entire set.

Examples

Cancel or Discard order

This example shows how to cancel order MM:1755772217755119:

==> set sourceId MM
==> cancel -f 1755772217755119

Similarly order can be discarded (discard simply marks order as cancelled without attempting to cancel it):

==> set sourceId MM
==> discard -f 1755772217755119

Mass-cancel orders

Cancel active orders for the current sourceId (default cancel type is SOURCE):

==> set sourceId MM
==> mass-cancel -f

Cancel all matching orders for an account, with a reason:

==> mass-cancel -f -a "Gold 1" -c ALL -r "End of day cleanup"

Halt state

Query whether trading is halted at the root level:

==> halt-state

Query halt state for a specific projection path:

==> halt-state Destination[OKX]

Resume trading

When trading was halted at the root level:

==> resume

When trading was halted at a specific projection (for example for Destination OKX):

==> resume Destination[OKX]

Import risk limits

Import risk limit INSERT/UPDATE/DELETE commands from a CSV file:

==> import -risk Admin risk-limits.csv

The CSV has no header. Blank lines are skipped. Each non-blank line has this form:

<INSERT|UPDATE|DELETE>,<projectionPath>[,<LimitName>=<value>...]

Examples:

INSERT,Account[*]/Symbol[BTCUSD],MaxOrderSize=550.4,MaxPositionLong=,MaxPositionShort=20000
UPDATE,"Account[A,B]/Symbol[BTCUSD]",MaxOrderSize=10
DELETE,Account[GOLD]/Symbol[BTCUSD]

Notes:

  • Projection path uses the same Name[Value] format as other Ember projection paths (for example Account[*]/Symbol[BTCUSD]). * is allowed as a risk-table wildcard in projection values.
  • Fields that contain commas must be CSV-quoted.
  • An empty limit value (for example MaxPositionLong=) means the limit is unset (null).
  • DELETE lines must not include limit fields.
  • Before sending anything, the command validates that each projection exists in risk.riskTables and that each limit name is defined for that projection. If validation fails, the import is aborted and no requests are sent.
  • On success, one risk update request is sent per CSV line, and the CLI prints how many requests were sent.

Query positions

Request positions for the Account/Symbol projection, optionally filtered by account:

==> position Account/Symbol -account "Gold 1"

Reset positions

Reset non-daily positions (with confirmation):

==> reset-positions

Reset daily positions without confirmation:

==> reset-positions -f true