Position #
The position
tool retrieves the latest position information from the
exchange and compares it to the target value that is specified in the
configuration.
The position
tool cannot be backtested. More information about strategy
backtesting can be found here.
Configuration #
{
"type": "position",
"context_id": "position-id-123",
"description": "a simple tool",
"quote_asset": true,
"condition": {
"type": "constant",
"target": "20",
"operator": "greater-than"
}
}
-
type
- string
The type of the tool configuration.Tool configuration types are described in detail here.
-
context_id
- string (optional; default: unused)
The ID of the tool 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 tool and its purpose. -
quote_asset
- boolean (optional; default: false)
The property that determines whether the symbol’s quote or base asset’s position is used during the tool’s execution. When the symbol is not an asset pair (e.g.,AAPL
), the asset that is represented by the symbol is considered as the base asset.The
position
tool expects the symbols that are using the strategy with this tool to be asset pairs (e.g.,BTC/USD
) whenquote_asset
is set totrue
. -
condition
- object
The condition that is used when checking the position’s quantity.-
type
- string (enum)
The type of the condition that determines what additional properties are required and how the target value is formed. Possible types are as follows:constant
When this type is active, the target value that is specified in the configuration is used as the condition’s target value. The additional properties of this type are the following:target
- string (decimal)
The target value that is used without any additional processing. It cannot be less than 0.
-
operator
- string (enum)
The operator that is used when comparing the position’s quantity to the condition’s target value. Possible values:-
equal
,eq
,==
The equality operator checks if the position’s quantity is equal to the condition’s target value. -
greater-than
,gt
,>
The greater than operator checks if the position’s quantity is greater than the condition’s target value. -
less-than
,lt
,<
The less than operator checks if the position’s quantity is less than the condition’s target value. -
greater-than-or-equal
,ge
,>=
The greater than or equal operator checks if the position’s quantity is greater than or equal to the condition’s target value. -
less-than-or-equal
,le
,<=
The less than or equal operator checks if the position’s quantity is less than or equal to the condition’s target value. -
not-equal
,ne
,!=
The inequality operator checks if the position’s quantity is not equal to the condition’s target value.
-
-
Report #
{
"type": "position",
"permit": true,
"value": "20.5",
"condition": {
"type": "constant",
"result": true
}
}
-
type
- string
The type of the tool report.Tool report types are described in detail here.
-
permit
- boolean
The property that determines whether the tool gave its permission to continue strategy execution or not.The tool execution flow is described in detail here.
-
value
- string (decimal)
The position’s quantity that was retrieved from the exchange and compared to the condition’s target value. -
condition
- object
The report of the condition that was used when checking the position’s quantity.-
type
- string (enum)
The type of the condition that determines what additional properties are included in the report. Possible types are as follows:constant
When this type is processed, no additional properties are added.
-
result
- boolean
The property that determines whether the comparison was successful or not.
-
If an error occurs during theposition
tool’s execution, onlytype
anderror
properties are added to the report. Theerror
property is described in detail here.
Context #
The objects that the position
tool inserts into the context
store are as follows:
-
tools.<context-id>.permit
- boolean
The object that determines whether the tool gave its permission to continue strategy execution or not. -
tools.<context-id>.value
- string (decimal)
The position’s quantity that was retrieved from the exchange and compared to the condition’s target value. -
tools.<context-id>.condition
- map
The results of the condition that was used when checking the position’s quantity.-
The type of the condition determines what additional objects are inserted into the context store. The types and their objects are as follows:
constant
When this type is processed, no additional objects are inserted into the context store.
-
tools.<context-id>.condition.result
- boolean
The object that determines whether the comparison of the position’s quantity and the condition’s target value was successful or not.
-
If an error occurs during theposition
tool’s execution, only thetools.<context-id>.error
object is inserted into the context store. This context data object is described in detail here.