vectorbt
vectorbt copied to clipboard
creating portfolio from order records has messed up init cash
so is it me or is there actually something wrong with the code
getting the data
data = vbt.CCXTData.download(
"BTCUSDT",
start='2023-01-11 UTC',
end='2023-01-13 UTC',
timeframe='2h',
exchange='bybit',
)
open = data.get('Open')
high = data.get('High')
low = data.get('Low')
close = data.get('Close')
vbt.settings.plotting["layout"]["template"] = "vbt_dark"
vbt.settings['caching']['enabled'] = False
entries = pd.Series([False]*24)
entries[0] = True
entries[8] = True
entries[11] = True
entries[13] = True
entries[17] = True
entries[19] = True
entries[21] = True
creating a portfolio from signals
pf_vbt = vbt.Portfolio.from_signals(
close,
entries,
sl_stop=0.01,
sl_trail=False,
tp_stop=0.02,
high=high,
low=low,
open=open,
fees=0.,
size=.01,
size_type=2,
init_cash=100,
# direction='longonly',
accumulate='addonly'
)
pf_vbt.init_cash
the init cash here is 100
create another portfolio from the first portfolios order records
pf_vbt2 = vbt.Portfolio(
wrapper=close.vbt.wrapper,
init_cash=100,
order_records=pf_vbt.order_records,
log_records=None,
close=close,
cash_sharing=False,
)
pf_vbt2.init_cash
this ones init cash is 1.99 which messes up all the stats
is this a me thing or a vbt thing because i noticed that when i run it in debug mode you get to the base.py in portfoilio and during the init phase at around line 1565 once you do self._cash_sharing the self.init_cash changes to 199 but the self._init_cash stays at 100


not sure what is going on
This issue is stale because it has been open for 90 days with no activity.