pit

Account Adjustments

Back to index

OpenPitParamAdjustmentAmount

One amount component inside an account adjustment.

The numeric value is interpreted according to kind:

typedef struct OpenPitParamAdjustmentAmount {
    OpenPitParamPositionSize value;
    OpenPitParamAdjustmentAmountKind kind;
} OpenPitParamAdjustmentAmount;

OpenPitAccountAdjustmentBalanceOperation

Balance-operation payload for account adjustment.

typedef struct OpenPitAccountAdjustmentBalanceOperation {
    OpenPitStringView asset;
    OpenPitParamPriceOptional average_entry_price;
    OpenPitParamPnlOptional realized_pnl;
} OpenPitAccountAdjustmentBalanceOperation;

OpenPitAccountAdjustmentPositionOperation

Position-operation payload for account adjustment.

typedef struct OpenPitAccountAdjustmentPositionOperation {
    OpenPitInstrument instrument;
    OpenPitStringView collateral_asset;
    OpenPitParamPriceOptional average_entry_price;
    OpenPitParamLeverage leverage;
    OpenPitParamPositionMode mode;
} OpenPitAccountAdjustmentPositionOperation;

OpenPitAccountAdjustmentOperationKind

Selects which account-adjustment operation payload is present.

At most one operation payload can be selected at a time:

typedef uint8_t OpenPitAccountAdjustmentOperationKind;
/**
 * No operation is supplied.
 */
#define OpenPitAccountAdjustmentOperationKind_Absent \
    ((OpenPitAccountAdjustmentOperationKind) 0)
/**
 * The balance-operation payload is selected.
 */
#define OpenPitAccountAdjustmentOperationKind_Balance \
    ((OpenPitAccountAdjustmentOperationKind) 1)
/**
 * The position-operation payload is selected.
 */
#define OpenPitAccountAdjustmentOperationKind_Position \
    ((OpenPitAccountAdjustmentOperationKind) 2)

OpenPitAccountAdjustmentOperation

Account-adjustment operation as a single discriminated value.

kind selects which payload is meaningful; the payload not selected by kind is ignored. Because a single discriminant chooses the payload, supplying both a balance and a position operation at once is not representable.

typedef struct OpenPitAccountAdjustmentOperation {
    OpenPitAccountAdjustmentOperationKind kind;
    OpenPitAccountAdjustmentBalanceOperation balance;
    OpenPitAccountAdjustmentPositionOperation position;
} OpenPitAccountAdjustmentOperation;

OpenPitAccountAdjustmentAmount

Optional amount-change group for account adjustment.

The group is absent when every field is absent.

typedef struct OpenPitAccountAdjustmentAmount {
    OpenPitParamAdjustmentAmount balance;
    OpenPitParamAdjustmentAmount held;
    OpenPitParamAdjustmentAmount incoming;
} OpenPitAccountAdjustmentAmount;

OpenPitAccountAdjustmentBounds

Optional bounds group for account adjustment.

The group is absent when every bound is absent.

typedef struct OpenPitAccountAdjustmentBounds {
    OpenPitParamPositionSizeOptional balance_upper;
    OpenPitParamPositionSizeOptional balance_lower;
    OpenPitParamPositionSizeOptional held_upper;
    OpenPitParamPositionSizeOptional held_lower;
    OpenPitParamPositionSizeOptional incoming_upper;
    OpenPitParamPositionSizeOptional incoming_lower;
} OpenPitAccountAdjustmentBounds;

OpenPitAccountAdjustment

Full caller-owned account-adjustment payload.

typedef struct OpenPitAccountAdjustment {
    OpenPitAccountAdjustmentOperation operation;
    OpenPitAccountAdjustmentAmountOptional amount;
    OpenPitAccountAdjustmentBoundsOptional bounds;
    void * user_data;
} OpenPitAccountAdjustment;

OpenPitAccountAdjustmentApplyStatus

Result of openpit_engine_apply_account_adjustment.

typedef uint8_t OpenPitAccountAdjustmentApplyStatus;
/**
 * The call failed before the batch could be evaluated.
 */
#define OpenPitAccountAdjustmentApplyStatus_Error \
    ((OpenPitAccountAdjustmentApplyStatus) 0)
/**
 * The batch was accepted and applied.
 */
#define OpenPitAccountAdjustmentApplyStatus_Applied \
    ((OpenPitAccountAdjustmentApplyStatus) 1)
/**
 * The batch was evaluated and rejected by policy or validation logic.
 */
#define OpenPitAccountAdjustmentApplyStatus_Rejected \
    ((OpenPitAccountAdjustmentApplyStatus) 2)

OpenPitAccountAdjustmentAmountOptional

typedef struct OpenPitAccountAdjustmentAmountOptional {
    OpenPitAccountAdjustmentAmount value;
    bool is_set;
} OpenPitAccountAdjustmentAmountOptional;

OpenPitAccountAdjustmentBoundsOptional

typedef struct OpenPitAccountAdjustmentBoundsOptional {
    OpenPitAccountAdjustmentBounds value;
    bool is_set;
} OpenPitAccountAdjustmentBoundsOptional;

openpit_param_adjustment_amount_to_string

Renders an adjustment amount into a caller-owned shared string.

Returns null and writes out_error when the amount is not set or its numeric value cannot be decoded.

OpenPitSharedString * openpit_param_adjustment_amount_to_string(
    OpenPitParamAdjustmentAmount value,
    OpenPitOutParamError out_error
);