Module serve
Classes
class Renderer-
This class is designed to convert a StateSignals object into a file or multiple files. The goal of exporting a StateSignals object is to be able to visualize the data in a human-readable format or to export it into a program-readable format (example: JSON, CSV, etc) for further processing. The class can be used as a decorator or derived. The derived class must implement the render method.
Example
The first example is deriving the class and implementing the render method.
>>> from backtest.serve import Renderer >>> class MyRenderer(Renderer): ... def render(self, state: StateSignals, base_path: PurePath): ... print(f"Rendering {state} to {base_path}")The second example is using the class as a decorator.
>>> from backtest.serve import Renderer >>> @Renderer() ... def my_renderer(state: StateSignals, base_path: PurePath): ... print(f"Rendering {state} to {base_path}")Parent
- abc.ABC
Methods
def render(self, state: StateSignals, base_path: pathlib.PurePath)-
Renders the state and signals and save it to a file or multiple files inside the provided base path.
Args:
state: The state and signals to render
base_path: The base path to save the rendered files
class RendererList (*renderers: Renderer)-
A class that have the same structure as a Renderer, but it contains a list of renderers. This class is used to combine multiple renderers into a single renderer. When the render method is called, it will call the render method of each renderer in the list.
Note: The order of the renderers in the list is kept.
Methods
def render(self, state: StateSignals, base_path: pathlib.PurePath)-
Run multiple renderers with the given state and base path.
Args:
state: The state and signals to render
base_path: The root path to store the rendered filesReturns:
- None