We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I tried to override the default benchmark returns #247 .
I found that VectorBT is try to broadcast it to an undefined "obj".
AttributeError: 'Portfolio' object has no attribute 'obj'
vectorbt/vectorbt/portfolio/base.py
Line 5154 in 67da37e
Reproduction code
Simulate comparing two Portfolio results
import vectorbt as vbt import numpy as np import pandas as pd close1 = pd.DataFrame( { "symbol_a": np.abs(np.random.randn(10)) * 10, "symbol_b": np.abs(np.random.randn(10)) * 10, } ) close2 = close1[["symbol_a"]] raw_signal1 = np.random.randn(10) signal1_a = (raw_signal1 > 0.5) * 1 + (raw_signal1 < -0.5) * -1 signal1_b = (raw_signal1 > 0.5) * 1 + (raw_signal1 < -0.5) * -1 signal1 = pd.DataFrame({"symbol_a": signal1_a, "symbol_b": signal1_b}) raw_signal2 = pd.Series(np.random.randn(10), name="symbol_a") signal2 = (raw_signal2 > 0.5) * 1 + (raw_signal2 < -0.5) * -1 pf1 = vbt.Portfolio.from_signals( close1, entries=signal1 == 1, exits=signal1 == -1, freq="T" ) pf2 = vbt.Portfolio.from_signals( close2, entries=signal2 == 1, exits=signal2 == -1, freq="T" ) # ok print(pf1.stats(settings=dict(benchmark_rets=pf2.returns()))) # ok print(pf1.stats(column="symbol_a", settings=dict(benchmark_rets=pf2.returns()))) # ok print(pf2.stats(settings=dict(benchmark_rets=pf1['symbol_a'].returns()))) # ---- error ---- # works if I comment the bug line pf1.plot( column="symbol_a", settings=dict(benchmark_rets=pf2.returns()), subplots=[ "orders", "trade_pnl", "cum_returns", "drawdowns", "underwater", "asset_flow", "asset_value", "assets", "cash", "cash_flow", "gross_exposure", "net_exposure", "trades", "value", ], ) # works if I comment the bug line pf2.plot( column="symbol_a", settings=dict(benchmark_rets=pf1.returns()), subplots=[ "orders", "trade_pnl", "cum_returns", "drawdowns", "underwater", "asset_flow", "asset_value", "assets", "cash", "cash_flow", "gross_exposure", "net_exposure", "trades", "value", ], )
Version
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I tried to override the default benchmark returns #247 .
I found that VectorBT is try to broadcast it to an undefined "obj".
AttributeError: 'Portfolio' object has no attribute 'obj'
vectorbt/vectorbt/portfolio/base.py
Line 5154 in 67da37e
Reproduction code
Version
The text was updated successfully, but these errors were encountered: