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

27 KiB
Raw Blame History

Table of Contents

aiomql.core.constants

TradeAction Objects

class TradeAction(Repr, IntEnum)

TRADE_REQUEST_ACTION Enum.

Attributes:

  • DEAL int - Delete the pending order placed previously Place a trade order for an immediate execution with the specified parameters (market order).
  • PENDING int - Delete the pending order placed previously
  • SLTP int - Modify Stop Loss and Take Profit values of an opened position
  • MODIFY int - Modify the parameters of the order placed previously
  • REMOVE int - Delete the pending order placed previously
  • CLOSE_BY int - Close a position by an opposite one

OrderFilling Objects

class OrderFilling(Repr, IntEnum)

ORDER_TYPE_FILLING Enum.

Attributes:

  • FOK int - This execution policy means that an order can be executed only in the specified volume. If the necessary amount of a financial instrument is currently unavailable in the market, the order will not be executed. The desired volume can be made up of several available offers.

  • IOC int - An agreement to execute a deal at the maximum volume available in the market within the volume specified in the order. If the request cannot be filled completely, an order with the available volume will be executed, and the remaining volume will be canceled.

  • RETURN int - This policy is used only for market (ORDER_TYPE_BUY and ORDER_TYPE_SELL), limit and stop limit orders (ORDER_TYPE_BUY_LIMIT, ORDER_TYPE_SELL_LIMIT,ORDER_TYPE_BUY_STOP_LIMIT and ORDER_TYPE_SELL_STOP_LIMIT) and only for the symbols with Market or Exchange execution modes. If filled partially, a market or limit order with the remaining volume is not canceled, and is processed further. During activation of the ORDER_TYPE_BUY_STOP_LIMIT and ORDER_TYPE_SELL_STOP_LIMIT orders, an appropriate limit order ORDER_TYPE_BUY_LIMIT/ORDER_TYPE_SELL_LIMIT with the ORDER_FILLING_RETURN type is created.

OrderTime Objects

class OrderTime(Repr, IntEnum)

ORDER_TIME Enum.

Attributes:

  • GTC int - Good till cancel order
  • DAY int - Good till current trade day order
  • SPECIFIED int - The order is active until the specified date
  • SPECIFIED_DAY int - The order is active until 23:59:59 of the specified day. If this time appears to be out of a trading session, the expiration is processed at the nearest trading time.

OrderType Objects

class OrderType(Repr, IntEnum)

ORDER_TYPE Enum.

Attributes:

  • BUY int - Market buy order

  • SELL int - Market sell order

  • BUY_LIMIT int - Buy Limit pending order

  • SELL_LIMIT int - Sell Limit pending order

  • BUY_STOP int - Buy Stop pending order

  • SELL_STOP int - Sell Stop pending order

  • BUY_STOP_LIMIT int - Upon reaching the order price, Buy Limit pending order is placed at StopLimit price

  • SELL_STOP_LIMIT int - Upon reaching the order price, Sell Limit pending order is placed at StopLimit price

  • CLOSE_BY int - Order for closing a position by an opposite one

    Properties:

  • opposite int - Gets the opposite of an order type

opposite

@property
def opposite()

Gets the opposite of an order type for closing an open position

Returns:

  • int - integer value of opposite order type

BookType Objects

class BookType(Repr, IntEnum)

BOOK_TYPE Enum.

Attributes:

  • SELL int - Sell order (Offer)
  • BUY int - Buy order (Bid)
  • SELL_MARKET int - Sell order by Market
  • BUY_MARKET int - Buy order by Market

TimeFrame Objects

class TimeFrame(Repr, IntEnum)

TIMEFRAME Enum.

Attributes:

  • M1 int - One Minute

  • M2 int - Two Minutes

  • M3 int - Three Minutes

  • M4 int - Four Minutes

  • M5 int - Five Minutes

  • M6 int - Six Minutes

  • M10 int - Ten Minutes

  • M15 int - Fifteen Minutes

  • M20 int - Twenty Minutes

  • M30 int - Thirty Minutes

  • H1 int - One Hour

  • H2 int - Two Hours

  • H3 int - Three Hours

  • H4 int - Four Hours

  • H6 int - Six Hours

  • H8 int - Eight Hours

  • D1 int - One Day

  • W1 int - One Week

  • MN1 int - One Month

    Properties:

  • time - return the value of the timeframe object in seconds. Used as a property

Methods:

  • get - get a timeframe object from a time value in seconds

time

@property
def time()

The number of seconds in a TIMEFRAME

