account_correction#

API documentation for tradeexecutor.strategy.account_correction Python module in Trading Strategy.

Module description#

Apply accounting corrections on the strategy state.

  • Read on-chain balances

  • Compare them to the balances seen in the state

  • Adjust statebalacnes to match chain based ones

  • Generate the accounting events to reflect these changes

Classes#

AccountingBalanceCheck

Accounting correction applied to a balance.

AccountingCorrectionCause

An enumeration.

Functions#

apply_accounting_correction(state, ...)

Update the state to reflect the true on-chain balances.

calculate_account_corrections(pair_universe, ...)

Figure out differences between our internal ledger (state) and on-chain balances.

calculate_total_assets(portfolio)

Calculate total tokens the portfolio should held.

check_accounts(pair_universe, ...[, ...])

Create a summary accounting corrections needed.

correct_accounts(state, corrections, ...[, ...])

Apply the accounting corrections on the state (internal ledger).

is_relative_mismatch(actual_amount, ...)

Calculate if we are within the relative tolerance.

transfer_away_assets_without_position(...)

Transfer away non-reserve assets that cannot be mapped to an open position.