SpotTrade#
tradingstrategy.analysis.tradeanalyzer.SpotTrade class.
- 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
trade_id (PrimaryKey) –
pair_id (PrimaryKey) –
timestamp (Timestamp) –
price (USDollarAmount) –
quantity (float) –
commission (USDollarAmount) –
slippage (USDollarAmount) –
- Return type
None
Methods
__init__
(trade_id, pair_id, timestamp, ...)is_buy
()is_sell
()Attributes
Any hints applied for this trade why it was performed
Internal state dump of the algorithm when this trade was made.
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 price at buy in
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
- trade_id: PrimaryKey#
Internal running counter to uniquely label all trades in trade analysis
- pair_id: PrimaryKey#
Trading pair for this trade
- price: USDollarAmount#
Asset price at buy in
- commission: USDollarAmount#
How much fees we paid to the exchange
- slippage: USDollarAmount#
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.
- __init__(trade_id, pair_id, timestamp, price, quantity, commission, slippage, hint=None, state_details=None)#
- Parameters
trade_id (PrimaryKey) –
pair_id (PrimaryKey) –
timestamp (Timestamp) –
price (USDollarAmount) –
quantity (float) –
commission (USDollarAmount) –
slippage (USDollarAmount) –
- Return type
None