Composes a specific deployment configuration into Rainlang code.
A deployment combines an order definition with a scenario to create a complete configuration ready for deployment. This method resolves the deployment's scenario and composes the Rainlang code with the appropriate bindings.
// Compose a production deployment
const result = await dotrainOrder.composeDeploymentToRainlang("production");
if (result.error) {
console.error('Failed:', result.error.readableMsg);
} else {
const rainlang = result.value;
// Do something with the rainlang
}
Name of the deployment defined in the dotrain YAML frontmatter
Composed Rainlang code for the deployment's scenario
Composes handle-add-order entrypoint for a specific scenario into Rainlang code for immediate execution after an order is added.
This is useful for scenarios that need to perform actions immediately after an order is added.
const result = await dotrainOrder.composeScenarioToPostTaskRainlang("scenario");
if (result.error) {
console.error('Failed:', result.error.readableMsg);
} else {
const postTaskCode = result.value;
// Do something with the postTaskCode
}
Name of the scenario defined in the dotrain YAML frontmatter
Composed handle-add-order Rainlang code with scenario bindings applied
Composes a specific scenario into Rainlang code.
Takes a scenario name from the dotrain configuration and composes the Rainlang code with that scenario's bindings applied.
// Compile a trading scenario
const result = await dotrainOrder.composeScenarioToRainlang("market-making");
if (result.error) {
console.error('Failed:', result.error.readableMsg);
} else {
const rainlang = result.value;
// Do something with the rainlang
}
Name of the scenario defined in the dotrain YAML frontmatter
Composed Rainlang code with scenario bindings applied
Returns the original dotrain text used to create this DotrainOrder instance.
const result = dotrainOrder.dotrain();
if (result.error) {
console.error('Failed:', result.error.readableMsg);
} else {
const dotrain = result.value;
// Do something with the dotrain
}
The complete dotrain text including YAML frontmatter and Rainlang code
StaticcreateCreates a new DotrainOrder instance by parsing dotrain configuration text along with additional configuration.
Parses the YAML frontmatter and validates the configuration including:
// Basic usage
const result = await DotrainOrder.create(dotrainText);
if (result.error) {
console.error('Failed:', result.error.readableMsg);
} else {
const dotrainOrder = result.value;
// Do something with the dotrainOrder
}
// With additional settings
const result = await DotrainOrder.create(dotrainText, [additionalConfig]);
if (result.error) {
console.error('Failed:', result.error.readableMsg);
} else {
const dotrainOrder = result.value;
// Do something with the dotrainOrder
}
Complete dotrain text containing YAML frontmatter and Rainlang code
Optionalsettings: null | string[]Optional additional YAML configuration strings to merge with the frontmatter
Successfully parsed and validated DotrainOrder instance
DotrainOrder represents a parsed and validated dotrain configuration that combines YAML frontmatter with Rainlang code for orderbook operations.
A dotrain file contains:
This struct provides methods to compose scenarios and deployments into Rainlang code with scenario-specific bindings applied.
Examples