Account adjustments

Account adjustments model non-trading changes to account state. Typical uses are balance corrections, direct position imports, or administrative state sync.

Balance adjustment

import openpit

adjustment = openpit.AccountAdjustment(
    operation=openpit.AccountAdjustmentBalanceOperation(asset="USD"),
    amount=openpit.AccountAdjustmentAmount(
        balance=openpit.param.AdjustmentAmount.absolute(
            openpit.param.PositionSize("10000"),
        ),
    ),
)

engine = openpit.Engine.builder().build()
result = engine.apply_account_adjustment(
    account_id=openpit.param.AccountId.from_int(99224416),
    adjustments=[adjustment],
)
assert result.ok

Position adjustment

adjustment = openpit.AccountAdjustment(
    operation=openpit.AccountAdjustmentPositionOperation(
        instrument=openpit.Instrument("SPX", "USD"),
        collateral_asset="USD",
        average_entry_price=openpit.param.Price("95000"),
        mode=openpit.param.PositionMode.HEDGED,
    ),
    amount=openpit.AccountAdjustmentAmount(
        balance=openpit.param.AdjustmentAmount.absolute(
            openpit.param.PositionSize("-3"),
        ),
    ),
)

Policy result contract

A Policy.apply_account_adjustment callback returns a PolicyAccountAdjustmentResult with:

  • rejects: business rejects for the current adjustment.

  • mutations: rollback and commit work for accepted state changes.

  • account_adjustments: per-asset outcomes produced by the policy.

  • account_blocks: blocks recorded only after the full batch commits.

The engine stops on the first rejected adjustment and exposes that index through AccountAdjustmentBatchResult.failed_index. Business rejection is returned as an AccountAdjustmentBatchResult with ok == False and a populated rejects list; it is not raised as an exception.