Files
aiomql/docs/order.md
T

116 lines
2.7 KiB
Markdown
Raw Normal View History

2023-10-11 09:49:06 +01:00
## <a id="order"></a> Order
```python
class Order(TradeRequest)
```
Trade order related functions and properties. Subclass of [TradeRequest](#traderequest).
2023-10-16 15:36:31 +01:00
### \_\_init\_\_
2023-10-11 09:49:06 +01:00
```python
def __init__(**kwargs)
```
Initialize the order object with keyword arguments, symbol must be provided.
Provides default values for action, type_time and type_filling if not provided.
2023-10-16 15:36:31 +01:00
#### Arguments:
|Name| Type | Description | Default |
|---|-------------------------|--------------|-------------------|
|**symbol**| **str** \| **Symbol** | Symbol name. Required keyword argument | |
|**action**| **TradeAction** | Trade action | TradeAction.DEAL |
|**type_time**| **OrderTime** | Order time | OrderTime.DAY |
|**type_filling**| **OrderFilling** | Order filling | OrderFilling.FOK |
#### Raises:
2023-10-11 09:49:06 +01:00
|Exception|Description|
|---|---|
|**SymbolError**|If symbol is not provided|
2023-10-16 15:36:31 +01:00
### <a id=order.Order.orders_total> orders_total
2023-10-11 09:49:06 +01:00
```python
async def orders_total()
```
Get the number of active orders.
2023-10-16 15:36:31 +01:00
#### Returns:
2023-10-11 09:49:06 +01:00
|Type|Description|
|---|---|
|**int**|total number of active orders|
2023-10-16 15:36:31 +01:00
### orders
2023-10-11 09:49:06 +01:00
```python
async def orders() -> tuple[TradeOrder]
```
Get the list of active orders for the current symbol.
2023-10-16 15:36:31 +01:00
#### Returns:
2023-10-11 09:49:06 +01:00
|Type|Description|
|---|---|
|**tuple[TradeOrder]**|A Tuple of active trade orders as TradeOrder objects|
2023-10-16 15:36:31 +01:00
### check
2023-10-11 09:49:06 +01:00
```python
async def check() -> OrderCheckResult
```
Check funds sufficiency for performing a required trading operation and the possibility to execute it at
2023-10-16 15:36:31 +01:00
#### Returns::
2023-10-11 09:49:06 +01:00
|Type|Description|
|---|---|
|**OrderCheckResult**|An OrderCheckResult object|
2023-10-16 15:36:31 +01:00
#### Raises:
2023-10-11 09:49:06 +01:00
|Exception|Description|
|---|---|
|**OrderError**|If not successful|
- `OrderError` - If not successful
#### <a id="order.Order.send"></a> send
```python
async def send() -> OrderSendResult
```
Send a request to perform a trading operation from the terminal to the trade server.
2023-10-16 15:36:31 +01:00
#### Returns:
2023-10-11 09:49:06 +01:00
|Type|Description|
|---|---|
|**OrderSendResult**|An OrderSendResult object|
2023-10-16 15:36:31 +01:00
#### Raises:
2023-10-11 09:49:06 +01:00
|Exception|Description|
|---|---|
|**OrderError**|If not successful|
2023-10-16 15:36:31 +01:00
### calc_margin
2023-10-11 09:49:06 +01:00
```python
async def calc_margin() -> float
```
Return the required margin in the account currency to perform a specified trading operation.
2023-10-16 15:36:31 +01:00
#### Returns:
2023-10-11 09:49:06 +01:00
|Type|Description|
|---|---|
|**float**|Returns float value if successful|
2023-10-16 15:36:31 +01:00
#### Raises:
2023-10-11 09:49:06 +01:00
|Exception|Description|
|---|---|
|**OrderError**|If not successful|
2023-10-16 15:36:31 +01:00
### calc_profit
2023-10-11 09:49:06 +01:00
```python
async def calc_profit() -> float
```
Return profit in the account currency for a specified trading operation.
2023-10-16 15:36:31 +01:00
#### Returns:
2023-10-11 09:49:06 +01:00
|Type|Description|
|---|---|
|**float**|Returns float value if successful|
2023-10-16 15:36:31 +01:00
#### Raises:
2023-10-11 09:49:06 +01:00
|Exception|Description|
|---|---|
|**OrderError**|If not successful|