mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-07-27 20:27:43 +00:00
3.5 KiB
3.5 KiB
Records
Table of contents
Records
class Records()
This utility class read trade records from csv files, and update them based on their closing positions. To use this default
implementation the csv files should at least have the following columns ['order', 'symbol', 'actual_profit', 'win', 'closed']
Once a trade have been closed, the actual profit and win status will be updated in the csv file.
Default Headers
| column | type | description |
|---|---|---|
| order | int | Order id of the trade |
| symbol | str | the name of the Symbol |
| actual_profit | float | The actual profit of the trade, this zero by default |
| win | bool | The win status of the trade, this is False by default |
| closed | bool | The status of the trade, this is False by default |
Attributes
| name | type | description |
|---|---|---|
| records_dir | Path | Absolut path to directory containing record of placed trades |
| config | Config | Config object |
__init__
def __init__(records_dir: Path | str = '')
Initialize an instance of the class
Parameters
| name | type | description |
|---|---|---|
| records_dir | Path | Absolute path to directory containing record of placed trades. |
get_records
async def get_records()
Get trade records from records_dir folder
Yields
| type | description |
|---|---|
| Path | Trade record files |
read_update
async def read_update(file: Path)
Read and update trade records
Parameters
| name | type | description |
|---|---|---|
| file | Path | Trade record file |
update_rows
async def update_rows(rows: list[dict]) -> list[dict]
Update the rows of entered trades in the csv file with the actual profit.
Parameters
| name | type | description |
|---|---|---|
| rows | list[dict] | A list of dictionaries from the dictionary writer object of the csv file. |
Returns
| type | description |
|---|---|
| list[dict] | A list of dictionaries with the actual profit and win status. |
update_records
async def update_records()
Update trade records in the records_dir folder.
update_record
async def update_record(file: Path | str)
Update a single trade record file.