Returns:

  • int - The number of seconds in a TIMEFRAME

Examples:

t = TimeFrame.H1 print(t.time) 3600

CopyTicks Objects

class CopyTicks(Repr, IntEnum)

COPY_TICKS Enum. This defines the types of ticks that can be requested using the copy_ticks_from() and copy_ticks_range() functions.

Attributes:

  • ALL int - All ticks
  • INFO int - Ticks containing Bid and/or Ask price changes
  • TRADE int - Ticks containing Last and/or Volume price changes

PositionType Objects

class PositionType(Repr, IntEnum)

POSITION_TYPE Enum. Direction of an open position (buy or sell)

Attributes:

  • BUY int - Buy
  • SELL int - Sell

PositionReason Objects

class PositionReason(Repr, IntEnum)

POSITION_REASON Enum. The reason for opening a position is contained in the POSITION_REASON Enum

Attributes:

  • CLIENT int - The position was opened as a result of activation of an order placed from a desktop terminal
  • MOBILE int - The position was opened as a result of activation of an order placed from a mobile application
  • WEB int - The position was opened as a result of activation of an order placed from the web platform
  • EXPERT int - The position was opened as a result of activation of an order placed from an MQL5 program, i.e. an Expert Advisor or a script

DealType Objects

class DealType(Repr, IntEnum)

DEAL_TYPE enum. Each deal is characterized by a type, allowed values are enumerated in this enum

Attributes:

  • BUY int - Buy

  • SELL int - Sell

  • BALANCE int - Balance

  • CREDIT int - Credit

  • CHARGE int - Additional Charge

  • CORRECTION int - Correction

  • BONUS int - Bonus

  • COMMISSION int - Additional Commission

  • COMMISSION_DAILY int - Daily Commission

  • COMMISSION_MONTHLY int - Monthly Commission

  • COMMISSION_AGENT_DAILY int - Daily Agent Commission

  • COMMISSION_AGENT_MONTHLY int - Monthly Agent Commission

  • INTEREST int - Interest Rate

  • DEAL_DIVIDEND int - Dividend Operations

  • DEAL_DIVIDEND_FRANKED int - Franked (non-taxable) dividend operations

  • DEAL_TAX int - Tax Charges

  • BUY_CANCELED int - Canceled buy deal. There can be a situation when a previously executed buy deal is canceled. In this case, the type of the previously executed deal (DEAL_TYPE_BUY) is changed to DEAL_TYPE_BUY_CANCELED, and its profit/loss is zeroized. Previously obtained profit/loss is charged/withdrawn using a separated balance operation

  • SELL_CANCELED int - Canceled sell deal. There can be a situation when a previously executed sell deal is canceled. In this case, the type of the previously executed deal (DEAL_TYPE_SELL) is changed to DEAL_TYPE_SELL_CANCELED, and its profit/loss is zeroized. Previously obtained profit/loss is charged/withdrawn using a separated balance operation.

DealEntry Objects

class DealEntry(Repr, IntEnum)

DEAL_ENTRY Enum. Deals differ not only in their types set in DEAL_TYPE enum, but also in the way they change positions. This can be a simple position opening, or accumulation of a previously opened position (market entering), position closing by an opposite deal of a corresponding volume (market exiting), or position reversing, if the opposite-direction deal covers the volume of the previously opened position.

Attributes:

  • IN int - Entry In
  • OUT int - Entry Out
  • INOUT int - Reverse
  • OUT_BY int - Close a position by an opposite one

DealReason Objects

class DealReason(Repr, IntEnum)

DEAL_REASON Enum. The reason for deal execution is contained in the DEAL_REASON property. A deal can be executed as a result of triggering of an order placed from a mobile application or an MQL5 program, as well as as a result of the StopOut event, variation margin calculation, etc.

Attributes:

  • CLIENT int - The deal was executed as a result of activation of an order placed from a desktop terminal
  • MOBILE int - The deal was executed as a result of activation of an order placed from a desktop terminal
  • WEB int - The deal was executed as a result of activation of an order placed from the web platform
  • EXPERT int - The deal was executed as a result of activation of an order placed from an MQL5 program, i.e. an Expert Advisor or a script
  • SL int - The deal was executed as a result of Stop Loss activation
  • TP int - The deal was executed as a result of Take Profit activation
  • SO int - The deal was executed as a result of the Stop Out event
  • ROLLOVER int - The deal was executed due to a rollover
  • VMARGIN int - The deal was executed after charging the variation margin
  • SPLIT int - The deal was executed after the split (price reduction) of an instrument, which had an open position during split announcement

