The finance developer workbenchSearch the reference Development · 0.1.4 · unpublished

backtest / wire operation

Run an options backtest

totalfinance.backtest.options_run

Backtest a declarative options strategy over chain snapshots: structure selection by delta and DTE, exit and roll triggers, optional delta hedging, declarative commission and slippage, American assignment modelling, and the marking policy (current-quote or entry volatility; what a missing mark does). Several rules may hold several trades at once (book), pre-trade limits reject entries with rows, combo or legged fills, quote freshness, split lineage, dividend evidence, the surface summary, and the portfolio ledger the equity reconciles to. Equity points, trades with per-leg attribution and mark counts, settlements, and the standard performance summary. The result is optionsBacktest(...) verbatim. Opt-in (backtestPack): payloads and runtime are heavier than the default set.

Pack / profilesbacktest / backtesting, full
Default discoveryOpt-in
Required capabilitiesNone
Effects / authorizationnone / none
Cost / cancellationjob / Do not assume inline interruption
Handle-eligible inputsNone
Idempotencynot-applicable
Input schema
{
  "type": "object",
  "properties": {
    "chains": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "asOf": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
          },
          "underlyingPrice": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "quotes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "contract": {
                  "type": "object",
                  "properties": {
                    "underlying": {
                      "type": "string",
                      "minLength": 1
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "call",
                        "put"
                      ]
                    },
                    "style": {
                      "type": "string",
                      "enum": [
                        "european",
                        "american"
                      ]
                    },
                    "strike": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "expiry": {
                      "type": "string",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}([Tt ]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?([Zz]|[+-]\\d{2}:?\\d{2}))?$",
                      "description": "Display label: 'YYYY-MM-DD' or a zoned ISO datetime (matches the builders)"
                    },
                    "expiresAt": {
                      "type": "number",
                      "description": "Resolved expiration instant (epoch ms) — stamped by the builders"
                    },
                    "expiryConvention": {
                      "type": "string",
                      "enum": [
                        "us-equity-close",
                        "explicit-instant"
                      ],
                      "description": "How the label resolved to the instant"
                    },
                    "multiplier": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    },
                    "settlement": {
                      "type": "string",
                      "enum": [
                        "physical",
                        "cash"
                      ]
                    },
                    "exerciseTime": {
                      "type": "string",
                      "enum": [
                        "AM",
                        "PM"
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "root": {
                      "type": "string"
                    },
                    "occSymbol": {
                      "type": "string"
                    },
                    "deliverable": {
                      "type": "object",
                      "properties": {
                        "cash": {
                          "type": "number"
                        },
                        "shares": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "symbol": {
                                "type": "string",
                                "minLength": 1
                              },
                              "quantity": {
                                "type": "number"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "symbol",
                              "quantity"
                            ]
                          }
                        },
                        "notes": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false
                    },
                    "adjusted": {
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "underlying",
                    "type",
                    "style",
                    "strike",
                    "expiry",
                    "expiresAt",
                    "expiryConvention"
                  ]
                },
                "timestampMs": {
                  "type": "number"
                },
                "bid": {
                  "type": "number"
                },
                "ask": {
                  "type": "number"
                },
                "bidSize": {
                  "type": "number",
                  "minimum": 0
                },
                "askSize": {
                  "type": "number",
                  "minimum": 0
                },
                "mid": {
                  "type": "number"
                },
                "last": {
                  "type": "number"
                },
                "mark": {
                  "type": "number"
                },
                "volume": {
                  "type": "number",
                  "minimum": 0
                },
                "openInterest": {
                  "type": "number",
                  "minimum": 0
                },
                "underlyingPrice": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "impliedVolatility": {
                  "type": "number",
                  "minimum": 0
                },
                "greeks": {
                  "type": "object",
                  "properties": {
                    "delta": {
                      "type": "number"
                    },
                    "gamma": {
                      "type": "number"
                    },
                    "theta": {
                      "type": "number"
                    },
                    "vega": {
                      "type": "number"
                    },
                    "rho": {
                      "type": "number"
                    },
                    "provenance": {
                      "type": "object",
                      "properties": {
                        "source": {
                          "type": "string"
                        },
                        "model": {
                          "type": "string"
                        },
                        "timestampMs": {
                          "type": "number"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "source"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "delta"
                  ],
                  "description": "Per-share Greeks in display units (theta per day, vega per vol point, rho per 1%), with optional provenance"
                },
                "exchange": {
                  "type": "string"
                },
                "conditions": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "contract",
                "timestampMs"
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "asOf",
          "underlyingPrice",
          "quotes"
        ]
      },
      "description": "Chain snapshots (any order; the engine sorts)"
    },
    "marking": {
      "type": "object",
      "properties": {
        "volatility": {
          "type": "string",
          "enum": [
            "current-quote",
            "entry"
          ]
        },
        "missingMark": {
          "type": "string",
          "enum": [
            "refuse",
            "entry-volatility",
            "carry-last-volatility"
          ]
        },
        "maximumQuoteAgeMs": {
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false,
      "description": "Default: re-mark from the current quote; refuse a missing mark"
    },
    "initialCapital": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Default 100,000"
    },
    "riskFreeRate": {
      "type": "number",
      "description": "Continuously-compounded risk-free rate (decimal, e.g. 0.045) pricing every mark — REQUIRED; the engine never assumes a rate"
    },
    "dividendYield": {
      "type": "number",
      "description": "Default 0"
    },
    "entry": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "const": "ironCondor",
              "type": "string"
            },
            "select": {
              "type": "object",
              "properties": {
                "shortDelta": {
                  "type": "number"
                },
                "wingWidth": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "shortDelta",
                "wingWidth"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure",
            "select"
          ]
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "type": "string",
              "enum": [
                "bullCallSpread",
                "bearCallSpread",
                "bullPutSpread",
                "bearPutSpread"
              ]
            },
            "select": {
              "type": "object",
              "properties": {
                "shortDelta": {
                  "type": "number"
                },
                "width": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "shortDelta",
                "width"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure",
            "select"
          ]
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "const": "strangle",
              "type": "string"
            },
            "select": {
              "type": "object",
              "properties": {
                "shortDelta": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "shortDelta"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure",
            "select"
          ]
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "const": "straddle",
              "type": "string"
            },
            "select": {
              "type": "object",
              "properties": {
                "strike": {
                  "type": "number"
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure"
          ]
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "const": "coveredCall",
              "type": "string"
            },
            "select": {
              "type": "object",
              "properties": {
                "shortDelta": {
                  "type": "number"
                },
                "stockPrice": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "shortDelta"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure",
            "select"
          ]
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "const": "protectivePut",
              "type": "string"
            },
            "select": {
              "type": "object",
              "properties": {
                "shortDelta": {
                  "type": "number"
                },
                "stockPrice": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "shortDelta"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure",
            "select"
          ]
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Names the rule in trades and rows"
            },
            "when": {
              "type": "string",
              "enum": [
                "flat",
                "always"
              ],
              "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
            },
            "daysToExpiry": {
              "type": "object",
              "properties": {
                "target": {
                  "type": "number"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "target"
              ]
            },
            "sizing": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "quantity": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "quantity"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "maxMarginFraction": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "maxMarginFraction"
                  ]
                }
              ],
              "description": "Default { quantity: 1 }"
            },
            "price": {
              "type": "string",
              "enum": [
                "bid",
                "ask",
                "mid",
                "last",
                "mark"
              ]
            },
            "structure": {
              "type": "string",
              "enum": [
                "calendarCallSpread",
                "calendarPutSpread",
                "diagonalCallSpread",
                "diagonalPutSpread",
                "doubleDiagonal"
              ]
            },
            "select": {
              "type": "object",
              "properties": {
                "shortDelta": {
                  "type": "number"
                },
                "nearDaysToExpiry": {
                  "type": "object",
                  "properties": {
                    "target": {
                      "type": "number"
                    },
                    "min": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "target"
                  ]
                },
                "farDaysToExpiry": {
                  "type": "object",
                  "properties": {
                    "target": {
                      "type": "number"
                    },
                    "min": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "target"
                  ]
                },
                "width": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "shortDelta",
                "nearDaysToExpiry",
                "farDaysToExpiry"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "daysToExpiry",
            "structure",
            "select"
          ]
        }
      ],
      "description": "The declarative entry structures; a `build` callback is SDK-only"
    },
    "rules": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "const": "ironCondor",
                "type": "string"
              },
              "select": {
                "type": "object",
                "properties": {
                  "shortDelta": {
                    "type": "number"
                  },
                  "wingWidth": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "shortDelta",
                  "wingWidth"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure",
              "select"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "type": "string",
                "enum": [
                  "bullCallSpread",
                  "bearCallSpread",
                  "bullPutSpread",
                  "bearPutSpread"
                ]
              },
              "select": {
                "type": "object",
                "properties": {
                  "shortDelta": {
                    "type": "number"
                  },
                  "width": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "shortDelta",
                  "width"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure",
              "select"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "const": "strangle",
                "type": "string"
              },
              "select": {
                "type": "object",
                "properties": {
                  "shortDelta": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "shortDelta"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure",
              "select"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "const": "straddle",
                "type": "string"
              },
              "select": {
                "type": "object",
                "properties": {
                  "strike": {
                    "type": "number"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "const": "coveredCall",
                "type": "string"
              },
              "select": {
                "type": "object",
                "properties": {
                  "shortDelta": {
                    "type": "number"
                  },
                  "stockPrice": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "shortDelta"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure",
              "select"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "const": "protectivePut",
                "type": "string"
              },
              "select": {
                "type": "object",
                "properties": {
                  "shortDelta": {
                    "type": "number"
                  },
                  "stockPrice": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "shortDelta"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure",
              "select"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "Names the rule in trades and rows"
              },
              "when": {
                "type": "string",
                "enum": [
                  "flat",
                  "always"
                ],
                "description": "'flat' (default) enters only when no position is open; a caller predicate is SDK-only"
              },
              "daysToExpiry": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "number"
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "target"
                ]
              },
              "sizing": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "quantity"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "maxMarginFraction": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "maxMarginFraction"
                    ]
                  }
                ],
                "description": "Default { quantity: 1 }"
              },
              "price": {
                "type": "string",
                "enum": [
                  "bid",
                  "ask",
                  "mid",
                  "last",
                  "mark"
                ]
              },
              "structure": {
                "type": "string",
                "enum": [
                  "calendarCallSpread",
                  "calendarPutSpread",
                  "diagonalCallSpread",
                  "diagonalPutSpread",
                  "doubleDiagonal"
                ]
              },
              "select": {
                "type": "object",
                "properties": {
                  "shortDelta": {
                    "type": "number"
                  },
                  "nearDaysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "farDaysToExpiry": {
                    "type": "object",
                    "properties": {
                      "target": {
                        "type": "number"
                      },
                      "min": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "target"
                    ]
                  },
                  "width": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "shortDelta",
                  "nearDaysToExpiry",
                  "farDaysToExpiry"
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "daysToExpiry",
              "structure",
              "select"
            ]
          }
        ],
        "description": "The declarative entry structures; a `build` callback is SDK-only"
      },
      "minItems": 1,
      "description": "Several rules, each a member of the book; exactly one of entry and rules"
    },
    "exit": {
      "type": "object",
      "properties": {
        "profitTarget": {
          "type": "number",
          "description": "Fraction of entry premium, e.g. 0.5"
        },
        "stopLoss": {
          "type": "number",
          "description": "Multiple of entry premium, e.g. 2"
        },
        "daysToExpiry": {
          "type": "number",
          "description": "Close at or below this DTE"
        }
      },
      "additionalProperties": false,
      "description": "A `when` predicate is SDK-only"
    },
    "roll": {
      "type": "object",
      "properties": {
        "when": {
          "type": "object",
          "properties": {
            "profitTarget": {
              "type": "number",
              "description": "Fraction of entry premium, e.g. 0.5"
            },
            "stopLoss": {
              "type": "number",
              "description": "Multiple of entry premium, e.g. 2"
            },
            "daysToExpiry": {
              "type": "number",
              "description": "Close at or below this DTE"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "hedge": {
      "type": "object",
      "properties": {
        "deltaBand": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "commission": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "none",
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "model"
              ]
            },
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "bps",
                  "type": "string"
                },
                "bps": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "model",
                "bps"
              ]
            },
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "perShare",
                  "type": "string"
                },
                "amountPerShare": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "model",
                "amountPerShare"
              ]
            },
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "fixed",
                  "type": "string"
                },
                "amount": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "model",
                "amount"
              ]
            }
          ],
          "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
        },
        "slippage": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "none",
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "model"
              ]
            },
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "bps",
                  "type": "string"
                },
                "bps": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "model",
                "bps"
              ]
            },
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "fixed",
                  "type": "string"
                },
                "perShare": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "model",
                "perShare"
              ]
            },
            {
              "type": "object",
              "properties": {
                "model": {
                  "const": "spread",
                  "type": "string"
                },
                "spread": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "model",
                "spread"
              ]
            }
          ],
          "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
        }
      },
      "additionalProperties": false,
      "required": [
        "deltaBand"
      ]
    },
    "commission": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "none",
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "model"
          ]
        },
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "bps",
              "type": "string"
            },
            "bps": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "model",
            "bps"
          ]
        },
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "perShare",
              "type": "string"
            },
            "amountPerShare": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "model",
            "amountPerShare"
          ]
        },
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "fixed",
              "type": "string"
            },
            "amount": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "model",
            "amount"
          ]
        }
      ],
      "description": "A declarative commission model (fees.none / bps / perShare / fixed)"
    },
    "slippage": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "none",
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "model"
          ]
        },
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "bps",
              "type": "string"
            },
            "bps": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "model",
            "bps"
          ]
        },
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "fixed",
              "type": "string"
            },
            "perShare": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "model",
            "perShare"
          ]
        },
        {
          "type": "object",
          "properties": {
            "model": {
              "const": "spread",
              "type": "string"
            },
            "spread": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "model",
            "spread"
          ]
        }
      ],
      "description": "A declarative slippage model (slippage.none / bps / fixed / spread)"
    },
    "assignment": {
      "type": "string",
      "enum": [
        "model",
        "none"
      ]
    },
    "periodsPerYear": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Default 252"
    },
    "book": {
      "type": "object",
      "properties": {
        "maximumOpenPositions": {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        "maximumPerUnderlying": {
          "type": "integer",
          "exclusiveMinimum": 0
        }
      },
      "additionalProperties": false,
      "description": "Default: one open trade"
    },
    "limits": {
      "type": "object",
      "properties": {
        "maximumMarginFraction": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "maximumNetDelta": {
          "type": "number",
          "minimum": 0
        },
        "maximumNetVega": {
          "type": "number",
          "minimum": 0
        },
        "maximumConcentration": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "scenarioLoss": {
          "type": "object",
          "properties": {
            "spotShocks": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "minItems": 1
            },
            "volatilityShocks": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "minItems": 1
            },
            "maximumLossFraction": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "spotShocks",
            "volatilityShocks",
            "maximumLossFraction"
          ]
        }
      },
      "additionalProperties": false,
      "description": "Pre-trade limits on the post-trade book; a breach is a limitRejections row"
    },
    "fillPolicy": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "combo",
            "legged"
          ]
        },
        "partialFill": {
          "type": "string",
          "enum": [
            "reject",
            "allow"
          ]
        },
        "price": {
          "type": "string",
          "enum": [
            "bid",
            "ask",
            "mid",
            "last",
            "mark"
          ]
        }
      },
      "additionalProperties": false
    },
    "quoteFreshness": {
      "type": "object",
      "properties": {
        "maximumQuoteAgeMs": {
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false,
      "required": [
        "maximumQuoteAgeMs"
      ]
    },
    "corporateActions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "symbol": {
            "type": "string",
            "minLength": 1
          },
          "effectiveDate": {
            "type": "string",
            "format": "date"
          },
          "type": {
            "type": "string",
            "enum": [
              "split",
              "reverseSplit",
              "dividend",
              "symbolChange",
              "merger",
              "spinoff",
              "other"
            ]
          },
          "ratio": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "cash": {
            "type": "number"
          },
          "newSymbol": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "additionalProperties": false,
        "required": [
          "symbol",
          "effectiveDate",
          "type"
        ]
      }
    },
    "dividends": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "underlying": {
            "type": "string",
            "minLength": 1
          },
          "exDate": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "underlying",
          "exDate",
          "amount"
        ]
      }
    },
    "baseCurrency": {
      "type": "string",
      "minLength": 1,
      "description": "Default 'USD'"
    }
  },
  "additionalProperties": false,
  "required": [
    "chains",
    "riskFreeRate",
    "exit"
  ]
}
Output schema
{
  "type": "object",
  "properties": {
    "points": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "returns": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "trades": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "settlements": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "finalValue": {
      "type": "number"
    },
    "performance": {
      "type": "object",
      "description": "The standard performance summary"
    },
    "limitRejections": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "fillRejections": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "surface": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "ledger": {
      "type": "object",
      "description": "The portfolio ledger snapshot (events)"
    },
    "timeline": {
      "type": [
        "object",
        "null"
      ],
      "description": "The ledger timeline (null under two marks)"
    },
    "runId": {
      "type": "string"
    },
    "assumptions": {
      "type": "object",
      "description": "Applied conventions"
    },
    "diagnostics": {
      "type": "object",
      "description": "Engine, method, warnings"
    }
  },
  "required": [
    "points",
    "returns",
    "trades",
    "settlements",
    "finalValue",
    "performance",
    "limitRejections",
    "fillRejections",
    "surface",
    "ledger",
    "timeline",
    "runId",
    "assumptions",
    "diagnostics"
  ]
}

All operations · Setup, handles, jobs & permissions