When adding a Volume Filler to a strategy, the strategy started executing a very small number of Trades, despite executing thousands of Orders. Without the Volume Filler, the strategy executes the number of Trades normally.

I created a test strategy to try to understand this behavior, using a data feed file from the github repository (file: 2006-01-02-volume-min-001.txt in datas directory).

The Volume Filler used to test always returns a constant maximum volume.

The size of the executed Trade (235 in the truncated log) is much larger than the maximum that the strategy tries to limit when sending orders (100 in this test)

The cause of this seems to be that the Execution Bits of the partial Order are added up repeatedly

In the log, see the increasing size of the trade (5, 10, 25, 45, 60 ...) and how the exbits with the same minute seem to be being added up even if they had already been added in the previous call (+5, +10, + 15, + 20, + 25...) . I think that with each call it should add an execution bit (ie +5, +5, + 5 ...)

This log is to try to explain, but first I tried to debug the Backtrader source code, putting breakpoints in the strategy class for example, but my Python skills are not great (I actually learned this language to try to use Backtrader) ...

So: is there an error in the code that deals with Execution Bits? Or am I missing something?

Perhaps the FIFO order queue is maintained for each stock? And because you have more than one stock, the order of execution is defined by the list of stocks and not by the placement of buy and sell orders (the FIFO queue is valid only for 1 stock, not for a list of stocks)?

I'm realizing a multi symbol strategy can create a complex synchronization scenario. It is not enough to just copy a “single symbol” strategy, you need to pay attention to the many details and situations that can occur.

I implemented a multi-symbol mean reversion strategy and the results were much different than the strategy with only one symbol. I was suspicious about the results and found that the system was repeating days in the simulation.

The multi-symbol strategy processes multiple feeds, in the format:

def next(self):
…
for data in self.datas:
# Operations

While reviewing the CSV files of the feeds, I discovered two issues:

Some days were repeated

Some days were absent in some feeds (for example: in 100 stocks, there were some days when 1 stock had no trading)

I corrected the feeds with repeated days, but cannot do the same for the problem of absent data.

This lack of synchronization in the dates of the feeds can make a lot of difference in the result, because Backtrader needs to be synchronized for every day in the multi symbol simulation.

I did not understand it well how Backtrader "repeats" days if the feeds do not have da same days for all feeds, but it seems like that in cerebro.py ‘datas’ is synched early in the "_runonce (self, runstrats ) ":

while True:
# Check next incoming date in the datas
dts = [d.advance_peek() for d in datas]
dt0 = min(dts)

See that ‘dt0’ receives the "minimum feed". But it looks like this causes a day that has already been processed to be processed again if any item in 'datas' faild to 'advance'.

I tried putting a test at the beginning of the strategy to check if the days are repeated: