need to correct myself: analyzers are coordinated by (cerebro, strategy), not associated with the whole cerebro only. But analyzers are not lines so it does not fulfill my use case as I need to track last n bars metrics to do my optimization.
Latest posts made by Chen Xu
-
RE: Multiple strategies on single data
-
RE: Multiple strategies on single data
@vladisld thanks for the reply and keeping leading the work to make BT(2) alive!
The reason is b/c of that I need to track the position, value, and etc for each separate strategy so that I can solve some optimization problem to decide optimally how much of my capital needs to go to each strategy.
I am trying to use the wonderful trackers, say analyzers and observers, already built in BT, which is currently more for a whole broker account and thus for one cerebro instance.
I am actually already working on building these as some sub-strategy's under one strategy and create a few class elements under the mother strategy to track the position, value, return and etc for each separate sub-strategy. There is also an added benefit: when there is some cross-over order i.e. one substrategy try to sell and some other substrategy try to buy the same stock then I don't need to place the order for them at all. (kind of I trade with myself)
I am also curious, what is the use case(s) for adding two strategies to one cerebro instance? I understand in the optstrategy() case it is more for the purpose of speeding things up by loading data and iterating over bars once.
-
RE: What is broker.getvalue() supposed to return?
I think it makes sense to have broker.getvalues(datas=None) to get all the position values plus the cash.
But it is very confusing to have broker.getvalues([datas[j]]) return all the next position values from ticker j plus all the cash in the broker?
IMHO, it is better designed in the way such coherence is expected that all_the_cash_in_the_broker + sum([broker.get_values(datas=[d]) for d in datas) == broker.get_values()