modular_trader.framework.risk_management#
Submodules#
Classes#
Base class for risk management. |
|
Fixed stop loss. |
|
No-op risk management strategy. |
Package Contents#
- class modular_trader.framework.risk_management.BaseRiskManagement#
Bases:
abc.ABC
Base class for risk management.
This class defines the interface for all risk management strategies.
The __call__ method is called by the framework to apply the risk management strategy to the given allocations.
The run method is called by __call__ and should be implemented by subclasses to perform the actual risk management logic.
- __call__(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection)#
- Parameters:
context (modular_trader.context.Context)
allocations (modular_trader.allocation.AllocationCollection)
- abstract run(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) modular_trader.allocation.AllocationCollection #
- Parameters:
context (modular_trader.context.Context)
allocations (modular_trader.allocation.AllocationCollection)
- Return type:
- class modular_trader.framework.risk_management.FixedStopLossRiskManagement#
Bases:
modular_trader.framework.risk_management.base.BaseRiskManagement
Fixed stop loss.
Liquidate positions if unrealized loss percent >= percent_loss.
- run(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) modular_trader.allocation.AllocationCollection #
Liquidate positions if unrealized loss percent >= percent_loss.
- Args:
context: The context to get the current positions from. allocations: The allocations to modify.
- Returns:
The modified allocations.
- Parameters:
context (modular_trader.context.Context)
allocations (modular_trader.allocation.AllocationCollection)
- Return type:
- percent_loss: float = None#
- class modular_trader.framework.risk_management.NullRiskManagement#
Bases:
modular_trader.framework.risk_management.base.BaseRiskManagement
No-op risk management strategy.
Leaves allocations unchanged.
- run(context: modular_trader.context.Context, allocations: modular_trader.allocation.AllocationCollection) modular_trader.allocation.AllocationCollection #
- Parameters:
context (modular_trader.context.Context)
allocations (modular_trader.allocation.AllocationCollection)
- Return type: