Sequence #
The sequence
outcome binds multiple outcomes together, making them depend
on each other’s execution results. This outcome may be used to create
complex conditions and fallback mechanisms. For example, it may be used
to send a Telegram message when an order cannot placed, or cancel all open
orders before placing a new one.
The sequence
outcome cannot be backtested. More information about
strategy backtesting can be found
here.
Configuration #
{
"type": "sequence",
"context_id": "sequence-id-123",
"description": "a simple outcome",
"outcomes": [
{
"type": "placeholder"
},
{
"type": "placeholder"
},
{
"type": "placeholder"
}
],
"operator": "or",
"mode": "partial-serial"
}
-
type
- string
The type of the outcome configuration.Outcome configuration types are described in detail here.
-
context_id
- string (optional; default: unused)
The ID of the outcome that is used when inserting data into the context store.The context data store and its IDs are described in detail here.
-
description
- string (optional; default: unused)
The description of the outcome and its purpose. -
outcomes
- array of objects
The array of outcomes to execute. At least two outcomes must be specified.The array of outcomes adheres to the same structuring rules as the array of the top-level outcomes. These rules are described in detail here.
-
operator
- string (enum)
The type of operator to use when building an outcome execution chain. Possible values:-
or
When this operator is active, the execution chain is terminated only when one of the inner outcomes finishes its individual execution successfully.Note that the
sequence
outcome finishes its execution successfully only when at least one of the inner outcomes does so. -
and
When this operator is active, the execution chain is terminated only when one of the inner outcomes produces an error.Note that the
sequence
outcome finishes its execution successfully only when all the inner outcomes do so.
-
-
mode
- string (enum)
The execution mode of the inner outcomes’ array. Possible values:-
full-serial
When this mode is active, all outcomes are executed one after the other until the very end, regardless of the status of the execution chain. This means that all outcomes generate their respective reports, even when their results become irrelevant due to the early termination of the execution chain. The examples below illustrate how this mode works with both operators:-
Example 1 (
or
):
The list of inner outcomes:outcome1(error)
outcome2(success)
outcome3(success)
The list of reports of all executed inner outcomes:
report-outcome1(error)
report-outcome2(success)
report-outcome3(success)
When using the
or
operator, the first outcome that finishes its individual execution successfully terminates thesequence
execution chain. In the example above, the second outcome (i.e.,outcome2
) is the one that triggers the termination of thesequence
chain, which renders the results ofoutcome3
irrelevant. Nevertheless, the report ofoutcome3
is included in the final report of thesequence
outcome. -
Example 2: (
and
):
The list of inner outcomes:outcome1(success)
outcome2(error)
outcome3(success)
The list of reports of all executed inner outcomes:
report-outcome1(success)
report-outcome2(error)
report-outcome3(success)
When using the
and
operator, the first outcome that produces an error terminates thesequence
execution chain. In the example above, the second outcome (i.e.,outcome2
) is the one that terminates thesequence
chain, which renders the results ofoutcome3
irrelevant. Nevertheless, the report ofoutcome3
is included in the final report of thesequence
outcome.
-
-
partial-serial
When this mode is active, all outcomes are executed one after the other until one of them triggers the termination of the execution chain. This means that only outcomes that finish their execution before the early termination generate their reports. The examples below illustrate how this mode works with both operators:-
Example 1 (
or
):
The list of inner outcomes:outcome1(error)
outcome2(success)
outcome3(success)
The list of reports of all executed inner outcomes:
report-outcome1(error)
report-outcome2(success)
When using the
or
operator, the first outcome that finishes its individual execution successfully terminates thesequence
execution chain. In the example above, the second outcome (i.e.,outcome2
) is the one that terminates thesequence
chain, which means thatoutcome3
is not executed and thus cannot generate its report. -
Example 2 (
and
):
The list of inner outcomes:outcome1(success)
outcome2(error)
outcome3(success)
The list of reports of all executed inner outcomes:
report-outcome1(success)
report-outcome2(error)
When using the
and
operator, the first outcome that produces an error terminates thesequence
execution chain. In the example above, the second outcome (i.e.,outcome2
) is the one that terminates thesequence
chain, which means thatoutcome3
is not executed and thus cannot generate its report.
-
-
Report #
{
"type": "sequence",
"outcomes": [
{
"type": "placeholder"
},
{
"type": "placeholder"
},
{
"type": "placeholder"
}
]
}
-
type
- string
The type of the outcome report.Outcome report types are described in detail here.
-
outcomes
- array of objects
The array of outcome reports. Note that the number of reports may be smaller than the number of outcomes when the execution termination is triggered and the active mode ispartial-serial
.The array of outcome reports adheres to the same structuring rules as the array of the top-level outcome reports. These rules are described in detail here.
If an error occurs during thesequence
outcome’s execution, onlytype
anderror
properties are added to the report. Theerror
property is described in detail here.
Context #
The sequence
outcome does not insert any objects into the context store.
If an error occurs during thesequence
outcome’s execution, only theoutcomes.<context-id>.error
object is inserted into the context store. This context data object is described in detail here.