OrderReason Objects

class OrderReason(Repr, IntEnum)

ORDER_REASON Enum.

Attributes:

  • CLIENT int - The order was placed from a desktop terminal
  • MOBILE int - The order was placed from a mobile application
  • WEB int - The order was placed from a web platform
  • EXPERT int - The order was placed from an MQL5-program, i.e. by an Expert Advisor or a script
  • SL int - The order was placed as a result of Stop Loss activation
  • TP int - The order was placed as a result of Take Profit activation
  • SO int - The order was placed as a result of the Stop Out event

SymbolChartMode Objects

class SymbolChartMode(Repr, IntEnum)

SYMBOL_CHART_MODE Enum. A symbol price chart can be based on Bid or Last prices. The price selected for symbol charts also affects the generation and display of bars in the terminal. Possible values of the SYMBOL_CHART_MODE property are described in this enum

Attributes:

  • BID int - Bars are based on Bid prices
  • LAST int - Bars are based on last prices

SymbolCalcMode Objects

class SymbolCalcMode(Repr, IntEnum)

SYMBOL_CALC_MODE Enum. The SYMBOL_CALC_MODE enumeration is used for obtaining information about how the margin requirements for a symbol are calculated.

Attributes:

  • FOREX int - Forex mode - calculation of profit and margin for Forex

  • FOREX_NO_LEVERAGE int - Forex No Leverage mode calculation of profit and margin for Forex symbols without taking into account the leverage

  • FUTURES int - Futures mode - calculation of margin and profit for futures

  • CFD int - CFD mode - calculation of margin and profit for CFD

  • CFDINDEX int - CFD index mode - calculation of margin and profit for CFD by indexes

  • CFDLEVERAGE int - CFD Leverage mode - calculation of margin and profit for CFD at leverage trading

  • EXCH_STOCKS int - Calculation of margin and profit for trading securities on a stock exchange

  • EXCH_FUTURES int - Calculation of margin and profit for trading futures contracts on a stock exchange

  • EXCH_OPTIONS int - value is 34

  • EXCH_OPTIONS_MARGIN int - value is 36

  • EXCH_BONDS int - Exchange Bonds mode calculation of margin and profit for trading bonds on a stock exchange

  • STOCKS_MOEX int - Exchange MOEX Stocks mode calculation of margin and profit for trading securities on MOEX

  • EXCH_BONDS_MOEX int - Exchange MOEX Bonds mode calculation of margin and profit for trading bonds on MOEX

  • SERV_COLLATERAL int - Collateral mode - a symbol is used as a non-tradable asset on a trading account. The market value of an open position is calculated based on the volume, current market price, contract size and liquidity ratio. The value is included into Assets, which are added to Equity. Open positions of such symbols increase the Free Margin amount and are used as additional margin (collateral) for open positions

SymbolTradeMode Objects

class SymbolTradeMode(Repr, IntEnum)

SYMBOL_TRADE_MODE Enum. There are several symbol trading modes. Information about trading modes of a certain symbol is reflected in the values this enumeration

Attributes:

  • DISABLED int - Trade is disabled for the symbol
  • LONGONLY int - Allowed only long positions
  • SHORTONLY int - Allowed only short positions
  • CLOSEONLY int - Allowed only position close operations
  • FULL int - No trade restrictions

SymbolTradeExecution Objects

class SymbolTradeExecution(Repr, IntEnum)

SYMBOL_TRADE_EXECUTION Enum. The modes, or execution policies, define the rules for cases when the price has changed or the requested volume cannot be completely fulfilled at the moment.

Attributes:

  • REQUEST int - Executing a market order at the price previously received from the broker. Prices for a certain market order are requested from the broker before the order is sent. Upon receiving the prices, order execution at the given price can be either confirmed or rejected.

  • INSTANT int - Executing a market order at the specified price immediately. When sending a trade request to be executed, the platform automatically adds the current prices to the order.

    • If the broker accepts the price, the order is executed.
    • If the broker does not accept the requested price, a "Requote" is sent — the broker returns prices, at which this order can be executed.
  • MARKET int - A broker makes a decision about the order execution price without any additional discussion with the trader. Sending the order in such a mode means advance consent to its execution at this price.

  • EXCHANGE int - Trade operations are executed at the prices of the current market offers.

SymbolSwapMode Objects

class SymbolSwapMode(Repr, IntEnum)

