SpotTrade#

tradingstrategy.analysis.tradeanalyzer.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, quantity, commission, slippage, hint=None, state_details=None)#
Parameters:
Return type:

None

Methods

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

is_buy()

is_sell()

Attributes

hint

Any hints applied for this trade why it was performed

state_details

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

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 price at buy in

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 price at buy in

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

hint: Optional[TradeHint] = 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.

__init__(trade_id, pair_id, timestamp, price, quantity, commission, slippage, hint=None, state_details=None)#
Parameters:
Return type:

None