# Playground: Customizers
Customizers can be used to shape the behaviour of a trading engine and its accounts.
# Commission customizer
Commissions can be added through a commission customizer, a custom function that given the order and the details of the upcoming trade, returns a commission for the respective trade.
- Example 1
import { decimal, } from "@reiryoku/mida";
// Used to set a fixed commission of 1 USD to all trades
engine.setCommissionCustomizer(() => [ "USD", decimal(1), ]);
- Example 2
// Used to set a commission relative to the traded volume
engine.setCommissionCustomizer((order, upcomingTrade) => {
return [
"USD",
upcomingTrade.volume.mul(3), // Commission = 3 USD per lot
];
});
# Latency customizer
Latency and slippage can be simulated through a latency customizer, a custom function called when a trading account places an order.
- Example 1
// Set a latency of 1 second when placing an order, this means that 1 second of data
// will be elapsed before actually placing the order
myAccount.setLatencyCustomizer(() => 1);
- Example 2
import { generateInRandomFloat, } from "@reiryoku/mida";
// Set a random latency bewteen 0.1 and 2 seconds when placing an order
myAccount.setLatencyCustomizer(() => generateInRandomFloat(0.1, 2));