JSONFileStore#

API documentation for tradeexecutor.state.store.JSONFileStore Python class in Trading Strategy framework.

class JSONFileStore[source]#

Bases: StateStore

Store the state of the executor as a JSON file.

  • Read by strategy on a startup

  • Read by webhook when asked over the API

__init__(path, on_save=None)[source]#
Parameters:
  • path (Union[Path, str]) – Path to the JSON file

  • on_save (Callable) – Save hook. Used by RunState.read_only_state_copy

Methods

__init__(path[, on_save])

param path:

create(name)

Create a new state storage.

is_pristine()

State has not been written yet.

load()

Load the state from the storage.

sync(state)

Write new JSON state dump using Linux atomic filereplacement.

__init__(path, on_save=None)[source]#
Parameters:
  • path (Union[Path, str]) – Path to the JSON file

  • on_save (Callable) – Save hook. Used by RunState.read_only_state_copy

is_pristine()[source]#

State has not been written yet.

Return type:

bool

load()[source]#

Load the state from the storage.

Return type:

State

sync(state)[source]#

Write new JSON state dump using Linux atomic filereplacement.

Parameters:

state (State) –

create(name)[source]#

Create a new state storage.

Parameters:

name (str) – Name of the strategy this State belongs to

Return type:

State