# VectorBT Work Request Specification ## Multiple Order Strategy Backtest Notebook We have written a strategy where there are regularly multiple sequential orders of the same type, i.e. [long enter, long enter, np.nan, long enter, long exit, np.nan, long exit, long enter, long enter] We would love a notebook demonstrating how to explicitly backtest this using different parameterizable order sizes, (trailing and non-trailing) stop losses, target percent of cash, various stopping behaviours (i.e. exit in full upon directional reversal, vs "reduce position" by target percent). It would be excellent to demonstrate how to do this with one long-only version and one short-only version on the same signal dataframe (i.e. entry/exits are inverted between long and short). We have generated all of the entry and exit signals in advance, and it currently works with from_signals and from_orders but it is routinely skipping orders, so we are trying to get to the root of why this isn't working. We aren't sure if we are using the accumulate setting properly. We haven't tried creating an order_func_nb yet, perhaps there is a simple wrapper we can try on this. It would also be excellent to have a debug tracelog to see where an order is not executed, compared against the input list of entries/exits, and why this lack of execution happened. ## Perpetual Futures Simulation We want to update the cash management section of vectorbt's portfolio class to handle perpetual futures. More info on perpetual futures here: https://o3schools.com/perpetual-futures-contracts/ In particular, some features that we'd like: - Funding rate simulation - Parameters: - Funding period (either period-based i.e. every 80 ticks, time-based i.e. '8h', or as an event array i.e. [np.nan, np.nan, ... True, np.nan, ...]) - Funding rate - Either as its own float array or by calculating it using its components as inputs: - Interest rate - Premium - Leverage simulation - Cross-position collateral & cash / margin management - As a strategy performs positively or negatively, increase or decrease the 'futures wallet' cash position (even though profits are "unrealized"). This mainly serves to constrain order size at any given moment (i.e. lose cash as your entered position goes down, you can't buy with the same amount as you did before). This is to emulate popular cryptocurrency perpetual futures exchanges such as Binance, FTX or dYdX. - Liquidation simulation - use "mark price"