Files
aiomql/docs/trader.md
T
Ichinga Samuel 1eeabd99fd v3.21
2024-05-05 00:08:57 +01:00

4.5 KiB

Trader

Trader class module. Handles the creation of an order and the placing of trades

Table of Contents

Trader

class Trader()

Base class for creating a Trader object. Handles the creation of an order and the placing of trades

Attributes

Name Type Description Default
ram RAM Risk Assessment Management System. None
config Config Config instance. None
order Order Order instance. None
symbol Symbol The Financial Instrument None
params Dict A dictionary of parameters associated with the trade. None

__init__

def __init__(*, symbol: Symbol, ram: RAM = None)

Parameters

Name Type Description Default
symbol Symbol The Financial instrument None
ram RAM Risk Assessment and Management instance None

create_order

async def create_order(*, order_type: OrderType, `kwargs)

Complete the order object with the required values. Creates a simple order.

Parameters

Name Type Description Default
order_type OrderType Type of order None
kwargs keyword arguments as required for the specific trader

set_order_limits

async def set_order_limits(pips: float):

Sets the stop loss and take profit for the order. This method uses pips as defined for forex instruments.

Parameters

Name Type Description Default
pips float Target pips None

set_trade_stop_levels

async def set_trade_stop_levels(*, points)

sets the stop loss and take profit for the order. This method uses points as defined by MetaTrader5 for all symbols.

Parameters

Name Type Description Default
points float Target points None

send_order

async def send_order()

Sends the order to the broker for execution. Record the trade.

check_order

async def check_order()

Checks the status of the order before placing the trade.

Returns

Type Description
bool True if order is valid else False

record_trade

async def record_trade(result: OrderSendResult, parameters: dict = None, name: str = '', exclude: set = None)

Records the trade and the order details if Config.record_trades is true. Trades are recorded as either json or csv.

Parameters

Name Type Description Default
result OrderSendResult The result of the placed order None
parameters dict parameters to saved instead of the ones in self.parameters None
name str Name for the csv or json file ''
exclude set Set of keys to exclude from the saved parameters None

place_trade

@abstractmethod
    async def place_trade(self, *args, **kwargs):

Places a trade. All traders must implement this method.