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)#
Methods
__init__
(trade_id, pair_id, timestamp, ...)is_buy
()is_sell
()Attributes
Set for legacy trades with legacy data.
LP fees paid, currency convereted to the USD.
Internal state dump of the algorithm when this trade was made.
Any hints applied for this trade why it was performed
value
Internal running counter to uniquely label all trades in trade analysis
Trading pair for this trade
When this trade was made, the backtes simulation thick
Asset mid-price
executed_price
How much we bought the asset.
How much fees we paid to the exchange
How much we lost against the midprice due to the slippage
- 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)#