Open brettelliot opened 2 years ago
@brettelliot Did you ever find a solution for this? I'm stuck with the exact same problem. I don't want the algo to rebalance with every transaction made and just keep the existing positions as they are
@Helikoptermann2 Hey, I'm facing the same issue. Did you ever figure out what to do?
I feel like it would be possible with some custom algos but I don't know how to implement it exactly.
No, I did not find a solution and then stepped away from this package. But would still be interested in a solution
Looking at the docs I see that the SecurityBase
class has methods for allocate()
and transact()
, which are meant to buy/sell for a specific amount/quantity. I think we would just have to create a custom algo for buying/selling with these methods instead of using rebalance.
There's also the StrategyBase
class which also has methods for allocate()
and transact()
. These seem to behave a little differently.
https://pmorissette.github.io/bt/bt.html#bt.core.SecurityBase https://pmorissette.github.io/bt/bt.html#bt.core.StrategyBase
Hi,
Let's say i want to build a trend strategy with a universe of 10 stocks. Id like the strategy to invest up to 10% of the total portfolio value when any stock is trending up. Say stock A goes up, and i end up buying 100 shares. When stock B goes up, I want to invest up to 10% of the current portfolio value (which is hopefully higher since we invested in stock A because it was going up). But I don't want to change anything about stock A's position. We should keep the 100 shares of stock A no matter what percentage of the portfolio they amount to until the strategy decides to sell stock A.
Can bt backtest a strategy like this?