For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
If I add two strategies, how to manage the positions of each strategy
-
two strategies have the same next() method
def next(self): for i,d in enumerate(self.datas): pos = self.getposition(d) if pos.size: if self.inds[d]['signal'] < 0: self.close(data=d) print(self.p.name) elif self.inds[d]['signal'] > 0: self.buy(data=d) pass
when I use these codes, the strategy will do short selling making the cash higher than the total account value. But I don't want to short, so how to make each strategy have their own position
-
@the-world AFAIK position is maintained by a broker per data and there is just a single broker per Cerebro engine. So in order for multiple strategies to have an independent positions, either they need to work on different datas or they need to be run using different engine instances.