SYMBOL_SWAP_MODE Enum. Methods of swap calculation at position transfer are specified in enumeration ENUM_SYMBOL_SWAP_MODE. The method of swap calculation determines the units of measure of the SYMBOL_SWAP_LONG and SYMBOL_SWAP_SHORT parameters. For example, if swaps are charged in the client deposit currency, then the values of those parameters are specified as an amount of money in the client deposit currency.

Attributes:

  • DISABLED int - Swaps disabled (no swaps)

  • POINTS int - Swaps are charged in points

  • CURRENCY_SYMBOL int - Swaps are charged in money in base currency of the symbol

  • CURRENCY_MARGIN int - Swaps are charged in money in margin currency of the symbol

  • CURRENCY_DEPOSIT int - Swaps are charged in money, in client deposit currency

  • INTEREST_CURRENT int - Swaps are charged as the specified annual interest from the instrument price at calculation of swap (standard bank year is 360 days)

  • INTEREST_OPEN int - Swaps are charged as the specified annual interest from the open price of position (standard bank year is 360 days)

  • REOPEN_CURRENT int - Swaps are charged by reopening positions. At the end of a trading day the position is closed. Next day it is reopened by the close price +/- specified number of points (parameters SYMBOL_SWAP_LONG and SYMBOL_SWAP_SHORT)

  • REOPEN_BID int - Swaps are charged by reopening positions. At the end of a trading day the position is closed. Next day it is reopened by the current Bid price +/- specified number of points (parameters SYMBOL_SWAP_LONG and SYMBOL_SWAP_SHORT)

DayOfWeek Objects

class DayOfWeek(Repr, IntEnum)

DAY_OF_WEEK Enum.

Attributes:

  • SUNDAY int - Sunday
  • MONDAY int - Monday
  • TUESDAY int - Tuesday
  • WEDNESDAY int - Wednesday
  • THURSDAY int - Thursday
  • FRIDAY int - Friday
  • SATURDAY int - Saturday

SymbolOrderGTCMode Objects

class SymbolOrderGTCMode(Repr, IntEnum)

SYMBOL_ORDER_GTC_MODE Enum. If the SYMBOL_EXPIRATION_MODE property is set to SYMBOL_EXPIRATION_GTC (good till canceled), the expiration of pending orders, as well as of Stop Loss/Take Profit orders should be additionally set using the ENUM_SYMBOL_ORDER_GTC_MODE enumeration.

Attributes:

  • GTC int - Pending orders and Stop Loss/Take Profit levels are valid for an unlimited period until theirConstants, Enumerations and explicit cancellation

  • DAILY int - Orders are valid during one trading day. At the end of the day, all Stop Loss and Take Profit levels, as well as pending orders are deleted.

  • DAILY_NO_STOPS int - When a trade day changes, only pending orders are deleted, while Stop Loss and Take Profit levels are preserved

SymbolOptionRight Objects

class SymbolOptionRight(Repr, IntEnum)

SYMBOL_OPTION_RIGHT Enum. An option is a contract, which gives the right, but not the obligation, to buy or sell an underlying asset (goods, stocks, futures, etc.) at a specified price on or before a specific date. The following enumerations describe option properties, including the option type and the right arising from it.

Attributes:

  • CALL int - A call option gives you the right to buy an asset at a specified price.
  • PUT int - A put option gives you the right to sell an asset at a specified price.

SymbolOptionMode Objects

class SymbolOptionMode(Repr, IntEnum)

SYMBOL_OPTION_MODE Enum.

Attributes:

  • EUROPEAN int - European option may only be exercised on a specified date (expiration, execution date, delivery date)
  • AMERICAN int - American option may be exercised on any trading day or before expiry. The period within which a buyer can exercise the option is specified for it.

AccountTradeMode Objects

class AccountTradeMode(Repr, IntEnum)

ACCOUNT_TRADE_MODE Enum. There are several types of accounts that can be opened on a trade server. The type of account on which an MQL5 program is running can be found out using the ENUM_ACCOUNT_TRADE_MODE enumeration.

Attributes:

  • DEMO - Demo account
  • CONTEST - Contest account
  • REAL - Real Account

TickFlag Objects

class TickFlag(Repr, IntFlag)

TICK_FLAG Enum. TICK_FLAG defines possible flags for ticks. These flags are used to describe ticks obtained by the copy_ticks_from() and copy_ticks_range() functions.

Attributes:

  • BID int - Bid price changed
  • ASK int - Ask price changed
  • LAST int - Last price changed
  • VOLUME int - Volume changed
  • BUY int - last Buy price changed
  • SELL int - last Sell price changed

TradeRetcode Objects

class TradeRetcode(Repr, IntEnum)

