Commission scripts are used for calculating the commission paid to a broker for each executed order, based on the broker's exact commission schedule.


Setup


A Commission script can be set up from the Advanced tab in the Desktop Settings.


Functions


Name

Description

OnInitialize()

This function is used for accepting the script parameters and for initializing the script prior to all other function calls. Once the script is assigned to a Desktop, its parameter values can be specified by the user and can be selected for optimization.

double OnCommission(int, int, int, double, double)

This function is called to calculate the commission paid to a broker for a specified order fill.

Note that the commission is denominated in the base currency of the Desktop.

OnShutdown()

This function is called when the script is shutdown.


Function Details


OnInitialize()

This function is used for accepting the script parameters and for initializing the script prior to all other function calls. Once the script is assigned to a Desktop, its parameter values can be specified by the user and can be selected for optimization.


double OnCommission(int strategyNumber, int orderIndex, int orderFillIndex, double fillQuantity, double fillPrice)

This function is called to calculate the commission paid to a broker for a specified order fill.

Note that the commission is denominated in the base currency of the Desktop.


Returns


The commission paid for the specified order fill, in the Desktop strategy currency.


Parameters


Type

Identifier

Description

int

strategyNumber

The strategy number to which the order belongs

int

orderIndex

The order index in the orders table to which the order fill belongs

int

orderFillIndex

The order fill index (0 being the first fill for the order, 1 being the next fill, etc.)

double

fillQuantity

The quantity of the new order fill for the specified order

double

fillPrice

The price of the new order fill for the specified order


OnShutdown()

This function is called when the script is shutdown.