TradingHaltRule

class pams.events.TradingHaltRule(event_id, prng, session, simulator, name)[source]

A trading halt is a market regulation that suspends the trading of some assets.

When the one of targetMarkets violate halting line, all of them will be halted. If you want to halt them separately, please make event separately. The current implementation sets pams.market.Market.is_running() = false for all targetMarkets when the price changed beyond the prespecified threshold range. Markets not included in targetMarkets are not affected, and the session setting (pams.Session.with_order_execution) is never changed by this rule.

After the halt starts at time t, the halted markets resume trading at time t + haltingTimeLength + 1, only if the session at that time allows order execution. If the halt continues over a session boundary, it is continued in the next session.

Note

This rule is hooked after execution, i.e., after all executions caused by one order are processed. Therefore, a halt prevents the subsequent executions, but not the executions caused by the triggering order. While halted, orders and cancels are still accepted, but the market price is not updated. Sharing a market among multiple TradingHaltRule events is not supported. Like other events, this rule is hooked from the beginning of the simulation, even if it is configured only in a later session.

hook_registration()[source]

Define when this event should be hooked by simulator.

This method is automatically hooked by simulator at the beginning of simulation. You must implement this.

Returns:

The list of event hook ( EventHook )

Return type:

List[EventHook]

hooked_after_execution(simulator, execution_log)[source]

Hook called after order executions if you set the event hook.

Parameters:
Return type:

None

hooked_before_step_for_market(simulator, market)[source]

Hook called at each step before market processing if you set the event hook.

Parameters:
  • simulator (Simulator) – simulator for reference.

  • market (Market) – market to be processed.

Return type:

None

setup(settings, *args, **kwargs)[source]

Event setup. Usually be called from simulator/runner automatically.

Parameters:

settings (Dict[str, Any]) – agent configuration. Usually, automatically set from json config of simulator. This must include the parameters “targetMarkets” and “triggerChangeRate”. This can include the parameters “haltingTimeLength” and “enabled”. The parameter “referenceMarket” is obsoleted.

Return type:

None

Returns:

None