SpotTrade#

tradeexecutor.analysis.trade_analyser.SpotTrade Python class in Trading Strategy framework.

class SpotTrade[source]#

Bases: object

Track spot trades to construct position performance.

For sells, quantity is negative.

__init__(trade_id, pair_id, timestamp, price, executed_price, quantity, commission, slippage, trade_type=None, state_details=None, lp_fees_paid=None, bad_data_issues=False)#
Parameters:
Return type:

None

Methods

__init__(trade_id, pair_id, timestamp, ...)

is_buy()

is_sell()

Attributes

bad_data_issues

Set for legacy trades with legacy data.

lp_fees_paid

LP fees paid, currency convereted to the USD.

state_details

Internal state dump of the algorithm when this trade was made.

trade_type

Any hints applied for this trade why it was performed

value

trade_id

Internal running counter to uniquely label all trades in trade analysis

pair_id

Trading pair for this trade

timestamp

When this trade was made, the backtes simulation thick

price

Asset mid-price

executed_price

quantity

How much we bought the asset.

commission

How much fees we paid to the exchange

slippage

How much we lost against the midprice due to the slippage

trade_id: int#

Internal running counter to uniquely label all trades in trade analysis

pair_id: int#

Trading pair for this trade

timestamp: Timestamp#

When this trade was made, the backtes simulation thick

price: float#

Asset mid-price

quantity: float#

How much we bought the asset. Negative value for sells.

commission: float#

How much fees we paid to the exchange

slippage: float#

How much we lost against the midprice due to the slippage

trade_type: Optional[TradeType] = None#

Any hints applied for this trade why it was performed

state_details: Optional[Dict] = None#

Internal state dump of the algorithm when this trade was made. This is mostly useful when doing the trade analysis try to understand why some trades were made. It also allows you to reconstruct the portfolio state over the time.

lp_fees_paid: Optional[Union[list[float], float]] = None#

LP fees paid, currency convereted to the USD.

The value is read back from the realised trade. LP fee is usually % of the trade. For Uniswap style exchanges fees are always taken from amount in token and directly passed to the LPs as the part of the swap, these is no separate fee information.

bad_data_issues: bool = False#

Set for legacy trades with legacy data.

Mark that calculations on this trade might be incorrect

__init__(trade_id, pair_id, timestamp, price, executed_price, quantity, commission, slippage, trade_type=None, state_details=None, lp_fees_paid=None, bad_data_issues=False)#
Parameters:
Return type:

None