modular_trader.framework.order_execution#

Submodules#

Classes#

BaseOrderExecution

Base class for order execution strategies.

InstantOrderExecution

Instantly execute orders from allocations

ThresholdDeviationOrderExecution

Execute orders when any current positions deviate from the allocation targets by certain threshold in percentage.

Package Contents#

class modular_trader.framework.order_execution.BaseOrderExecution#

Bases: abc.ABC

Inheritance diagram of modular_trader.framework.order_execution.BaseOrderExecution

Base class for order execution strategies.

Note that run() is called by __call__() and should not be called directly.

__call__(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) None#
Parameters:
Return type:

None

abstract run(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) None#

Execute orders from the given allocations.

This method is called by __call__() and should not be called directly.

Parameters:
Return type:

None

class modular_trader.framework.order_execution.InstantOrderExecution#

Bases: modular_trader.framework.order_execution.base.BaseOrderExecution

Inheritance diagram of modular_trader.framework.order_execution.InstantOrderExecution

Instantly execute orders from allocations

Iterate through all allocations and place the corresponding orders. If an order is already pending, skip it. If the allocation is an AllocationTarget, close the position if weight is 0, otherwise place an order to set the weight to the target value. If the allocation is an AllocationAdjustment, place an order to adjust the weight by the target value.

run(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) None#

Execute orders from the given allocations.

This method is called by __call__() and should not be called directly.

Parameters:
Return type:

None

class modular_trader.framework.order_execution.ThresholdDeviationOrderExecution#

Bases: modular_trader.framework.order_execution.instant.InstantOrderExecution

Inheritance diagram of modular_trader.framework.order_execution.ThresholdDeviationOrderExecution

Execute orders when any current positions deviate from the allocation targets by certain threshold in percentage.

The threshold is in decimal format; e.g. 0.05 = 5%

Args:

threshold (float, optional): The threshold in decimal format. Defaults to 0.05.

run(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) None#

Execute orders from the given allocations.

This method is called by __call__() and should not be called directly.

Parameters:
Return type:

None

threshold: float = None#