Replies: 1 comment 1 reply
-
@jennyntd, from_holding simply generates an entry signal at the first timestamp and passes it to from_signals. The problem is that import pandas as pd
import numpy as np
import vectorbt as vbt
close = vbt.YFData.download(["BTC-USD", "ETH-USD"], missing_index='drop').get('Close')
size = pd.DataFrame.vbt.empty_like(close, fill_value=np.nan)
size.iloc[0] = [0.3, 0.7] # starting weights
pf = vbt.Portfolio.from_orders(
close,
size,
size_type='targetpercent',
group_by=True, # group of two columns
cash_sharing=True # share capital between columns
) Read the documentation to get a better idea of what's going on. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm wondering if the portfolio has more than one stocks and different weighting how can we incorporate that into the below code? Thanks.
"
price = vbt.YFData.download('BTC-USD').get('Close')
pf = vbt.Portfolio.from_holding(price, init_cash=100)
pf.total_profit()"
Beta Was this translation helpful? Give feedback.
All reactions