quantlab.execution.rules.plan_orders#

quantlab.execution.rules.plan_orders(weights, fill, valuation, delisted, settings=ExecutionSettings(sizing_basis='fill', fees=0.0, slippage=0.0))[source]#

Return the orders the market accepts for weights decided on each bar.

Parameters:
weightsarray-like

Target weights on [T, S], row t decided at bar t; NaN keeps a holding.

fill, valuationarray-like

The fill and valuation prices on [T, S] as given, NaN where a bar has none; both are forward-filled here.

delistedarray-like

Booleans on [T, S]: a symbol’s last bar before it delists.

settingsExecutionSettings

The sizing basis, fees and slippage.

Returns:
OrderPlan

The plan of every fill bar.

Examples

AAA has no fill price on bar 2, so bar 1’s exit is rejected there:

>>> import numpy as np
>>> plan = plan_orders(
...     np.array([[1.0], [0.0], [np.nan]]),
...     np.array([[10.0], [10.0], [np.nan]]),
...     np.array([[10.0], [10.0], [10.0]]),
...     np.zeros((3, 1), dtype=bool),
... )
>>> plan.target[:, 0].tolist(), plan.size[:, 0].tolist(), plan.rejected[:, 0].tolist()
([nan, 1.0, 0.0], [nan, 1.0, nan], [False, False, True])