Module engine
Classes
class Analyser (data: List[Dict[str, TSData]], backtest_result_state: dict)-
This class is used to analyse the backtest results. It has few utility methods that helps the user to visualize the backtest results.
Methods
def focus(self, ticker: str)-
This method will return a class that focus on a given ticker. It will have methods to visualize the trades and the indicators for the given ticker.
Args:
ticker: The ticker to lookoutReturns:
- TickerFocus
def get_margin_calls(self) ‑> List[Dict[str, Union[datetime.datetime, dict]]]-
This method returns the margin calls of the backtest.
Returns:
- The margin calls
def get_trade_history(self)-
This method returns the trade history of the backtest.
Returns:
- The trade history
def get_transactions(self) ‑> List[Dict[str, Union[datetime.datetime, dict]]]-
This method returns the transactions of the backtest.
Returns:
- The transactions
def inspect(self, ticker: str, timestamp: datetime.datetime)-
This method returns a TradeInspector object that can be used to visualize the trade order on the chart.
Args:
ticker: The ticker to inspect
timestamp: The timestep to inspectReturns:
- The TradeInspector object
class TickerFocus (ticker: str, data: List[TSData], main_timestep: int, trades: List[Trade], bktst_state: List[StepState], window: int)-
Static methods
def format_float(n: float, length: int) ‑> str-
Make sure that the float value is converted as a string and is aligned to the right and with the good len.
Returns:
- The float as a formattted string
class TradeInspector (ticker: str, data: List[TSData], main_timestep: int, trade_order: TradeOrder, trade: Trade, bktst_state: StepState)-
Methods
def get_indicators(self)-
This method returns the indicators for the trade order. It is meant to be override by the user.
Returns:
- indicators as 'make_addplot' objects.
def plot(self, indicator_cb:= <function TradeInspector.<lambda>>) -
This method plots the trade order on the chart with the price history (Only in the window) This helps visualize what the strategy saw to make that decision.
Legend
Green: Enter a Position Red: Exit a Position ^: Buy v: Sell
Args:
indicator_cb: The indicator callback to plot on the chart. Returns a list of 'make_addplot' objectsReturns:
- None