

Instead of creating a Order tuple for each asset and timestamp (which may waste a lot of memory) and appending it to a (potentially huge) list for processing, om_orders() takes each of those information pieces as an array, broadcasts them against each other, and creates a Order tuple out of each element for us. om_orders() is the most straightforward and the fastest out of all simulation modes.Īn order is a simple instruction that contains size, price, fees, and other information (see Order for details about what information a typical order requires). Offers a broad range of risk & performance metrics based on order records.Receives the returned order records and initializes a new Portfolio object.Updates the current state such as the cash and asset balancesĬonstruction phase (in the particular class method):.If the order has been filled, registers the result by appending it to the order records.If an order has been issued, processes the order and fills/ignores/rejects it.Generates an order or skips the element altogether.Gets all available information related to this element and executes the logic.For each asset and timestamp (= element):.The simulation function traverses the broadcasted shape element by element, row by row (time dimension), column by column (asset dimension).Simulation phase (in the particular simulation function using Numba): Passes everything to a Numba-compiled simulation function.Does some basic validation of inputs and converts Pandas objects to NumPy arrays.Resolves parameter defaults by searching for them in the global settings.Receives a set of inputs, such as signal arrays and other parameters.Preparation phase (in the particular class method): Portfolio class does quite a few things to simulate your strategy.

import numpy as np > import pandas as pd > from datetime import datetime > import talib > from numba import njit > import vectorbt as vbt > from import adjust_opacity > from _ import map_enum_fields > from _fns import broadcast, flex_select_auto_nb, to_2d_array > from import SizeType, Direction, NoOrder, OrderStatus, OrderSide > from vectorbt.portfolio import nb Workflow ¶
