Available translations

Open Stage

foundations.png
open-stage.png
The open stage deals with the definitions that make up the logic to enter a position, including the target rate and size, and order execution.
Content
The open stage comes into play once the take position event is triggered.
Conceptually, the open stage deals with the details concerning how the position shall be opened once the decision to take a position has been made. That is, the open stage does not participate in the process of deciding whether a position should be open or not.
To take a position, several definitions are required. In particular, those concerning targets, such as the rate and size of the position, and the logic of the execution strategy, that is, how many of which orders shall be placed at the exchange—and when—to enter the position.
The open stage closes as soon as one of the following events happen:
  • the target size gets filled,
  • the close stage event is triggered,
  • the take profit or stop loss targets are hit.
Foundations->Topic->Why My Stage is not Closing?->The Stage Does Not Close
The Stage Does Not Close
One common issue users have while dealing with stages is that they do not get closed after their orders get filled. This usually happens because there are several adjustments on rate that happens during trading, specially during live trading. The reason a Stage does not get closed automatically is because the total filled for the whole stage is not close enough to the Stage Target Size defined by users. In order to avoid this situation there are three configurations at the Stage node you can use:
  • ROUNDING_ERROR_CORRECTION_FACTOR: is a configurable factor that can be applied to the stage filled at runtime in order to force it to reach the Stage Target Size. The default value for this factor is:
 ROUNDING_ERROR_CORRECTION_FACTOR = 1.001
This value is overwritten by whatever users config at the Stage node under the roundingErrorCorrectionFactor property.
A value of 1.01 would mean that when the Filled amount is at 1% distance from the Stage Target, the stage will be closed.
  • ABSOLUTE_DUST_IN_BASE_ASSET: is a numeric value that represents the distance that you allow to be between the Size Filled and the Target Side for a stage, measured in Base Asset. It's default value is Zero and you can define it at the config of a Stage node using the absoluteDustInBaseAsset property.
  • ABSOLUTE_DUST_IN_QUOTED_ASSET: is a numeric value that represents the distance that you allow to be between the Size Filled and the Target Side for a stage, measured in Base Asset. It's default value is Zero and you can define it at the config of a Stage node using the absoluteDustInQuotedAsset property.
Implementation
Here you can see how these parameters are implemented in the Low Frequency Trading Bot code:
         if (
            tradingEngineStage.stageBaseAsset.sizeFilled.value
            *
            ROUNDING_ERROR_CORRECTION_FACTOR
            +
            ABSOLUTE_DUST_IN_BASE_ASSET
            >=
            tradingEngineStage.stageBaseAsset.targetSize.value
        ) {
            positionFilled()
        } else if (
            tradingEngineStage.stageQuotedAsset.sizeFilled.value
            *
            ROUNDING_ERROR_CORRECTION_FACTOR
            +
            ABSOLUTE_DUST_IN_QUOTED_ASSET
            >=
            tradingEngineStage.stageQuotedAsset.targetSize.value
        ) {
            positionFilled()
        } else {
            checkCloseStageEvent(tradingSystemStage)
        }
Initial Values
These are the Initial Values for Open Stage configuration:
 {
    "roundingErrorCorrectionFactor": 1.01,
    "absoluteDustInBaseAsset": 0,
    "absoluteDustInQuotedAsset": 0
}
Examples
This is a list of properties featured by the Open Stage configuration. Expanding a property shows sample values for the property extracted from the current Workspace.
Open Stage Menu
The Open Stage node has the following Node Menu items:
The Configure menu item has the following properties:
  • action: Configure
  • actionFunction: uiObject.configEditor.activate
  • label: Configure
  • iconPathOn: configuration
  • iconPathOff: configuration
The Add Missing Items menu item has the following properties:
  • action: Add Missing Children
  • label: Add Missing Items
  • relatedUiObject: Open Stage
  • actionFunction: payload.executeAction
  • actionProject: Visual-Scripting
  • relatedUiObjectProject: Foundations
The Add Announcement menu item has the following properties:
  • action: Add UI Object
  • label: Add Announcement
  • actionFunction: payload.executeAction
  • relatedUiObjectProject: Social-Bots
  • actionProject: Visual-Scripting
The Delete menu item has the following properties:
  • action: Delete UI Object
  • actionProject: Visual-Scripting
  • askConfirmation: true
  • confirmationLabel: Confirm to Delete
  • label: Delete
  • iconPathOn: delete-entity
  • iconPathOff: delete-entity
  • actionFunction: payload.executeAction
Open Stage Children
The Open Stage node has the following childrenNodesProperties:
The Initial Targets node property features the following properties:
  • name: initialTargets
  • type: node
  • autoAdd: true
The Open Execution node property features the following properties:
  • name: openExecution
  • type: node
  • autoAdd: true
The Close Stage Event node property features the following properties:
  • name: closeStageEvent
  • type: node
  • autoAdd: true
The Announcements node property features the following properties:
  • name: announcements
  • type: array
  • project: Social-Bots
The User Defined Code node property features the following properties:
  • name: userDefinedCode
  • type: node
  • autoAdd: false
Open Stage Attaching Rules
The following are the Node Attaching Rules that govern the attachment of Open Stage with other nodes:
Compatible Types: