Skip to content

adding *args, **kwargs to add_execution, set_after_exec and set_before_exec #196

@none2003

Description

@none2003

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":
            pass

So, 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":
            pass

set_after_exec and set_before_exec can also be handled in the same way.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions