Files
aiomql/docs/strategy.md
T
Ichinga Samuel 027f9fd8de add docs
2023-10-11 09:49:06 +01:00

1.7 KiB

aiomql.strategy

The base class for creating strategies.

Strategy Objects

class Strategy(ABC)

The base class for creating strategies.

Attributes:

  • symbol Symbol - The Financial Instrument as a Symbol Object

  • parameters Dict - A dictionary of parameters for the strategy.

    Class Attributes:

  • name str - A name for the strategy.

  • account Account - Account instance.

  • mt5 MetaTrader - MetaTrader instance.

  • config Config - Config instance.

Notes:

Define the name of a strategy as a class attribute. If not provided, the class name will be used as the name.

__init__

def __init__(*, symbol: Symbol, params: dict = None)

Initiate the parameters dict and add name and symbol fields. Use class name as strategy name if name is not provided

Arguments:

  • symbol Symbol - The Financial instrument
  • params Dict - Trading strategy parameters

sleep

@staticmethod
async def sleep(secs: float)

Sleep for the needed amount of seconds in between requests to the terminal. computes the accurate amount of time needed to sleep ensuring that the next request is made at the start of a new bar and making cooperative multitasking possible.

Arguments:

  • secs float - The time in seconds. Usually the timeframe you are trading on.

trade

@abstractmethod
async def trade()

Place trades using this method. This is the main method of the strategy. It will be called by the strategy runner.