HookTradeProcessOpen
HookTradeProcessOpen¶
The hook is triggered during the recalculation of a trade request.
Warning
This hook is highly sensitive — it can affect the operation of the entire server. Do not use this hook unless absolutely necessary.
virtual int HookTradeProcessOpen(
const TradeRecord& trade, // reference to the trade request object
const GroupRecord& group, // reference to the group configuration object
const SymbolRecord& symbol, // reference to the symbol configuration object
const AccountRecord& user, // reference to the account object
const MarginLevel& margin, // reference to the margin state object
TradeDiffRecord& trade_dif // [in/out] reference to the trade difference object that must be applied as a result of executing the trade request (see below)
);
Parameters¶
-
trade
[in]Reference to the TradeRecord object representing the trade request. -
group
[in]Reference to the GroupRecord object representing the client group configuration for which the request is processed. -
symbol
[in]Reference to the SymbolRecord object representing the symbol configuration for which the request is processed. -
user
[in]Reference to the AccountRecord object representing the current account associated with the request. -
margin
[in]Reference to the MarginLevel object representing the current margin state associated with the request. -
trade_dif
[in/out]Reference to the TradeDiffRecord object that should be created as a result of executing the trade request.
This is filled only for requests related to the creation of a new order (see the list below). The order is fully prepared to be added to the trading database (all fields are filled except for the ticket). The creation of the new order and assignment of the ticket happens only afterRET_OK_CHANGEis returned from the hook.
Return Value¶
- If
RET_OKis returned, the operation is confirmed. - Otherwise, the request will be rejected with the corresponding code.
Notes¶
- Depending on the type of request, the parameters
symbolandordermay beNULL. - After the order is executed, the trade and position will be passed in a recalculated state.
When modifying these objects, data integrity must be maintained.
(For example, when changing the order execution price, also adjust the trade price and the position's weighted average price).