Hooks¶
Hook is a predefined plugin function called by the server at a specific point in processing.
For example, HookTradeRequestOpen is called whenever a client request is added to the processing queue.
Full descriptions are available in the Hooks documentation.
Every plugin must contain at least two hook functions:
- AboutPlugin — provides the server with basic plugin information.
- CreatePlugin — performs global plugin initialization and receives the server interface as a parameter.
- DestroyPlugin — performs global plugin deinitialization.
If a plugin requires cleanup, such as closing threads or sockets, implement DestroyPlugin. It is called when the server shuts down.
Warning: access to the server interface is prohibited after CreatePlugin returns.
For example, a plugin-owned thread should be stopped in DestroyPlugin instead of waiting for the plugin to unload.
How to add plugins to the Docker image?
Your answer or details here.
Hook Processing Flow¶

Flow explanation:
- The server invokes a hook function, such as
HookUserAdd. - The request passes through the configured plugin chain:
- Each plugin receives control in priority order.
- If a plugin returns
RET_OK, control passes to the next plugin. - Any other return code stops processing, and the server does not call subsequent plugins for that hook.
- If every plugin returns
RET_OK, the server completes event processing.
Thus, a hook is processed until the first rejection (No in the diagram), after which remaining plugins are skipped.
Trades Hooks¶
| Hook | Description |
|---|---|
| HookTradeRequestOpen | Hook for adding a checked trade request to the queue |
| HookTradeProcessOpen | Hook for trade request execution |
| HookTradeRequestClose | Hook for Close By request execution |
| HookTradeProcessClose | Hook for checking if a trade request matches routing rules |
| HookTradeProcessCommission | Hook for calculating the commission blocked when placing an order |
| HookTradeProcessMarginCall | Hook for margin calculation (in progress) |
| HookTradeProcessStopOut | Hook for stop out calculation (in progress) |
Accounts Hooks¶
| Hook | Description |
|---|---|
| HookAccountAdd | A hook of an event of adding a new client record |
| HookAccountUpdate | A hook of an event of client record update |
| HookAccountDelete | A hook of an event of client record deletion |
| HookAccountLogin | A hook of a client's connection to the server |
System Hooks¶
| Hook | Description |
|---|---|
| HookServerConnect | The hook for managing ScaleTrade platform components connections to Gateway API. |