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 registered through pre_trade can return:
Nonefor success without mutations.An iterable of
PolicyRejectobjects to reject the batch.A tuple of
Mutationobjects to register rollback work.
The engine stops on the first rejected adjustment and exposes that index through
AccountAdjustmentBatchResult.failed_index.