Curfew

Curfew #

The curfew tool checks if the strategy’s execution time matches at least one of the specified schedules. Note that they are checked only when this tool is executed, which means that schedules with small execution intervals may cause the tool to produce a negative result (an indication that further execution is not permitted) by the time they are processed.

The curfew tool can be backtested. More information about strategy backtesting can be found here.

Configuration #

{
	"type": "curfew",
	"context_id": "curfew-id-123",
	"description": "a simple tool",
	"time_zone": "Europe/London",
	"schedules": [
		"0 4 8-14 * *",
		"10-15 * 10,20 * *",
		"0 0-10/3 0 7 0",
		"0 0-10/3,12,15-17 0 7 0",
		"* * 5 * * 2021",
		"@hourly"
	]
}
  • 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.

  • time_zone - string (optional; default: UTC)
    The time zone to use when checking the schedules.

    The complete list of available time zones can be found here (TZ database name column). A special Local time zone that represents the system’s local time zone may be used as well.

  • schedules - array of strings
    The array of schedules to check when executing the tool. At least one schedule must be specified.

    A schedule string must be a valid cron expression (i.e., <minute> <hour> <day> <month> <weekday> with an optional <year> value at the end). Each segment of the expression may also contain the following symbols:

    • Comma (,)
      A comma may be used to specify multiple values (e.g., 15,30,45 * * * * matches the 15th, 30th and 45th minutes).

    • Dash (-)
      A dash may be used to specify a range of values (e.g., 15-45 * * * * matches every minute between the 15th and 45th).

    • Slash (/)
      A slash may be used in combination with a dash to specify a range of values with a custom step (e.g., 15-45/2 * * * * matches every other minute between the 15th and 45th).

    Instead of a long cron expression, a schedule string may contain one of the following tags: - @yearly or @annually - @monthly - @weekly - @daily - @hourly

    Cron expressions can be tested here.

Report #

{
	"type": "curfew",
	"permit": 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.

If an error occurs during the curfew tool’s execution, only type and error properties are added to the report. The error property is described in detail here.

Context #

The objects that the curfew 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.
If an error occurs during the curfew tool’s execution, only the tools.<context-id>.error object is inserted into the context store. This context data object is described in detail here.