Skip to main content

Module stop

Module stop 

Source
Expand description

Stop orders: the request of the shared interface to ALOR’s stop and stop-limit orders, and back.

ALOR has two kinds of stop orders, and both keep the trigger price and the condition (more, less, …): a stop order (a market order is made on trigger) and a stop-limit order (a limit order is made, with its own price). The shared interface has three kinds:

RequestALOR
StopLoss, TakeProfit without limit_pricea stop order. The condition follows the side and the kind (a sell stop-loss triggers when the price falls to the trigger price, a sell take-profit when it rises to it)
StopLoss, TakeProfit with limit_price, StopLimita stop-limit order (a StopLimit without limit_price is refused)

A stop order read back has the kind StopLoss or TakeProfit (from the side and the condition) and a stop-limit order has the kind StopLimit: ALOR does not keep which of the two a bot meant.

Constants§

GTC_HORIZON_SECS
The stop orders of ALOR end at a given time; a stop order that is “good till cancel” gets this long.

Functions§

build
The wire request and whether it is a stop-limit order (true) or a stop order (false).
cid_of
The cid in the comment of a stop order record, if it is ours.
condition
The trigger condition for the side and the kind.
end_time
The end of the stop order, Unix seconds, from the expiry. now_secs is the time now.
snapshot
A stop order of the portfolio as a snapshot. The cid is the one the connector found (None if the order is not ours). None if the record lacks the side, the quantity or the trigger price.
state_of
The state of a stop order from its status: a working one waits for the trigger.