Files
aiomql/docs/trader.md
T

66 lines
2.7 KiB
Markdown
Raw Normal View History

2023-10-16 15:36:31 +01:00
## <a id="trader"></a> Trader
2023-10-11 09:49:06 +01:00
Trader class module. Handles the creation of an order and the placing of trades
```python
class Trader()
```
Base class for creating a Trader object. Handles the creation of an order and the placing of trades
2023-10-16 15:36:31 +01:00
### Attributes:
|Name|Type|Description|Default|
|---|---|---|---|
|**name**|**str**|A name for the strategy.|None|
|**account**|**Account**|Account instance.|None|
|**mt5**|**MetaTrader**|MetaTrader instance.|None|
|**config**|**Config**|Config instance.|None|
|**symbol**|**Symbol**|The Financial Instrument as a Symbol Object|None|
|**parameters**|**Dict**|A dictionary of parameters for the strategy.|None|
2023-10-11 09:49:06 +01:00
2023-10-16 15:36:31 +01:00
### \_\_init\_\_
2023-10-11 09:49:06 +01:00
```python
def __init__(*, symbol: Symbol, ram: RAM = None)
```
2023-10-16 15:36:31 +01:00
|Name| Type | Description | Default |
|---|--------------------|-----------------------------|-------------------|
|**symbol**| **Symbol** | The Financial instrument | None |
|**ram**| **RAM** | Risk Assessment and Management instance | None |
2023-10-11 09:49:06 +01:00
Initializes the order object and RAM instance
2023-10-16 15:36:31 +01:00
#### Arguments:
|Name| Type | Description | Default |
|---|--------------------|-----------------------------|-------------------|
|**symbol**| **Symbol** | The Financial instrument | None |
|**ram**| **RAM** | Risk Assessment and Management instance | None |
### create\_order
2023-10-11 09:49:06 +01:00
```python
async def create_order(*, order_type: OrderType, **kwargs)
```
Complete the order object with the required values. Creates a simple order.
Uses the ram instance to set the volume.
2023-10-16 15:36:31 +01:00
#### Arguments:
|Name| Type | Description | Default |
|---|--------------------|-----------------------------|-------------------|
|**order_type**| **OrderType** | Type of order | None |
|**kwargs**| | keyword arguments as required for the specific trader | |
2023-10-11 09:49:06 +01:00
2023-10-16 15:36:31 +01:00
### set\_order\_limits
2023-10-11 09:49:06 +01:00
```python
async def set_order_limits(pips: float)
```
Sets the stop loss and take profit for the order.
This method uses pips as defined for forex instruments.
2023-10-16 15:36:31 +01:00
#### Arguments:
|Name| Type | Description | Default |
|---|--------------------|-----------------------------|-------------------|
|**pips**| **float** | Target pips | None |
2023-10-11 09:49:06 +01:00
2023-10-16 15:36:31 +01:00
### place\_trade
2023-10-11 09:49:06 +01:00
```python
async def place_trade(order_type: OrderType, params: dict = None, **kwargs)
```
Places a trade based on the order_type.
2023-10-16 15:36:31 +01:00
#### Arguments:
|Name| Type | Description | Default |
|---|--------------------|-----------------------------|-------------------|
|**order_type**| **OrderType** | Type of order | None |
|**params**| **dict** | parameters to be saved with the trade | None |
|**kwargs**| | keyword arguments as required for the specific trader | |