2024-02-12 21:09:28 +01:00
|
|
|
# Risk Assessment and Management
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2024-02-12 21:09:28 +01:00
|
|
|
## Table of Contents
|
2024-11-10 12:25:50 +01:00
|
|
|
- [RAM](#ram.ram)
|
|
|
|
|
- [\__init\__](#ram.__init__)
|
|
|
|
|
- [get_amount](#ram.get_amount)
|
|
|
|
|
- [check_losing_positions](#ram.check_losing_positions)
|
|
|
|
|
- [check_open_positions](#ram.check_open_positions)
|
2024-11-30 23:10:31 +01:00
|
|
|
- [modify_ram](#ram.modify_ram)
|
2024-02-12 21:09:28 +01:00
|
|
|
|
2024-11-10 12:25:50 +01:00
|
|
|
<a id="ram.ram"></a>
|
2024-02-12 21:09:28 +01:00
|
|
|
### RAM
|
2023-10-11 09:49:06 +01:00
|
|
|
```python
|
2024-02-12 21:09:28 +01:00
|
|
|
class RAM
|
2023-10-11 09:49:06 +01:00
|
|
|
```
|
2024-02-12 21:09:28 +01:00
|
|
|
Risk Assessment and Management. You can customize this class based on how you want to manage risk.
|
2024-05-05 00:08:57 +01:00
|
|
|
|
2024-11-10 12:25:50 +01:00
|
|
|
#### Attributes:
|
|
|
|
|
| Name | Type | Description | Default |
|
|
|
|
|
|------------------|-----------|---------------------------------------------------|-----------|
|
|
|
|
|
| `account` | `Account` | The account object | Account() |
|
|
|
|
|
| `risk_to_reward` | `float` | Risk to reward ratio | 2 |
|
|
|
|
|
| `risk` | `float` | Percentage of account balance to risk per trade | 1% |
|
|
|
|
|
| `fixed_amount` | `float` | A fixed amount to risk per trade | |
|
|
|
|
|
| `min_amount` | `float` | Minimum amount to risk per trade | |
|
|
|
|
|
| `max_amount` | `float` | Maximum amount to risk per trade | |
|
|
|
|
|
| `loss_limit` | `int` | Number of open losing trades to allow at any time | 3 |
|
|
|
|
|
| `open_limit` | `int` | Number of open trades to allow at any time | 3 |
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2024-11-10 12:25:50 +01:00
|
|
|
|
|
|
|
|
<a id="ram.__init__"></a>
|
2024-02-12 21:09:28 +01:00
|
|
|
### \_\_init\_\_
|
2023-10-11 09:49:06 +01:00
|
|
|
```python
|
2024-11-10 12:25:50 +01:00
|
|
|
def __init__(self, **kwargs):
|
2023-10-11 09:49:06 +01:00
|
|
|
```
|
|
|
|
|
Risk Assessment and Management. All provided keyword arguments are set as attributes.
|
2023-11-14 03:24:47 +01:00
|
|
|
#### Parameters
|
2024-11-10 12:25:50 +01:00
|
|
|
| Name | Type | Description | Default |
|
|
|
|
|
|------------------|--------|----------------------------------------------------|-----------|
|
|
|
|
|
| `kwargs` | `dict` | Keyword arguments to be set as instance attributes | {} |
|
2023-10-11 09:49:06 +01:00
|
|
|
|
|
|
|
|
|
2024-11-10 12:25:50 +01:00
|
|
|
<a id="ram.get_amount"></a>
|
|
|
|
|
### ram.get_amount
|
2023-10-11 09:49:06 +01:00
|
|
|
```python
|
2024-02-12 21:09:28 +01:00
|
|
|
async def get_amount() -> float
|
2023-10-11 09:49:06 +01:00
|
|
|
```
|
2024-02-12 21:09:28 +01:00
|
|
|
Calculate the amount to risk per trade as a percentage of balance.
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2024-11-10 12:25:50 +01:00
|
|
|
#### Returns:
|
|
|
|
|
| Type | Description |
|
|
|
|
|
|---------|-------------------------------------------------------|
|
|
|
|
|
| `float` | Amount to risk per trade in terms of account currency |
|
|
|
|
|
|
|
|
|
|
<a id="ram.check_losing_positions"></a>
|
2024-02-12 21:09:28 +01:00
|
|
|
### check_losing_positions
|
|
|
|
|
```python
|
|
|
|
|
async def check_losing_positions(self) -> bool:
|
|
|
|
|
```
|
|
|
|
|
Check if the number of open losing trades is greater than or equal to the loss limit.
|
2023-10-11 09:49:06 +01:00
|
|
|
|
2024-11-10 12:25:50 +01:00
|
|
|
#### Returns:
|
|
|
|
|
| Type | Description |
|
|
|
|
|
|--------|---------------------------------------------------------------------------------------|
|
|
|
|
|
| `bool` | True if the number of open losing trades is more than the loss limit, False otherwise |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="ram.check_open_positions"></a>
|
|
|
|
|
### check_open_positions
|
2024-02-12 21:09:28 +01:00
|
|
|
```python
|
2024-11-10 12:25:50 +01:00
|
|
|
async def check_open_positions(self) -> bool:
|
2024-02-12 21:09:28 +01:00
|
|
|
```
|
2024-11-10 12:25:50 +01:00
|
|
|
Check if the number of open positions is less than or equal the loss limit.
|
|
|
|
|
|
|
|
|
|
#### Returns:
|
|
|
|
|
| Type | Description |
|
|
|
|
|
|--------|---------------------------------------------------------------------------------------|
|
|
|
|
|
| `bool` | True if the number of open losing trades is more than the loss limit, False otherwise |
|
2024-11-30 23:10:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
<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.
|