trading.execution.backtester.orders.stoploss_order_manager
trading.execution.backtester.orders.stoploss_order_manager
StoplossOrderManager
StoplossOrderManager(event_bus: EventBus)
Holds pending stoploss order events & publishes order events if the stoploss is met. If the stoploss event is exited manually (all shares are sold), the stoploss has no effect. Assumes only one ticker to be traded & no pyramiding.
Initializes StoplossOrderManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_bus
|
EventBus
|
The event bus to publish order events to upon the stoploss price being met. |
required |
Source code in src\contango\trading\execution\backtester\orders\stoploss_order_manager.py
30 31 32 33 34 35 36 37 38 39 40 41 | |
check_if_stoploss_met
check_if_stoploss_met(market_data: MarketDataEvent) -> None
Executes the pending stoploss order when the market bar breaches the stop price.
Publishes an OrderEvent upon the stoploss being reached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market_data
|
MarketDataEvent
|
The current market data event (bar) for the OHLCV data. |
required |
Source code in src\contango\trading\execution\backtester\orders\stoploss_order_manager.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
collect_portfolio_snapshot
collect_portfolio_snapshot(snapshot: PortfolioSnapshotEvent) -> None
Sets the latest & previous portfolio snapshots so the manager can tell whether the stop is still relevant.
Source code in src\contango\trading\execution\backtester\orders\stoploss_order_manager.py
49 50 51 52 53 54 | |
collect_stoploss_order_event
collect_stoploss_order_event(stoploss_order: StoplossOrderEvent) -> None
Stores the latest pending stoploss order.
Source code in src\contango\trading\execution\backtester\orders\stoploss_order_manager.py
43 44 45 46 47 | |