Trigger#
API documentation for tradeexecutor.state.trigger.Trigger Python class in Trading Strategy framework.
- class Trigger[source]#
Bases:
object
Trigger data for market orders.
Triggers can be on both on
Unopened positions, see
tradeeexecutor.state.portfolio.Portfolio.pending_positions
where the trigger is on the trade that will open the position (market limit order case)Opened positions, see
tradeeexecutor.state.position.TradingPosition.pending_positions
where the trigger order is on the increase/reduce position (partial take profit case)Trigger orders can be created to make trades to happen outside the strategy decision cycle
Market limit order is the most famous trigger order from the TradFi markets, used to enter into breakout positions
Triggers are executed in the s
Nested structure inside
tradeexecutor.state.trade.TradeExecution
Any price structure estimations on trigger trades is based on the time of the trigger creation, and maybe very different when the trigger is executed
- __init__(type, condition, price=None, triggering_at=None, triggering_at_delta=None, expires_at=None, expired_at=None, triggered_at=None)#
- Parameters:
type (TriggerType) –
condition (TriggerCondition) –
price (float | None) –
triggering_at (datetime.datetime | None) –
triggering_at_delta (datetime.timedelta | None) –
expires_at (datetime.datetime | None) –
expired_at (datetime.datetime | None) –
triggered_at (datetime.datetime | None) –
- Return type:
None
Methods
__init__
(type, condition[, price, ...])This trigged is already executed.
is_expired
(ts)This trigger has expired.
is_triggering
(market_price, timestamp, ...)Is the given price triggering a tride.
Attributes
Do we trigger when price crossed above or below
When this trigger is executed
When to take action
Always executed at a certain time.
Always executed at a certain time.
After expiration, this trade execution is removed from the hanging queue
When this trigger was marked as expired
When the trigger happened
- type: TriggerType#
Do we trigger when price crossed above or below
- condition: TriggerCondition#
When this trigger is executed
- triggering_at: datetime.datetime | None#
Always executed at a certain time.
See TriggerType.timed_absolute
- triggering_at_delta: datetime.timedelta | None#
Always executed at a certain time.
See TriggerType.timed_relative_to_open
- expires_at: datetime.datetime | None#
After expiration, this trade execution is removed from the hanging queue
- expired_at: datetime.datetime | None#
When this trigger was marked as expired
- triggered_at: datetime.datetime | None#
When the trigger happened
- is_expired(ts)[source]#
This trigger has expired.
Expired triggers must not be executed, and must be moved to past triggers.
- is_triggering(market_price, timestamp, position_open_time)[source]#
Is the given price triggering a tride.
- __init__(type, condition, price=None, triggering_at=None, triggering_at_delta=None, expires_at=None, expired_at=None, triggered_at=None)#
- Parameters:
type (TriggerType) –
condition (TriggerCondition) –
price (float | None) –
triggering_at (datetime.datetime | None) –
triggering_at_delta (datetime.timedelta | None) –
expires_at (datetime.datetime | None) –
expired_at (datetime.datetime | None) –
triggered_at (datetime.datetime | None) –
- Return type:
None