-
Notifications
You must be signed in to change notification settings - Fork 376
Open
Description
Currently, if you want to pass parameters to fn, you must use the pybroker.param method, which is rather inconvenient, eg:
pybroker.param("run_type", "monthly")
def some_exec(ctx):
run_type = pybroker.param("run_type")
if run_type:
if run_type == "monthly":
passSo, it will be great if *args, **kwargs can be add to add_execution, set_after_exec and set_before_exec, like:
def add_execution(
self,
fn: Optional[Callable[[ExecContext], None]],
symbols: Union[str, Iterable[str]],
models: Optional[Union[ModelSource, Iterable[ModelSource]]] = None,
indicators: Optional[Union[Indicator, Iterable[Indicator]]] = None,
*args,
**kwargs,
):these extra args can later be passed to fn directly and then referenced within fn, thereby increasing the flexibility of fn.
For example:
strategy.add_execution(some_exec, symbols, indicators=[inv_vol], run_type="monthly")
def some_exec(ctx, run_type):
if run_type:
if run_type == "monthly":
passset_after_exec and set_before_exec can also be handled in the same way.
Metadata
Metadata
Assignees
Labels
No labels