mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-23 16:58:07 +00:00
v4.0.17 no-backtest
This commit is contained in:
+23
-68
@@ -1,80 +1,35 @@
|
||||
# Result
|
||||
# result
|
||||
|
||||
## Table of Contents
|
||||
- [Result](#result.result)
|
||||
- [__init__](#result.__init__)
|
||||
- [save](#result.save)
|
||||
- [get_data](#result.get_data)
|
||||
- [to_csv](#result.to_csv)
|
||||
- [to_json](#result.to_json)
|
||||
`aiomql.lib.result` — Trade result recording (CSV / JSON / SQL).
|
||||
|
||||
## Overview
|
||||
|
||||
<a id="result.result"></a>
|
||||
```python
|
||||
class Result
|
||||
```
|
||||
A base class for handling trade results and strategy parameters for record keeping and analysis.
|
||||
#### Attributes:
|
||||
| Name | Type | Description |
|
||||
|--------------|-------------------|-----------------------------------|
|
||||
| `result` | `OrderSendResult` | The result of the trade |
|
||||
| `parameters` | `dict` | The parameters used for the trade |
|
||||
| `name` | `str` | The name of the result object |
|
||||
The `Result` class records trade outcomes and strategy parameters to files in CSV, JSON,
|
||||
or SQL format. It integrates with the `Config` to determine the recording directory and
|
||||
format.
|
||||
|
||||
Inherits from [`_Base`](../core/base.md).
|
||||
|
||||
<a id="result.__init__"></a>
|
||||
### \__init\__
|
||||
```python
|
||||
def __init__(*, result: OrderSendResult, parameters: dict = None, name: str = '')
|
||||
```
|
||||
Prepare result data for record keeping and analysis.
|
||||
## Classes
|
||||
|
||||
#### Parameters:
|
||||
| Name | Type | Description |
|
||||
|--------------|-------------------|-----------------------------------|
|
||||
| `result` | `OrderSendResult` | The result of the trade |
|
||||
| `parameters` | `dict` | The parameters used for the trade |
|
||||
| `name` | `str` | The name of the result object |
|
||||
### `Result`
|
||||
|
||||
> Saves trade results to persistent storage.
|
||||
|
||||
<a id="result.get_data"></a>
|
||||
### get_data
|
||||
```python
|
||||
def get_data(self) -> dict
|
||||
```
|
||||
Get the result data as a dictionary
|
||||
| Attribute | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `config` | `Config` | Global configuration |
|
||||
|
||||
#### Returns:
|
||||
| Type | Description |
|
||||
|--------|-----------------|
|
||||
| `dict` | The result data |
|
||||
#### Methods
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `save(result, parameters, name)` | Dispatches to the configured format (CSV/JSON/SQL) |
|
||||
| `save_csv(result, parameters, name)` | Appends a result row to a CSV file |
|
||||
| `save_json(result, parameters, name)` | Appends a result object to a JSON file |
|
||||
| `save_sql(result, parameters, name)` | Saves the result to the SQLite database |
|
||||
| `get_data(result, parameters)` | Prepares a unified dict from result and parameters |
|
||||
|
||||
<a id="result.to_save"></a>
|
||||
### to_save
|
||||
```python
|
||||
async def to_save(*, trade_record_mode: Literal["csv", "json"] = None)
|
||||
```
|
||||
Save to json or csv depending on the trade record mode.
|
||||
## Synchronous API
|
||||
|
||||
#### Returns:
|
||||
| Name | Type | Description | Default |
|
||||
|---------------------|--------------------------|-----------------------|---------|
|
||||
| `trade_record_mode` | `Literal["csv", "json"]` | The trade record mode | None |
|
||||
|
||||
|
||||
<a id="result.to_csv"></a>
|
||||
### to_csv
|
||||
```python
|
||||
async def to_csv()
|
||||
```
|
||||
Record trade results and associated parameters as a csv file
|
||||
|
||||
|
||||
<a id="result.to_json"></a>
|
||||
### to_json
|
||||
```python
|
||||
async def to_json()
|
||||
```
|
||||
Record trade results and associated parameters as a json file
|
||||
```
|
||||
Available in `aiomql.lib.sync.result`.
|
||||
|
||||
Reference in New Issue
Block a user