AccountingBalanceCheck#
API documentation for tradeexecutor.strategy.account_correction.AccountingBalanceCheck Python class in Trading Strategy framework.
- class AccountingBalanceCheck[source]#
Bases:
object
Accounting correction applied to a balance.
Any irregular accounting correction will cause the position profit calcualtions and such to become invalid. Such positions should be separately market and not included in the profit calculations.
- __init__(type, holding_address, asset, positions, expected_amount, actual_amount, dust_epsilon, relative_epsilon, block_number, timestamp, usd_value, reserve_asset, mismatch, price, price_at)#
- Parameters:
type (AccountingCorrectionCause) –
holding_address (str) –
asset (AssetIdentifier) –
positions (Optional[Set[GenericPosition]]) –
expected_amount (Decimal) –
actual_amount (Decimal) –
dust_epsilon (Decimal) –
relative_epsilon (Decimal) –
block_number (int | None) –
timestamp (datetime.datetime | None) –
usd_value (float | None) –
reserve_asset (bool) –
mismatch (bool) –
price (decimal.Decimal | None) –
price_at (datetime.datetime | None) –
- Return type:
None
Methods
__init__
(type, holding_address, asset, ...)We have extra
is_dusty
()If there is a mismatch, is the mismatch within the dust tolerance.
is_mismatch
()is_usd_low_value_diff
([usd_value_threshold])Check for dust positions.
Attributes
Backwards compatibility.
How many tokens we corrected
type
Where is this token being stored
Related on-chain asset
Related positions
expected_amount
actual_amount
Dust epsilon
Relative epsilon
block_number
timestamp
The difference between expected and actual, in USD terms
Is this correction for reserve asset
Was there a balance mismatch that is larger than the epsilon
Token price used in usd_value calcuulation
Timestamp when we fetched the prcie
- asset: AssetIdentifier#
Related on-chain asset
- positions: Optional[Set[GenericPosition]]#
Related positions
Set none if no open position was found
- usd_value: float | None#
The difference between expected and actual, in USD terms
Keep track of monetary value of corrections.
An estimated value at the time of the correction creation.
Negative for negative corrections
None if the the tokens are for a new position and we do not have pricing information yet available, or if the position is not a spot position.
- price: decimal.Decimal | None#
Token price used in usd_value calcuulation
- price_at: datetime.datetime | None#
Timestamp when we fetched the prcie
- property quantity#
How many tokens we corrected
- property position: tradeexecutor.state.generic_position.GenericPosition | None#
Backwards compatibility.
TODO: Remove code paths touching this
- is_usd_low_value_diff(usd_value_threshold=0.1)[source]#
Check for dust positions.
We have plenty of token as in base token quantity but it is zeor
- __init__(type, holding_address, asset, positions, expected_amount, actual_amount, dust_epsilon, relative_epsilon, block_number, timestamp, usd_value, reserve_asset, mismatch, price, price_at)#
- Parameters:
type (AccountingCorrectionCause) –
holding_address (str) –
asset (AssetIdentifier) –
positions (Optional[Set[GenericPosition]]) –
expected_amount (Decimal) –
actual_amount (Decimal) –
dust_epsilon (Decimal) –
relative_epsilon (Decimal) –
block_number (int | None) –
timestamp (datetime.datetime | None) –
usd_value (float | None) –
reserve_asset (bool) –
mismatch (bool) –
price (decimal.Decimal | None) –
price_at (datetime.datetime | None) –
- Return type:
None