This commit is contained in:
Ichinga Samuel
2024-11-30 23:10:31 +01:00
parent bd2139dd64
commit 01f8c4af7d
22 changed files with 431 additions and 58 deletions
+9
View File
@@ -12,6 +12,7 @@
- [calc_profit](#order.calc_profit)
- [calc_loss](#order.calc_loss)
- [request](#order.request)
- [modify](#order.modify)
<a id="order.order"></a>
### Order
@@ -160,3 +161,11 @@ Return the trade request object as a dict
| Type | Description |
|--------|----------------------------------|
| `dict` | Returns the trade request object |
<a id="order.modify"></a>
### modify
```python
def modify(**kwargs)
```
Modify the order object with keyword arguments.
+30 -7
View File
@@ -10,6 +10,7 @@
- [close_position_by_ticket](#positions.close_position_by_ticket)
- [close_position](#positions.close_position)
- [close_all](#positions.close_all)
- [get_total_positions](#positions.get_total_positions)
<a id="positions.positions"></a>
### Positions
@@ -19,10 +20,11 @@ class Positions
Get and handle Open positions.
#### Attributes
| Name | Type | Description |
|-------------|-----------------------------|----------------------------|
| `positions` | `tuple[TradePosition, ...]` | Financial instrument name. |
| `mt5` | `MetaTrader` | MetaTrader instance. |
| Name | Type | Description |
|-------------|-----------------------------|-------------------------------------------------------------------------------------|
| `positions` | `tuple[TradePosition, ...]` | Financial instrument name. |
| `mt5` | `MetaTrader` | MetaTrader instance. |
|`total_positions`| `int` | Total number of open positions. Can be set in `get_positions` or `get_total_positions`. |
<a id="positions.__init__"></a>
### \_\_init\_\_
@@ -35,11 +37,19 @@ Initialize a position instance
<a id="positions.get_position"></a>
### get_positions
```python
async def get_positions(self) -> tuple[TradePosition, ...]:
async def get_positions(*, symbol: str = None, ticket: int = None, group: str = None) -> tuple[TradePosition, ...]:
```
Get open positions
Get open positions, with the ability to filter by symbol, ticket, or group.
#### Returns
#### Parameters:
| Name | Type | Description |
|----------|-------|-----------------|
| `symbol` | `str` | Symbol |
| `ticket` | `int` | Position ticket |
| `group` | `str` | Group name |
#### Returns:
| Type | Description |
|-----------------------------|--------------------------------|
| `tuple[TradePosition, ...]` | A list of open trade positions |
@@ -150,3 +160,16 @@ Close all open positions for the trading account.
| Type | Description |
|-------|--------------------------------------|
| `int` | Return total number of closed trades |
<a id="positions.get_total_positions"></a>
### get_total_positions
```python
async def get_total_positions() -> int
```
Get the total number of open positions and set the `total_positions` attribute.
#### Returns:
| Type | Description |
|-------|--------------------------------------|
| `int` | Return total number of open trades |
+9
View File
@@ -6,6 +6,7 @@
- [get_amount](#ram.get_amount)
- [check_losing_positions](#ram.check_losing_positions)
- [check_open_positions](#ram.check_open_positions)
- [modify_ram](#ram.modify_ram)
<a id="ram.ram"></a>
### RAM
@@ -75,3 +76,11 @@ Check if the number of open positions is less than or equal the loss limit.
| Type | Description |
|--------|---------------------------------------------------------------------------------------|
| `bool` | True if the number of open losing trades is more than the loss limit, False otherwise |
<a id="ram.modify_ram"></a>
### modify_ram
```python
def modify_ram(**kwargs):
```
Modify the RAM attributes. All provided keyword arguments are set as attributes.