Skip to content

Add User-Defined Functions #8

@maxholloway

Description

@maxholloway

Add User-Defined Functions

Motivation

Users should be able to express behavior at the beginning of a backtest and at the end of a backtest. The default, of course, is that nothing special happens after a backtest starts or stops running. But what if a user wants to set some context variables before the backtest begins running? Or what if they want to make a graph after the backtest stops running, but they don't want to perform that behavior throughout the backtest?

Current Code

https://github.com/maxholloway/backtest/blob/ab8e7db4dfb67a000b3cf387d1c94297aedfd04e/src/Backtest.jl#L383-L399

Solution

  1. Add functions called onbegin and onend to StrategyOptions. These functions should take the standard user-defined function arguments. As of the time of writing, this would include only strat. Depending
  2. Invoke onbegin here: https://github.com/maxholloway/backtest/blob/ab8e7db4dfb67a000b3cf387d1c94297aedfd04e/src/Backtest.jl#L386
  3. Invoke onend here, replacing the current log statement: https://github.com/maxholloway/backtest/blob/ab8e7db4dfb67a000b3cf387d1c94297aedfd04e/src/Backtest.jl#L398

Status: Blocked until we implement context passing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersp2High Priority (priority 2)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions