You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/trade-object.md
+73-5Lines changed: 73 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,20 @@ The following attributes / properties are available for each individual trade -
14
14
| Attribute | DataType | Description |
15
15
|------------|-------------|-------------|
16
16
|`pair`| string | Pair of this trade. |
17
+
|`safe_base_currency`| string | Compatibility layer for base currency . |
18
+
|`safe_quote_currency`| string | Compatibility layer for quote currency. |
17
19
|`is_open`| boolean | Is the trade currently open, or has it been concluded. |
20
+
|`exchange`| string | Exchange where this trade was executed. |
18
21
|`open_rate`| float | Rate this trade was entered at (Avg. entry rate in case of trade-adjustments). |
22
+
|`open_rate_requested`| float | The rate that was requested when the trade was opened. |
23
+
|`open_trade_value`| float | Value of the open trade including fees. |
19
24
|`close_rate`| float | Close rate - only set when is_open = False. |
25
+
|`close_rate_requested`| float | The close rate that was requested. |
26
+
|`safe_close_rate`| float | Close rate or `close_rate_requested` or 0.0 if neither is available. Only makes sense once the trade is closed. |
20
27
|`stake_amount`| float | Amount in Stake (or Quote) currency. |
28
+
|`max_stake_amount`| float | Maximum stake amount that was used in this trade (sum of all filled Entry orders). |
21
29
|`amount`| float | Amount in Asset / Base currency that is currently owned. Will be 0.0 until the initial order fills. |
30
+
|`amount_requested`| float | Amount that was originally requested for this trade as part of the first entry order. |
22
31
|`open_date`| datetime | Timestamp when trade was opened **use `open_date_utc` instead**|
23
32
|`open_date_utc`| datetime | Timestamp when trade was opened - in UTC. |
24
33
|`close_date`| datetime | Timestamp when trade was closed **use `close_date_utc` instead**|
@@ -28,15 +37,47 @@ The following attributes / properties are available for each individual trade -
28
37
|`realized_profit`| float | Absolute already realized profit (in stake currency) while the trade is still open. |
29
38
|`leverage`| float | Leverage used for this trade - defaults to 1.0 in spot markets. |
30
39
|`enter_tag`| string | Tag provided on entry via the `enter_tag` column in the dataframe. |
40
+
|`exit_reason`| string | Reason why the trade was exited. |
41
+
|`exit_order_status`| string | Status of the exit order. |
42
+
|`strategy`| string | Strategy name that was used for this trade. |
43
+
|`timeframe`| int | Timeframe used for this trade. |
31
44
|`is_short`| boolean | True for short trades, False otherwise. |
32
45
|`orders`| Order[]| List of order objects attached to this trade (includes both filled and cancelled orders). |
33
46
|`date_last_filled_utc`| datetime | Time of the last filled order. |
47
+
|`date_entry_fill_utc`| datetime | Date of the first filled entry order. |
34
48
|`entry_side`| "buy" / "sell" | Order Side the trade was entered. |
35
49
|`exit_side`| "buy" / "sell" | Order Side that will result in a trade exit / position reduction. |
36
50
|`trade_direction`| "long" / "short" | Trade direction in text - long or short. |
51
+
|`max_rate`| float | Highest price reached during this trade. Not 100% accurate. |
52
+
|`min_rate`| float | Lowest price reached during this trade. Not 100% accurate. |
37
53
|`nr_of_successful_entries`| int | Number of successful (filled) entry orders. |
38
54
|`nr_of_successful_exits`| int | Number of successful (filled) exit orders. |
55
+
|`has_open_position`| boolean | True if there is an open position (amount > 0) for this trade. Only false while the initial entry order is unfilled. |
39
56
|`has_open_orders`| boolean | Has the trade open orders (excluding stoploss orders). |
57
+
|`has_open_sl_orders`| boolean | True if there are open stoploss orders for this trade. |
58
+
|`open_orders`| Order[]| All open orders for this trade excluding stoploss orders. |
59
+
|`open_sl_orders`| Order[]| All open stoploss orders for this trade. |
60
+
|`fully_canceled_entry_order_count`| int | Number of fully canceled entry orders. |
61
+
|`canceled_exit_order_count`| int | Number of canceled exit orders. |
62
+
63
+
### Stop Loss related attributes
64
+
65
+
| Attribute | DataType | Description |
66
+
|------------|-------------|-------------|
67
+
|`stop_loss`| float | Absolute value of the stop loss. |
68
+
|`stop_loss_pct`| float | Relative value of the stop loss. |
69
+
|`initial_stop_loss`| float | Absolute value of the initial stop loss. |
70
+
|`initial_stop_loss_pct`| float | Relative value of the initial stop loss. |
71
+
|`stoploss_last_update_utc`| datetime | Timestamp of the last stoploss on exchange order update. |
72
+
|`stoploss_or_liquidation`| float | Returns the more restrictive of stoploss or liquidation price and corresponds to the price a stoploss would trigger at. |
73
+
74
+
### Futures/Margin trading attributes
75
+
76
+
| Attribute | DataType | Description |
77
+
|------------|-------------|-------------|
78
+
|`liquidation_price`| float | Liquidation price for leveraged trades. |
79
+
|`interest_rate`| float | Interest rate for margin trades. |
80
+
|`funding_fees`| float | Total funding fees for futures trades. |
40
81
41
82
## Class methods
42
83
@@ -102,6 +143,10 @@ from freqtrade.persistence import Trade
102
143
profit = Trade.total_open_trades_stakes()
103
144
```
104
145
146
+
## Class methods not supported in backtesting/hyperopt
147
+
148
+
The following class methods are not supported in backtesting/hyperopt mode.
149
+
105
150
### get_overall_performance
106
151
107
152
Retrieve the overall performance - similar to the `/performance` telegram command.
@@ -120,6 +165,17 @@ Sample return value: ETH/BTC had 5 trades, with a total profit of 1.5% (ratio of
120
165
{"pair": "ETH/BTC", "profit": 0.015, "count": 5}
121
166
```
122
167
168
+
### get_trading_volume
169
+
170
+
Get total trading volume based on orders.
171
+
172
+
```python
173
+
from freqtrade.persistence import Trade
174
+
175
+
# ...
176
+
volume = Trade.get_trading_volume()
177
+
```
178
+
123
179
## Order Object
124
180
125
181
An `Order` object represents an order on the exchange (or a simulated order in dry-run mode).
@@ -135,6 +191,10 @@ Most properties here can be None as they are dependent on the exchange response.
135
191
|`trade`| Trade | Trade object this order is attached to |
136
192
|`ft_pair`| string | Pair this order is for |
137
193
|`ft_is_open`| boolean | is the order still open? |
194
+
|`ft_order_side`| string | Order side ('buy', 'sell', or 'stoploss') |
195
+
|`ft_cancel_reason`| string | Reason why the order was canceled |
196
+
|`ft_order_tag`| string | Custom order tag |
197
+
|`order_id`| string | Exchange order ID |
138
198
|`order_type`| string | Order type as defined on the exchange - usually market, limit or stoploss |
139
199
|`status`| string | Status as defined by [ccxt's order structure](https://docs.ccxt.com/#/README?id=order-structure). Usually open, closed, expired, canceled or rejected |
140
200
|`side`| string | buy or sell |
@@ -143,12 +203,20 @@ Most properties here can be None as they are dependent on the exchange response.
143
203
|`amount`| float | Amount in base currency |
144
204
|`filled`| float | Filled amount (in base currency) (use `safe_filled` instead) |
145
205
|`safe_filled`| float | Filled amount (in base currency) - guaranteed to not be None |
206
+
|`safe_amount`| float | Amount - falls back to ft_amount if None |
207
+
|`safe_price`| float | Price - falls back through average, price, stop_price, ft_price |
208
+
|`safe_placement_price`| float | Price at which the order was placed |
|`safe_remaining`| float | Remaining amount - either taken from the exchange or calculated. |
148
-
|`cost`| float | Cost of the order - usually average * filled (*Exchange dependent on futures, may contain the cost with or without leverage and may be in contracts.*) |
149
-
|`stake_amount`| float | Stake amount used for this order. *Added in 2023.7.*|
150
-
|`stake_amount_filled`| float | Filled Stake amount used for this order. *Added in 2024.11.*|
211
+
|`safe_cost`| float | Cost of the order - guaranteed to not be None |
212
+
|`safe_fee_base`| float | Fee in base currency - guaranteed to not be None |
213
+
|`safe_amount_after_fee`| float | Amount after deducting fees |
214
+
|`cost`| float | Cost of the order - usually average * filled (*Exchange dependent on futures trading, may contain the cost with or without leverage and may be in contracts.*) |
215
+
|`stop_price`| float | Stop price for stop orders. Empty for non-stoploss orders. |
216
+
|`stake_amount`| float | Stake amount used for this order. |
217
+
|`stake_amount_filled`| float | Filled Stake amount used for this order. |
151
218
|`order_date`| datetime | Order creation date **use `order_date_utc` instead**|
152
219
|`order_date_utc`| datetime | Order creation date (in UTC) |
153
-
|`order_fill_date`| datetime | Order fill date **use `order_fill_utc` instead**|
154
-
|`order_fill_date_utc`| datetime | Order fill date |
220
+
|`order_filled_date`| datetime | Order fill date **use `order_filled_utc` instead**|
221
+
|`order_filled_utc`| datetime | Order fill date |
222
+
|`order_update_date`| datetime | Last order update date |
0 commit comments