The finance developer workbenchSearch the reference Development · 0.1.4 · unpublished

portfolio / wire operation

Propose a rebalance (a proposal, never an order)

totalfinance.portfolio.rebalance_proposal

Fold the ledger snapshot to its state, mark it from the market snapshot, and propose the trades that take the portfolio to the policy targets (or only the drifted ones) under the policy limits, lot sizes, minimum notional, transaction-cost estimates, and an optional external flow. The result is proposePortfolioRebalance(...) verbatim: weights before and after, the cash summary, the trades with their estimates, the objective, and every target it could not resolve. Read-only by construction — it returns a proposal and places nothing. Opt-in (portfolioPack).

Pack / profilesportfolio / full, portfolio
Default discoveryOpt-in
Required capabilitiestrade:propose
Effects / authorizationnone / none
Cost / cancellationmedium / Do not assume inline interruption
Handle-eligible inputsledger, market
Idempotencynot-applicable
Input schema
{
  "type": "object",
  "properties": {
    "ledger": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "totalfinance.portfolio-ledger",
          "type": "string"
        },
        "schemaVersion": {
          "type": "integer"
        },
        "portfolioId": {
          "type": "string"
        },
        "baseCurrency": {
          "type": "string"
        },
        "lotRelief": {
          "type": "string",
          "enum": [
            "fifo",
            "lifo",
            "highest-cost",
            "specific-lot"
          ]
        },
        "events": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": {}
          },
          "description": "Portfolio event envelopes (each re-validated by readPortfolioLedgerSnapshot)"
        },
        "provenance": {
          "type": "object",
          "properties": {
            "provider": {
              "type": "string"
            },
            "dataset": {
              "type": "string"
            },
            "asOf": {
              "type": "number"
            },
            "receivedAt": {
              "type": "number"
            },
            "sourceVersion": {
              "type": "string"
            },
            "requestId": {
              "type": "string"
            },
            "warnings": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {}
              }
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "schemaVersion",
        "baseCurrency",
        "lotRelief",
        "events"
      ],
      "description": "A serialized portfolio ledger (totalfinance.portfolio-ledger, the FC7 JSON form)"
    },
    "asOf": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "string"
        }
      ],
      "description": "The valuation instant the proposal is sized at"
    },
    "market": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "totalfinance.market-snapshot",
          "type": "string"
        },
        "schemaVersion": {
          "type": "integer"
        },
        "asOf": {
          "type": "number",
          "description": "Epoch ms (resolved on the artifact)"
        },
        "conventions": {
          "type": "object",
          "properties": {
            "conventionsVersion": {
              "type": "string"
            },
            "asOfConvention": {
              "type": "string",
              "enum": [
                "explicit-instant",
                "date-midnight-utc"
              ],
              "description": "How asOf was expressed at create time (a bare date is refused by option pricing)"
            },
            "dayCount": {
              "type": "string"
            },
            "compounding": {
              "type": "string"
            },
            "calendar": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "conventionsVersion",
            "asOfConvention"
          ]
        },
        "observations": {
          "type": "object",
          "properties": {
            "spots": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {}
              }
            },
            "riskFreeRates": {
              "type": "object",
              "additionalProperties": {
                "type": "number"
              }
            },
            "dividendYields": {
              "type": "object",
              "additionalProperties": {
                "type": "number"
              }
            },
            "volatilities": {
              "type": "object",
              "additionalProperties": {
                "type": "number"
              }
            },
            "curves": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {}
              }
            },
            "surfaces": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {}
              }
            },
            "chains": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {}
              }
            }
          },
          "additionalProperties": false
        },
        "provenance": {
          "type": "object",
          "properties": {
            "provider": {
              "type": "string"
            },
            "dataset": {
              "type": "string"
            },
            "asOf": {
              "type": "number"
            },
            "receivedAt": {
              "type": "number"
            },
            "sourceVersion": {
              "type": "string"
            },
            "requestId": {
              "type": "string"
            },
            "warnings": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {}
              }
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "schemaVersion",
        "asOf",
        "conventions",
        "observations"
      ],
      "description": "A Gate B market snapshot (totalfinance.market-snapshot); its interior is re-validated by the read door"
    },
    "currencyConversions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "baseCurrency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "quoteCurrency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "quotePerBase": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "baseCurrency",
          "quoteCurrency",
          "quotePerBase"
        ]
      }
    },
    "policy": {
      "type": "object",
      "properties": {
        "targets": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "group": {
                "type": "object",
                "properties": {
                  "instrumentId": {
                    "type": "string"
                  },
                  "sleeveId": {
                    "type": "string"
                  },
                  "assetClass": {
                    "type": "string"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "tag": {
                    "type": "string"
                  },
                  "underlying": {
                    "type": "string"
                  },
                  "strategy": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "description": "Exactly one group key"
              },
              "weight": {
                "type": "number"
              },
              "riskBudget": {
                "type": "number"
              },
              "driftBand": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "group"
            ]
          }
        },
        "model": {
          "type": "object",
          "additionalProperties": {},
          "description": "A model portfolio envelope (totalfinance.model-portfolio), validated by the policy grammar"
        },
        "withinGroupAllocation": {
          "type": "string",
          "enum": [
            "proportional-to-current",
            "equal"
          ]
        },
        "driftBand": {
          "type": "number"
        },
        "reviewCadenceDays": {
          "type": "number"
        },
        "maximumTurnover": {
          "type": "number"
        },
        "maximumEstimatedTransactionCost": {
          "type": "number"
        },
        "minimumCash": {
          "type": "number"
        },
        "minimumCashWeight": {
          "type": "number"
        },
        "limits": {
          "type": "object",
          "properties": {
            "maximumPositionWeight": {
              "type": "number"
            },
            "maximumGroupWeights": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "group": {
                    "type": "object",
                    "properties": {
                      "instrumentId": {
                        "type": "string"
                      },
                      "sleeveId": {
                        "type": "string"
                      },
                      "assetClass": {
                        "type": "string"
                      },
                      "currency": {
                        "type": "string"
                      },
                      "tag": {
                        "type": "string"
                      },
                      "underlying": {
                        "type": "string"
                      },
                      "strategy": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "description": "Exactly one group key"
                  },
                  "maximumWeight": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "group",
                  "maximumWeight"
                ]
              }
            },
            "maximumGrossLeverage": {
              "type": "number"
            },
            "maximumDrawdown": {
              "type": "number"
            },
            "maximumDailyLoss": {
              "type": "number"
            },
            "maximumDaysToLiquidate": {
              "type": "number"
            },
            "minimumSettledCash": {
              "type": "number"
            }
          },
          "additionalProperties": false
        },
        "allowedInstruments": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictedInstruments": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowedAccounts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "benchmark": {
          "type": "object",
          "properties": {
            "benchmarkId": {
              "type": "string",
              "minLength": 1
            },
            "asOf": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ],
              "description": "Epoch ms, YYYY-MM-DD, or a zoned ISO datetime"
            },
            "constituents": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "instrumentId": {
                    "type": "string"
                  },
                  "weight": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "instrumentId",
                  "weight"
                ]
              }
            }
          },
          "additionalProperties": false,
          "required": [
            "benchmarkId"
          ]
        },
        "performanceObjective": {
          "type": "string"
        },
        "contributionHandling": {
          "type": "string",
          "enum": [
            "invest-to-targets",
            "hold-as-cash"
          ]
        },
        "withdrawalHandling": {
          "type": "string",
          "enum": [
            "raise-from-overweights",
            "pro-rata"
          ]
        },
        "incomeReinvestment": {
          "type": "string",
          "enum": [
            "reinvest",
            "hold-as-cash"
          ]
        },
        "lotSelectionObjective": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "description": "Targets come from the policy (inline targets or a model)"
    },
    "instrumentClassification": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "underlying": {
            "type": "string"
          },
          "assetClass": {
            "type": "string"
          },
          "strategy": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "description": "Identity metadata per instrument for grouping; unknown instruments group as unclassified"
    },
    "scope": {
      "type": "string",
      "enum": [
        "to-target",
        "drift-only"
      ],
      "description": "'to-target' trades every target to weight; 'drift-only' trades only targets outside their band"
    },
    "externalFlow": {
      "type": "object",
      "properties": {
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "amount",
        "currency"
      ],
      "description": "A contribution (positive) or withdrawal (negative) the proposal sizes around"
    },
    "tradingAccountId": {
      "type": "string"
    },
    "averageDailyVolumes": {
      "type": "object",
      "additionalProperties": {
        "type": "number"
      }
    },
    "lotSizes": {
      "type": "object",
      "additionalProperties": {
        "type": "number"
      }
    },
    "defaultLotSize": {
      "type": "number",
      "exclusiveMinimum": 0
    },
    "minimumNotional": {
      "type": "number",
      "minimum": 0
    },
    "transactionCosts": {
      "type": "object",
      "properties": {
        "commissionPerTrade": {
          "type": "number",
          "minimum": 0
        },
        "commissionPerUnit": {
          "type": "number",
          "minimum": 0
        },
        "spreadBasisPoints": {
          "type": "number",
          "minimum": 0
        },
        "slippageBasisPoints": {
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "required": [
    "ledger",
    "asOf",
    "market",
    "policy",
    "scope"
  ]
}
Output schema
{
  "type": "object",
  "properties": {
    "asOf": {
      "type": "number"
    },
    "baseCurrency": {
      "type": "string"
    },
    "netAssetValue": {
      "type": "number"
    },
    "netAssetValueAfterFlow": {
      "type": "number"
    },
    "weights": {
      "type": "object"
    },
    "cash": {
      "type": "object"
    },
    "trades": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "estimates": {
      "type": "object"
    },
    "objective": {
      "type": "object"
    },
    "unresolvedTargets": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "assumptions": {
      "type": "object",
      "description": "Applied conventions"
    },
    "diagnostics": {
      "type": "object",
      "description": "Engine, method, warnings"
    }
  },
  "required": [
    "asOf",
    "baseCurrency",
    "netAssetValue",
    "netAssetValueAfterFlow",
    "weights",
    "cash",
    "trades",
    "estimates",
    "objective",
    "unresolvedTargets",
    "assumptions",
    "diagnostics"
  ]
}

All operations · Setup, handles, jobs & permissions