Files
aiomql/docs/lib/trade_records.md
T
Ichinga Samuel f56d0c85b3 v4
2024-11-10 12:25:50 +01:00

5.0 KiB

Trade Records

Table of contents

Trade Records

class TradeRecords()

This utility class read trade records from csv and json files, and update them based on their closing positions. Once a trade have been closed, the actual profit and win status will be updated in the file.

Attributes:

name type description
config Config Config object
records_dir Path A directory for finding the trade records

_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_csv_records

async def get_csv_records()

Get trade records from records_dir folder.

Yields:

type description
Path Trade record files

get_json_records

async def get_json_records()

Get trade records from records_dir folder.

Yields

type description
Path Trade record files

read_update_csv

async def read_update_csv(*, file: Path)

Read and update trade records from a csv file.

Parameters:

name type description
file Path Trade record file

read_update_json

async def read_update_json(*, file: Path)

Read and update trade records from a json file.

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 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_row

async def update_row(row: dict) -> dict

Update the row of an entered trade with the actual profit.

Parameters:

Name Type Description
row dict A dictionary from the csv file row object

Returns:

Type Description
dict A dictionary with the actual profit

update_csv_record

async def update_csv_record(*, file: Path | str)

Update a single trade record csv file

Parameters:

Name Type Description
file Path A trade record csv file

update_csv_records

def update_csv_records()

Update csv trade records in the records_dir folder.

update_csv_record

async def update_json_record(*, file: Path | str)

Update a single trade record json file

Parameters:

Name Type Description
file Path A trade record json file

update_json_records

def update_json_records()

Update json trade records in the records_dir folder.