Discrete, continuous and order actions — what each number means, how a size becomes lots, and what a stop and a target do.
Choosing the kind
env_make takes action: discrete (the default), continuous or order. The kind decides what your agent sends to env_step and what the answer's action_space says.
| Kind | The agent sends | Good for |
|---|---|---|
discrete | 0, 1 or 2 | DQN, PPO with a categorical policy, tabular methods — the simplest start |
continuous | one number in [−1, 1] | policies with a Gaussian output (PPO, SAC, TD3) that also choose a size |
order | {side, size, stop, target} | agents that set their own protective stop and target |
01Discrete
| Action | Meaning | Size |
|---|---|---|
0 | flat — close any position | — |
1 | long | lots |
2 | short | lots |
lots is set in env_make, 0.01 by default.
02Continuous
The agent sends a target x between −1 and 1:
- its sign is the side — above zero long, below zero short;
- its size is the share of
lots: the volume islots × |x|, rounded to two decimals; - inside the deadband —
|x|belowdeadband,0.1by default — the action is flat.
x | With lots = 1.0 and the default deadband |
|---|---|
0.05 | flat (inside the deadband) |
0.5 | long 0.5 lots |
−0.25 | short 0.25 lots |
1.7 | long 1.0 lots (sizes above 1 count as 1) |
The deadband keeps a policy whose output hovers around zero from opening and closing a position on every candle.
03Order
The agent sends an object:
| Field | Values | Meaning |
|---|---|---|
side | 0, 1, 2 | flat, long, short |
size | 0 to 1 | the share of lots |
stop | 0 to max_points | the stop's distance from the entry price, in points; 0 for none |
target | 0 to max_points | the target's distance, in points; 0 for none |
For example {"side": 1, "size": 0.5, "stop": 200, "target": 400} opens a long of half of lots, with a stop 200 points below the ask it is filled at and a target 400 points above. The volume is rounded down to the market's volume step, and never below the market's smallest volume. Values outside their range are brought to its edge; max_points is 10,000 by default.
A stop or a target is a real order on the venue, so it can fill inside a step, while the clock moves to the next close — the next observation then shows the position gone.
04An action that keeps the side changes nothing
With every kind, an action whose side is the side already held sends nothing: holding long 0.5 lots and sending long 1.0 keeps the 0.5. The size, the stop and the target are set when a position opens. To change them, go flat for a step and open again — and pay the spread again, which is what it costs on a real venue too.
05When the venue refuses
The venue checks every order the way a broker does: the volume step, the smallest and largest volume, the stops level, the market's session. A refused order is never changed into another one; info.refused carries the sentence, and the agent stays where it was. Common causes:
- a stop or target closer to the price than the market's stops level allows;
- a market outside its trading session;
- a size the account's margin cannot hold.
06A participation cap
participation, a share between 0 and 1, caps an order's units at that share of the last closed candle's volume. A larger order is cut to fit — or, if what fits is smaller than the market's least volume, refused — and impact (a number you choose) is charged to the reward, never to the account: impact × units ÷ the candle's volume. info.participation shows what was asked and what was allowed. It is a model: on a recording whose volume is a tick count rather than traded units, the cap is arithmetic, not a fact about the market.