TRADE_RETCODE Enum. Return codes for order send/check operations

Attributes:

  • REQUOTE int - Requote

  • REJECT int - Request rejected

  • CANCEL int - Request canceled by trader

  • PLACED int - Order placed

  • DONE int - Request completed

  • DONE_PARTIAL int - Only part of the request was completed

  • ERROR int - Request processing error

  • TIMEOUT int - Request canceled by timeout

  • INVALID int - Invalid request

  • INVALID_VOLUME int - Invalid volume in the request

  • INVALID_PRICE int - Invalid price in the request

  • INVALID_STOPS int - Invalid stops in the request

  • TRADE_DISABLED int - Trade is disabled

  • MARKET_CLOSED int - Market is closed

  • NO_MONEY int - There is not enough money to complete the request

  • PRICE_CHANGED int - Prices changed

  • PRICE_OFF int - There are no quotes to process the request

  • INVALID_EXPIRATION int - Invalid order expiration date in the request

  • ORDER_CHANGED int - Order state changed

  • TOO_MANY_REQUESTS int - Too frequent requests

  • NO_CHANGES int - No changes in request

  • SERVER_DISABLES_AT int - Autotrading disabled by server

  • CLIENT_DISABLES_AT int - Autotrading disabled by client terminal

  • LOCKED int - Request locked for processing

  • FROZEN int - Order or position frozen

  • INVALID_FILL int - Invalid order filling type

  • CONNECTION int - No connection with the trade server

  • ONLY_REAL int - Operation is allowed only for live accounts

  • LIMIT_ORDERS int - The number of pending orders has reached the limit

  • LIMIT_VOLUME int - The volume of orders and positions for the symbol has reached the limit

  • INVALID_ORDER int - Incorrect or prohibited order type

  • POSITION_CLOSED int - Position with the specified POSITION_IDENTIFIER has already been closed

  • INVALID_CLOSE_VOLUME int - A close volume exceeds the current position volume

  • CLOSE_ORDER_EXIST int - A close order already exists for a specified position. This may happen when working in the hedging system: · when attempting to close a position with an opposite one, while close orders for the position already exist · when attempting to fully or partially close a position if the total volume of the already present close orders and the newly placed one exceeds the current position volume

  • LIMIT_POSITIONS int - The number of open positions simultaneously present on an account can be limited by the server settings.After a limit is reached, the server returns the TRADE_RETCODE_LIMIT_POSITIONS error when attempting to place an order. The limitation operates differently depending on the position accounting type: · Netting — number of open positions is considered. When a limit is reached, the platform does not let placing new orders whose execution may increase the number of open positions. In fact, the platform allows placing orders only for the symbols that already have open positions. The current pending orders are not considered since their execution may lead to changes in the current positions but it cannot increase their number.

    · Hedging — pending orders are considered together with open positions, since a pending order activation always leads to opening a new position. When a limit is reached, the platform does not allow placing both new market orders for opening positions and pending orders.

  • REJECT_CANCEL int - The pending order activation request is rejected, the order is canceled.

  • LONG_ONLY int - The request is rejected, because the "Only long positions are allowed" rule is set for the symbol (POSITION_TYPE_BUY)

  • SHORT_ONLY int - The request is rejected, because the "Only short positions are allowed" rule is set for the symbol (POSITION_TYPE_SELL)

  • CLOSE_ONLY int - The request is rejected, because the "Only position closing is allowed" rule is set for the symbol

  • FIFO_CLOSE int - The request is rejected, because "Position closing is allowed only by FIFO rule" flag is set for the trading account (ACCOUNT_FIFO_CLOSE=true)

AccountStopOutMode Objects

class AccountStopOutMode(Repr, IntEnum)

ACCOUNT_STOPOUT_MODE Enum.

Attributes:

  • PERCENT int - Account stop out mode in percents
  • MONEY int - Account stop out mode in money

AccountMarginMode Objects

class AccountMarginMode(Repr, IntEnum)

ACCOUNT_MARGIN_MODE Enum.

Attributes:

  • RETAIL_NETTING int - Used for the OTC markets to interpret positions in the "netting" mode (only one position can exist for one symbol). The margin is calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE).

  • EXCHANGE int - Used for the exchange markets. Margin is calculated based on the discounts specified in symbol settings. Discounts are set by the broker, but not less than the values set by the exchange.

  • HEDGING int - Used for the exchange markets where individual positions are possible (hedging, multiple positions can exist for one symbol). The margin is calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE) taking into account the hedged margin (SYMBOL_MARGIN_HEDGED).