vectorbt
vectorbt copied to clipboard
Returns do not make sense?
I created signals and position size in a custom way and then passed the price & size arrays to Portfolio.from_orders function as below:
pf = vbt.Portfolio.from_orders(df.Price, df.Quantity, direction='both', init_cash=10000, size_type='TargetAmount', freq='1s')
The cumulative returns graph looks the same as my manually computed cumulative return except the scale. The actual returns seem to be way off. I get 45.74% manually computed cumulative return (which is correct), while I get 0.459% with VectorBT.
In fact, multiplying my position size array by 10, 100, or 1000 changes nothing with VectorBT.
I manually computed the cumulative return by calculating the return and then multiplying that return by the quantity I am holding, as you can see below:
df["return"] = (df.Price- df.Price.shift(1)) / df.Price.shift(1)
df['actual_returns'] = df['return'] * df['quantity']
df['cumulative_return'] = (df['actual_returns']+1).cumprod()
The confusing bit is why does the return not change with the size of the quantity? In one trial I enter the position with size=0.02 and then increase that by 3x each time a signal comes, while in another trial I start with size=2. Total Return [%] in both cases is 0.459%.
Cumulative returns are computed from equity, that is, if you're not using the most of your cash, your holdings will be small relative to the overall portfolio value, thus driving the magnitude of the returns down.
This issue is stale because it has been open for 90 days with no activity.