Module serve

Classes

class ServerStatus (*args, **kwds)

Used to indicate the status of the server after the strategy has been executed.

Parent

  • enum.Enum

Class variables

var ERROR
var OK
var WARNING
class StateSignals (account: Account, broker: Broker, signals: Dict[str, TradeOrder], strategy: Strategy, timestamp: datetime.datetime, cash_controller: CashControllerBase, initial_cash: float, index_data: Optional[Dict[str, TSData]] = None, data: Optional[List[Dict[str, TSData]]] = None, main_idx: Optional[int] = None, backtest_params: Optional[Dict[str, Any]] = None, status: ServerStatus = Ok, exception: Optional[Exception] = None, warnings: Optional[List[warnings.WarningMessage]] = None)

Class that stores the signals given y the strategy for the current timestep and state of the account, the broker and the portfolio. Its more of a dataclass that stores the signals and the state of the account, broker and portfolio. It also has few method for easy access to the signals.

Args:

account: The account object
broker: The broker object
signals: The signals emitted by the strategy
strategy: The strategy object
timestamp: The current timestamp (i.e. the time at which the strategy was executed)
cash_controller: The cash controller object
initial_cash: The initial cash in the account (Useful to calculate the returns in a renderer)
index_data: The index data for the current timestamp. Same time-resolution as the main time resolution.
data: The data for the current timestamp.
main_idx: The index of the main time resolution in the data list.
backtest_params: The backtest parameters passed as a dictionary.
status: The server status after the strategy has been executed.
exception: An exception object if an exception was raised during the strategy execution.
warnings: Any warning objects that were raised during the strategy execution.

Instance variables

var buy_long_signals : Dict[str, TradeOrder]

Returns the buy long signals

var buy_short_signals : Dict[str, TradeOrder]

Returns the buy short signals

var sell_long_signals : Dict[str, TradeOrder]

Returns the sell long signals

var sell_short_signals : Dict[str, TradeOrder]

Returns the sell short signals

Methods

def get(self, item: str, default: Optional[Any] = None) ‑> Union[TradeOrder, Any]

Returns the signal for the given ticker

Args:

item: The ticker to search for
default: The default value to return if no signals were emitted for the given ticker

Returns:

The TradeOrder object or the default value